From a1a3526c170cb3a6f1cffa056838855b8bf8818f Mon Sep 17 00:00:00 2001 From: Bertie690 Date: Fri, 1 Aug 2025 18:34:00 -0400 Subject: [PATCH] Removed deprecated functions from phase interceptor --- src/phase.ts | 2 + test/abilities/moxie.test.ts | 7 +- test/abilities/wimp-out.test.ts | 2 +- test/battle/battle-order.test.ts | 14 +- test/battle/battle.test.ts | 131 +----------------- test/items/lock-capsule.test.ts | 22 ++- test/items/temp-stat-stage-booster.test.ts | 13 +- test/misc.test.ts | 16 --- test/moves/fusion-flare-bolt.test.ts | 85 ++++++------ test/moves/growth.test.ts | 4 +- test/moves/metronome.test.ts | 2 +- test/moves/parting-shot.test.ts | 65 +++------ test/moves/tackle.test.ts | 6 +- test/moves/tail-whip.test.ts | 4 +- .../mystery-encounter/encounter-test-utils.ts | 13 +- .../berries-abound-encounter.test.ts | 10 +- .../bug-type-superfan-encounter.test.ts | 18 +-- .../clowning-around-encounter.test.ts | 9 +- .../dancing-lessons-encounter.test.ts | 6 +- .../department-store-sale-encounter.test.ts | 8 +- .../fight-or-flight-encounter.test.ts | 10 +- .../fun-and-games-encounter.test.ts | 20 +-- .../global-trade-system-encounter.test.ts | 2 +- .../mysterious-challengers-encounter.test.ts | 12 +- .../teleporting-hijinks-encounter.test.ts | 8 +- .../the-expert-breeder-encounter.test.ts | 19 ++- .../the-strong-stuff-encounter.test.ts | 4 +- .../the-winstrate-challenge-encounter.test.ts | 12 +- .../trash-to-treasure-encounter.test.ts | 6 +- .../encounters/weird-dream-encounter.test.ts | 10 +- test/phases/mystery-encounter-phase.test.ts | 8 +- test/test-utils/game-manager.ts | 13 +- .../helpers/challenge-mode-helper.ts | 2 +- test/test-utils/helpers/reload-helper.ts | 2 +- test/ui/pokedex.test.ts | 4 +- test/ui/starter-select.test.ts | 47 +++---- test/ui/transfer-item.test.ts | 4 - test/ui/type-hints.test.ts | 10 +- 38 files changed, 213 insertions(+), 417 deletions(-) diff --git a/src/phase.ts b/src/phase.ts index 46a81dddb6f..eec79e493ef 100644 --- a/src/phase.ts +++ b/src/phase.ts @@ -2,8 +2,10 @@ import { globalScene } from "#app/global-scene"; import type { PhaseMap, PhaseString } from "#types/phase-types"; export abstract class Phase { + /** Start the current phase. */ start() {} + /** End the current phase and start a new one. */ end() { globalScene.phaseManager.shiftPhase(); } diff --git a/test/abilities/moxie.test.ts b/test/abilities/moxie.test.ts index 28b90042969..ae63093b6a2 100644 --- a/test/abilities/moxie.test.ts +++ b/test/abilities/moxie.test.ts @@ -3,9 +3,6 @@ import { BattlerIndex } from "#enums/battler-index"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import { Stat } from "#enums/stat"; -import { EnemyCommandPhase } from "#phases/enemy-command-phase"; -import { TurnEndPhase } from "#phases/turn-end-phase"; -import { VictoryPhase } from "#phases/victory-phase"; import { GameManager } from "#test/test-utils/game-manager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; @@ -46,7 +43,7 @@ describe("Abilities - Moxie", () => { expect(playerPokemon.getStatStage(Stat.ATK)).toBe(0); game.move.select(moveToUse); - await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(VictoryPhase); + await game.phaseInterceptor.to("VictoryPhase"); expect(playerPokemon.getStatStage(Stat.ATK)).toBe(1); }); @@ -67,7 +64,7 @@ describe("Abilities - Moxie", () => { game.move.select(moveToUse, BattlerIndex.PLAYER_2); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(firstPokemon.getStatStage(Stat.ATK)).toBe(1); }, diff --git a/test/abilities/wimp-out.test.ts b/test/abilities/wimp-out.test.ts index a1c19a12fd4..a32ecaf5983 100644 --- a/test/abilities/wimp-out.test.ts +++ b/test/abilities/wimp-out.test.ts @@ -547,7 +547,7 @@ describe("Abilities - Wimp Out", () => { await game.move.selectEnemyMove(MoveId.SPLASH); await game.move.selectEnemyMove(MoveId.ENDURE); - await game.phaseInterceptor.to("SelectModifierPhase"); + await game.toNextWave(); expect(game.scene.currentBattle.waveIndex).toBe(wave + 1); }); }); diff --git a/test/battle/battle-order.test.ts b/test/battle/battle-order.test.ts index 47afb582a5a..5939830e044 100644 --- a/test/battle/battle-order.test.ts +++ b/test/battle/battle-order.test.ts @@ -1,9 +1,7 @@ import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; -import { EnemyCommandPhase } from "#phases/enemy-command-phase"; -import { SelectTargetPhase } from "#phases/select-target-phase"; -import { TurnStartPhase } from "#phases/turn-start-phase"; +import type { TurnStartPhase } from "#phases/turn-start-phase"; import { GameManager } from "#test/test-utils/game-manager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; @@ -41,7 +39,7 @@ describe("Battle order", () => { vi.spyOn(enemyPokemon, "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 150]); // set enemyPokemon's speed to 150 game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.run(EnemyCommandPhase); + await game.phaseInterceptor.to("TurnStartPhase"); const playerPokemonIndex = playerPokemon.getBattlerIndex(); const enemyPokemonIndex = enemyPokemon.getBattlerIndex(); @@ -60,7 +58,7 @@ describe("Battle order", () => { vi.spyOn(enemyPokemon, "stats", "get").mockReturnValue([20, 20, 20, 20, 20, 50]); // set enemyPokemon's speed to 50 game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.run(EnemyCommandPhase); + await game.phaseInterceptor.to("TurnStartPhase"); const playerPokemonIndex = playerPokemon.getBattlerIndex(); const enemyPokemonIndex = enemyPokemon.getBattlerIndex(); @@ -84,7 +82,7 @@ describe("Battle order", () => { game.move.select(MoveId.TACKLE); game.move.select(MoveId.TACKLE, 1); - await game.phaseInterceptor.runFrom(SelectTargetPhase).to(TurnStartPhase, false); + await game.phaseInterceptor.to("TurnStartPhase", false); const phase = game.scene.phaseManager.getCurrentPhase() as TurnStartPhase; const order = phase.getCommandOrder(); @@ -108,7 +106,7 @@ describe("Battle order", () => { game.move.select(MoveId.TACKLE); game.move.select(MoveId.TACKLE, 1); - await game.phaseInterceptor.runFrom(SelectTargetPhase).to(TurnStartPhase, false); + await game.phaseInterceptor.to("TurnStartPhase", false); const phase = game.scene.phaseManager.getCurrentPhase() as TurnStartPhase; const order = phase.getCommandOrder(); @@ -132,7 +130,7 @@ describe("Battle order", () => { game.move.select(MoveId.TACKLE); game.move.select(MoveId.TACKLE, 1); - await game.phaseInterceptor.runFrom(SelectTargetPhase).to(TurnStartPhase, false); + await game.phaseInterceptor.to("TurnStartPhase", false); const phase = game.scene.phaseManager.getCurrentPhase() as TurnStartPhase; const order = phase.getCommandOrder(); diff --git a/test/battle/battle.test.ts b/test/battle/battle.test.ts index ff5090e5f8d..7c97ea57e0d 100644 --- a/test/battle/battle.test.ts +++ b/test/battle/battle.test.ts @@ -1,28 +1,13 @@ -import { getGameMode } from "#app/game-mode"; import { allSpecies } from "#data/data-lists"; import { AbilityId } from "#enums/ability-id"; import { BiomeId } from "#enums/biome-id"; -import { GameModes } from "#enums/game-modes"; import { MoveId } from "#enums/move-id"; -import { PlayerGender } from "#enums/player-gender"; import { SpeciesId } from "#enums/species-id"; import { Stat } from "#enums/stat"; import { UiMode } from "#enums/ui-mode"; -import { BattleEndPhase } from "#phases/battle-end-phase"; import { CommandPhase } from "#phases/command-phase"; -import { DamageAnimPhase } from "#phases/damage-anim-phase"; -import { EncounterPhase } from "#phases/encounter-phase"; -import { EnemyCommandPhase } from "#phases/enemy-command-phase"; -import { LoginPhase } from "#phases/login-phase"; import { NextEncounterPhase } from "#phases/next-encounter-phase"; -import { SelectGenderPhase } from "#phases/select-gender-phase"; -import { SelectStarterPhase } from "#phases/select-starter-phase"; -import { SummonPhase } from "#phases/summon-phase"; -import { SwitchPhase } from "#phases/switch-phase"; -import { TitlePhase } from "#phases/title-phase"; -import { TurnInitPhase } from "#phases/turn-init-phase"; import { GameManager } from "#test/test-utils/game-manager"; -import { generateStarter } from "#test/test-utils/game-manager-utils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; @@ -45,55 +30,11 @@ describe("Phase - Battle Phase", () => { game.scene.gameData.gender = undefined!; // just for these tests! }); - it("test phase interceptor with prompt", async () => { - await game.phaseInterceptor.run(LoginPhase); - - game.onNextPrompt("SelectGenderPhase", UiMode.OPTION_SELECT, () => { - game.scene.gameData.gender = PlayerGender.MALE; - game.endPhase(); - }); - - await game.phaseInterceptor.run(SelectGenderPhase); - - await game.phaseInterceptor.run(TitlePhase); - await game.waitMode(UiMode.TITLE); - - expect(game.scene.ui?.getMode()).toBe(UiMode.TITLE); - expect(game.scene.gameData.gender).toBe(PlayerGender.MALE); - }); - - it("test phase interceptor with prompt with preparation for a future prompt", async () => { - await game.phaseInterceptor.run(LoginPhase); - - game.onNextPrompt("SelectGenderPhase", UiMode.OPTION_SELECT, () => { - game.scene.gameData.gender = PlayerGender.MALE; - game.endPhase(); - }); - - game.onNextPrompt("CheckSwitchPhase", UiMode.CONFIRM, () => { - game.setMode(UiMode.MESSAGE); - game.endPhase(); - }); - await game.phaseInterceptor.run(SelectGenderPhase); - - await game.phaseInterceptor.run(TitlePhase); - await game.waitMode(UiMode.TITLE); - - expect(game.scene.ui?.getMode()).toBe(UiMode.TITLE); - expect(game.scene.gameData.gender).toBe(PlayerGender.MALE); - }); - - it("newGame one-liner", async () => { - await game.classicMode.startBattle(); - expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND); - expect(game.scene.phaseManager.getCurrentPhase()?.phaseName).toBe("CommandPhase"); - }); - it("do attack wave 3 - single battle - regular - OHKO", async () => { game.override.enemySpecies(SpeciesId.RATTATA).startingLevel(2000).battleStyle("single").startingWave(3); await game.classicMode.startBattle([SpeciesId.MEWTWO]); game.move.use(MoveId.TACKLE); - await game.phaseInterceptor.to("SelectModifierPhase"); + await game.toNextWave(); }); it("do attack wave 3 - single battle - regular - NO OHKO with opponent using non damage attack", async () => { @@ -107,7 +48,7 @@ describe("Phase - Battle Phase", () => { .battleStyle("single"); await game.classicMode.startBattle([SpeciesId.MEWTWO]); game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnInitPhase, false); + await game.phaseInterceptor.to("TurnInitPhase", false); }); it("load 100% data file", async () => { @@ -135,68 +76,6 @@ describe("Phase - Battle Phase", () => { } }); - it("wrong phase", async () => { - await game.phaseInterceptor.run(LoginPhase); - await game.phaseInterceptor.run(LoginPhase).catch(e => { - expect(e).toBe("Wrong phase: this is SelectGenderPhase and not LoginPhase"); - }); - }); - - it("wrong phase but skip", async () => { - await game.phaseInterceptor.run(LoginPhase); - await game.phaseInterceptor.run(LoginPhase, () => game.isCurrentPhase(SelectGenderPhase)); - }); - - it("good run", async () => { - await game.phaseInterceptor.run(LoginPhase); - game.onNextPrompt( - "SelectGenderPhase", - UiMode.OPTION_SELECT, - () => { - game.scene.gameData.gender = PlayerGender.MALE; - game.endPhase(); - }, - () => game.isCurrentPhase(TitlePhase), - ); - await game.phaseInterceptor.run(SelectGenderPhase, () => game.isCurrentPhase(TitlePhase)); - await game.phaseInterceptor.run(TitlePhase); - }); - - it("good run from select gender to title", async () => { - await game.phaseInterceptor.run(LoginPhase); - game.onNextPrompt( - "SelectGenderPhase", - UiMode.OPTION_SELECT, - () => { - game.scene.gameData.gender = PlayerGender.MALE; - game.endPhase(); - }, - () => game.isCurrentPhase(TitlePhase), - ); - await game.phaseInterceptor.runFrom(SelectGenderPhase).to(TitlePhase); - }); - - it("good run to SummonPhase phase", async () => { - await game.phaseInterceptor.run(LoginPhase); - game.onNextPrompt( - "SelectGenderPhase", - UiMode.OPTION_SELECT, - () => { - game.scene.gameData.gender = PlayerGender.MALE; - game.endPhase(); - }, - () => game.isCurrentPhase(TitlePhase), - ); - game.onNextPrompt("TitlePhase", UiMode.TITLE, () => { - game.scene.gameMode = getGameMode(GameModes.CLASSIC); - const starters = generateStarter(game.scene); - const selectStarterPhase = new SelectStarterPhase(); - game.scene.phaseManager.pushPhase(new EncounterPhase(false)); - selectStarterPhase.initBattle(starters); - }); - await game.phaseInterceptor.runFrom(SelectGenderPhase).to(SummonPhase); - }); - it.each([ { name: "1v1", double: false, qty: 1 }, { name: "2v1", double: false, qty: 2 }, @@ -232,7 +111,7 @@ describe("Phase - Battle Phase", () => { await game.classicMode.startBattle([SpeciesId.DARMANITAN, SpeciesId.CHARIZARD]); game.move.select(moveToUse); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); await game.killPokemon(game.scene.currentBattle.enemyParty[0]); expect(game.scene.currentBattle.enemyParty[0].isFainted()).toBe(true); await game.phaseInterceptor.to("VictoryPhase"); @@ -296,7 +175,7 @@ describe("Phase - Battle Phase", () => { game.scene.getPlayerPokemon()!.hp = 1; game.move.select(moveToUse); - await game.phaseInterceptor.to(BattleEndPhase); + await game.phaseInterceptor.to("BattleEndPhase"); game.doRevivePokemon(0); // pretend max revive was picked game.doSelectModifier(); @@ -308,6 +187,6 @@ describe("Phase - Battle Phase", () => { }, () => game.isCurrentPhase(NextEncounterPhase), ); - await game.phaseInterceptor.to(SwitchPhase); + await game.phaseInterceptor.to("SwitchPhase"); }); }); diff --git a/test/items/lock-capsule.test.ts b/test/items/lock-capsule.test.ts index 01552a4db37..71eb9b86960 100644 --- a/test/items/lock-capsule.test.ts +++ b/test/items/lock-capsule.test.ts @@ -1,8 +1,7 @@ import { AbilityId } from "#enums/ability-id"; import { ModifierTier } from "#enums/modifier-tier"; import { MoveId } from "#enums/move-id"; -import { UiMode } from "#enums/ui-mode"; -import { SelectModifierPhase } from "#phases/select-modifier-phase"; +import type { SelectModifierPhase } from "#phases/select-modifier-phase"; import { GameManager } from "#test/test-utils/game-manager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; @@ -34,20 +33,17 @@ describe("Items - Lock Capsule", () => { it("doesn't set the cost of common tier items to 0", async () => { await game.classicMode.startBattle(); - game.scene.phaseManager.overridePhase( - new SelectModifierPhase(0, undefined, { - guaranteedModifierTiers: [ModifierTier.COMMON, ModifierTier.COMMON, ModifierTier.COMMON], - fillRemaining: false, - }), - ); - - game.onNextPrompt("SelectModifierPhase", UiMode.MODIFIER_SELECT, () => { - const selectModifierPhase = game.scene.phaseManager.getCurrentPhase() as SelectModifierPhase; - const rerollCost = selectModifierPhase.getRerollCost(true); - expect(rerollCost).toBe(150); + game.scene.phaseManager.clearAllPhases(); + game.scene.phaseManager.unshiftNew("SelectModifierPhase", 0, undefined, { + guaranteedModifierTiers: [ModifierTier.COMMON, ModifierTier.COMMON, ModifierTier.COMMON], + fillRemaining: false, }); game.doSelectModifier(); await game.phaseInterceptor.to("SelectModifierPhase"); + + const selectModifierPhase = game.scene.phaseManager.getCurrentPhase() as SelectModifierPhase; + const rerollCost = selectModifierPhase.getRerollCost(true); + expect(rerollCost).toBe(150); }); }); diff --git a/test/items/temp-stat-stage-booster.test.ts b/test/items/temp-stat-stage-booster.test.ts index 806ff20df6c..38680a4bb9c 100644 --- a/test/items/temp-stat-stage-booster.test.ts +++ b/test/items/temp-stat-stage-booster.test.ts @@ -6,7 +6,6 @@ import { SpeciesId } from "#enums/species-id"; import { BATTLE_STATS, Stat } from "#enums/stat"; import { UiMode } from "#enums/ui-mode"; import { TempStatStageBoosterModifier } from "#modifiers/modifier"; -import { TurnEndPhase } from "#phases/turn-end-phase"; import { GameManager } from "#test/test-utils/game-manager"; import type { ModifierSelectUiHandler } from "#ui/modifier-select-ui-handler"; import Phaser from "phaser"; @@ -47,7 +46,7 @@ describe("Items - Temporary Stat Stage Boosters", () => { game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.runFrom("EnemyCommandPhase").to(TurnEndPhase); + await game.toEndOfTurn(); expect(partyMember.getStatStageMultiplier).toHaveReturnedWith(1.3); }); @@ -64,11 +63,11 @@ describe("Items - Temporary Stat Stage Boosters", () => { // Raise ACC by +2 stat stages game.move.select(MoveId.HONE_CLAWS); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); // ACC at +3 stat stages yields a x2 multiplier expect(partyMember.getAccuracyMultiplier).toHaveReturnedWith(2); @@ -84,11 +83,11 @@ describe("Items - Temporary Stat Stage Boosters", () => { // Raise ATK by +1 stat stage game.move.select(MoveId.HONE_CLAWS); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); // ATK at +1 stat stage yields a x1.5 multiplier, add 0.3 from X_ATTACK expect(partyMember.getStatStageMultiplier).toHaveReturnedWith(1.8); @@ -112,7 +111,7 @@ describe("Items - Temporary Stat Stage Boosters", () => { game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(partyMember.getAccuracyMultiplier).toHaveReturnedWith(3); expect(partyMember.getStatStageMultiplier).toHaveReturnedWith(4); diff --git a/test/misc.test.ts b/test/misc.test.ts index 96407b78470..25691e7b211 100644 --- a/test/misc.test.ts +++ b/test/misc.test.ts @@ -1,5 +1,4 @@ import { GameManager } from "#test/test-utils/game-manager"; -import { waitUntil } from "#test/test-utils/game-manager-utils"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; @@ -62,19 +61,4 @@ describe("Test misc", () => { const data = await game.scene.cachedFetch("./battle-anims/splishy-splash.json"); expect(data).toBeDefined(); }); - - it("testing wait phase queue", async () => { - const fakeScene = { - phaseQueue: [1, 2, 3], // Initially not empty - }; - setTimeout(() => { - fakeScene.phaseQueue = []; - }, 500); - const spy = vi.fn(); - await waitUntil(() => fakeScene.phaseQueue.length === 0).then(result => { - expect(result).toBe(true); - spy(); // Call the spy function - }); - expect(spy).toHaveBeenCalled(); - }); }); diff --git a/test/moves/fusion-flare-bolt.test.ts b/test/moves/fusion-flare-bolt.test.ts index 42cc1248325..f5d556bde48 100644 --- a/test/moves/fusion-flare-bolt.test.ts +++ b/test/moves/fusion-flare-bolt.test.ts @@ -4,10 +4,7 @@ import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import { Stat } from "#enums/stat"; import type { Move } from "#moves/move"; -import { DamageAnimPhase } from "#phases/damage-anim-phase"; -import { MoveEffectPhase } from "#phases/move-effect-phase"; -import { MoveEndPhase } from "#phases/move-end-phase"; -import { MovePhase } from "#phases/move-phase"; +import type { MoveEffectPhase } from "#phases/move-effect-phase"; import { GameManager } from "#test/test-utils/game-manager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; @@ -55,14 +52,14 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { // Force user party to act before enemy party await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(100); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(200); }); @@ -75,14 +72,14 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { // Force user party to act before enemy party await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(100); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200); }); @@ -95,19 +92,19 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { // Force first enemy to act (and fail) in between party await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(100); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); // Skip enemy move; because the enemy is at full HP, Rest should fail - await game.phaseInterceptor.runFrom(MovePhase).to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(200); }); @@ -121,18 +118,18 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { // Force first enemy to act in between party await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(100); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); // Skip enemy move - await game.phaseInterceptor.runFrom(MovePhase).to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(100); }); @@ -145,14 +142,14 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { // Force user party to act before enemy party await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(100); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200); }); @@ -189,24 +186,24 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { // Force first enemy to act in between party await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(100); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(200); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200); }); @@ -243,24 +240,24 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => { // Force first enemy to act in between party await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(100); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionBolt.id); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(fusionBolt.calculateBattlePower).toHaveLastReturnedWith(200); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(fusionFlare.id); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200); }); }); diff --git a/test/moves/growth.test.ts b/test/moves/growth.test.ts index 5737f32d891..328a4cf87e2 100644 --- a/test/moves/growth.test.ts +++ b/test/moves/growth.test.ts @@ -2,8 +2,6 @@ import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import { Stat } from "#enums/stat"; -import { EnemyCommandPhase } from "#phases/enemy-command-phase"; -import { TurnInitPhase } from "#phases/turn-init-phase"; import { GameManager } from "#test/test-utils/game-manager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; @@ -40,7 +38,7 @@ describe("Moves - Growth", () => { expect(playerPokemon.getStatStage(Stat.SPATK)).toBe(0); game.move.select(MoveId.GROWTH); - await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnInitPhase); + await game.toEndOfTurn(); expect(playerPokemon.getStatStage(Stat.SPATK)).toBe(1); }); diff --git a/test/moves/metronome.test.ts b/test/moves/metronome.test.ts index e39d24c81db..b88206f23d9 100644 --- a/test/moves/metronome.test.ts +++ b/test/moves/metronome.test.ts @@ -146,6 +146,6 @@ describe("Moves - Metronome", () => { const hasFled = enemyPokemon.switchOutStatus; expect(!isVisible && hasFled).toBe(true); - await game.toNextTurn(); + await game.toNextWave(); }); }); diff --git a/test/moves/parting-shot.test.ts b/test/moves/parting-shot.test.ts index 7785bdd3a2f..2797f3c1113 100644 --- a/test/moves/parting-shot.test.ts +++ b/test/moves/parting-shot.test.ts @@ -2,10 +2,6 @@ import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import { Stat } from "#enums/stat"; -import { BerryPhase } from "#phases/berry-phase"; -import { FaintPhase } from "#phases/faint-phase"; -import { MessagePhase } from "#phases/message-phase"; -import { TurnInitPhase } from "#phases/turn-init-phase"; import { GameManager } from "#test/test-utils/game-manager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, test } from "vitest"; @@ -43,7 +39,7 @@ describe("Moves - Parting Shot", () => { game.move.select(MoveId.PARTING_SHOT); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0); expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(0); expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MURKROW); @@ -58,7 +54,7 @@ describe("Moves - Parting Shot", () => { game.move.select(MoveId.PARTING_SHOT); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0); expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(0); expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MURKROW); @@ -79,24 +75,24 @@ describe("Moves - Parting Shot", () => { // use Memento 3 times to debuff enemy game.move.select(MoveId.MEMENTO); - await game.phaseInterceptor.to(FaintPhase); + await game.phaseInterceptor.to("FaintPhase"); expect(game.scene.getPlayerParty()[0].isFainted()).toBe(true); game.doSelectPartyPokemon(1); - await game.phaseInterceptor.to(TurnInitPhase, false); + await game.phaseInterceptor.to("TurnInitPhase", false); game.move.select(MoveId.MEMENTO); - await game.phaseInterceptor.to(FaintPhase); + await game.phaseInterceptor.to("FaintPhase"); expect(game.scene.getPlayerParty()[0].isFainted()).toBe(true); game.doSelectPartyPokemon(2); - await game.phaseInterceptor.to(TurnInitPhase, false); + await game.phaseInterceptor.to("TurnInitPhase", false); game.move.select(MoveId.MEMENTO); - await game.phaseInterceptor.to(FaintPhase); + await game.phaseInterceptor.to("FaintPhase"); expect(game.scene.getPlayerParty()[0].isFainted()).toBe(true); game.doSelectPartyPokemon(3); // set up done - await game.phaseInterceptor.to(TurnInitPhase, false); + await game.phaseInterceptor.to("TurnInitPhase", false); const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon).toBeDefined(); @@ -106,7 +102,7 @@ describe("Moves - Parting Shot", () => { // now parting shot should fail game.move.select(MoveId.PARTING_SHOT); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(-6); expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(-6); expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MURKROW); @@ -125,7 +121,7 @@ describe("Moves - Parting Shot", () => { game.move.select(MoveId.PARTING_SHOT); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0); expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(0); expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MURKROW); @@ -144,7 +140,7 @@ describe("Moves - Parting Shot", () => { game.move.select(MoveId.PARTING_SHOT); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0); expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(0); expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MURKROW); @@ -153,43 +149,24 @@ describe("Moves - Parting Shot", () => { it.todo( // TODO: fix this bug to pass the test! - "Parting shot should de-buff and not fail if no party available to switch - party size 1", - async () => { - await game.classicMode.startBattle([SpeciesId.MURKROW]); - - const enemyPokemon = game.scene.getEnemyPokemon()!; - expect(enemyPokemon).toBeDefined(); - - game.move.select(MoveId.PARTING_SHOT); - - await game.phaseInterceptor.to(BerryPhase, false); - expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(-1); - expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(-1); - expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MURKROW); - }, - ); - - it.todo( - // TODO: fix this bug to pass the test! - "Parting shot regularly not fail if no party available to switch - party fainted", + "should lower stats without failing if no alive party members available to switch", async () => { await game.classicMode.startBattle([SpeciesId.MURKROW, SpeciesId.MEOWTH]); + + const meowth = game.scene.getPlayerParty()[1]; + meowth.hp = 0; + game.move.select(MoveId.SPLASH); + await game.toNextTurn(); - // intentionally kill party pokemon, switch to second slot (now 1 party mon is fainted) - await game.killPokemon(game.scene.getPlayerParty()[0]); - expect(game.scene.getPlayerParty()[0].isFainted()).toBe(true); - await game.phaseInterceptor.run(MessagePhase); - game.doSelectPartyPokemon(1); - - await game.phaseInterceptor.to(TurnInitPhase, false); game.move.select(MoveId.PARTING_SHOT); + game.doSelectPartyPokemon(1); + await game.toEndOfTurn(); - await game.phaseInterceptor.to(BerryPhase, false); - const enemyPokemon = game.scene.getEnemyPokemon()!; + const enemyPokemon = game.field.getEnemyPokemon(); expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0); expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(0); - expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MEOWTH); + expect(game.field.getPlayerPokemon().species.speciesId).toBe(SpeciesId.MURKROW); }, ); }); diff --git a/test/moves/tackle.test.ts b/test/moves/tackle.test.ts index 23abd650e55..9bd15cbafa9 100644 --- a/test/moves/tackle.test.ts +++ b/test/moves/tackle.test.ts @@ -1,8 +1,6 @@ import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import { Stat } from "#enums/stat"; -import { EnemyCommandPhase } from "#phases/enemy-command-phase"; -import { TurnEndPhase } from "#phases/turn-end-phase"; import { GameManager } from "#test/test-utils/game-manager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; @@ -41,7 +39,7 @@ describe("Moves - Tackle", () => { await game.classicMode.startBattle([SpeciesId.MIGHTYENA]); const hpOpponent = game.scene.currentBattle.enemyParty[0].hp; game.move.select(moveToUse); - await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnEndPhase); + await game.toEndOfTurn(); const hpLost = hpOpponent - game.scene.currentBattle.enemyParty[0].hp; expect(hpLost).toBe(0); }); @@ -55,7 +53,7 @@ describe("Moves - Tackle", () => { const hpOpponent = game.scene.currentBattle.enemyParty[0].hp; game.move.select(moveToUse); - await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnEndPhase); + await game.toEndOfTurn(); const hpLost = hpOpponent - game.scene.currentBattle.enemyParty[0].hp; expect(hpLost).toBeGreaterThan(0); expect(hpLost).toBeLessThan(4); diff --git a/test/moves/tail-whip.test.ts b/test/moves/tail-whip.test.ts index c872b2535e3..62eb657adbd 100644 --- a/test/moves/tail-whip.test.ts +++ b/test/moves/tail-whip.test.ts @@ -2,8 +2,6 @@ import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import { Stat } from "#enums/stat"; -import { EnemyCommandPhase } from "#phases/enemy-command-phase"; -import { TurnInitPhase } from "#phases/turn-init-phase"; import { GameManager } from "#test/test-utils/game-manager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; @@ -43,7 +41,7 @@ describe("Moves - Tail whip", () => { expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(0); game.move.select(moveToUse); - await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnInitPhase); + await game.toEndOfTurn(); expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(-1); }); diff --git a/test/mystery-encounter/encounter-test-utils.ts b/test/mystery-encounter/encounter-test-utils.ts index 784e8ae4950..22fd86cf28a 100644 --- a/test/mystery-encounter/encounter-test-utils.ts +++ b/test/mystery-encounter/encounter-test-utils.ts @@ -9,7 +9,6 @@ import { MessagePhase } from "#phases/message-phase"; import { MysteryEncounterBattlePhase, MysteryEncounterOptionSelectedPhase, - MysteryEncounterPhase, MysteryEncounterRewardsPhase, } from "#phases/mystery-encounter-phases"; import { VictoryPhase } from "#phases/victory-phase"; @@ -89,9 +88,9 @@ export async function runMysteryEncounterToEnd( uiHandler.processInput(Button.ACTION); }); - await game.phaseInterceptor.to(CommandPhase); + await game.toNextTurn(); } else { - await game.phaseInterceptor.to(MysteryEncounterRewardsPhase); + await game.phaseInterceptor.to("MysteryEncounterRewardsPhase"); } } @@ -112,7 +111,7 @@ export async function runSelectMysteryEncounterOption( ); if (game.isCurrentPhase(MessagePhase)) { - await game.phaseInterceptor.run(MessagePhase); + await game.phaseInterceptor.to("MessagePhase"); } // dispose of intro messages @@ -126,7 +125,7 @@ export async function runSelectMysteryEncounterOption( () => game.isCurrentPhase(MysteryEncounterOptionSelectedPhase), ); - await game.phaseInterceptor.to(MysteryEncounterPhase, true); + await game.phaseInterceptor.to("MysteryEncounterPhase", true); // select the desired option const uiHandler = game.scene.ui.getHandler(); @@ -205,7 +204,7 @@ export async function skipBattleRunMysteryEncounterRewardsPhase(game: GameManage game.scene.field.remove(p); }); game.scene.phaseManager.pushPhase(new VictoryPhase(0)); - game.phaseInterceptor.superEndPhase(); + game.phaseInterceptor.shiftPhase(); game.setMode(UiMode.MESSAGE); - await game.phaseInterceptor.to(MysteryEncounterRewardsPhase, runRewardsPhase); + await game.phaseInterceptor.to("MysteryEncounterRewardsPhase", runRewardsPhase); } diff --git a/test/mystery-encounter/encounters/berries-abound-encounter.test.ts b/test/mystery-encounter/encounters/berries-abound-encounter.test.ts index 3d29c04cab7..f8afde2722d 100644 --- a/test/mystery-encounter/encounters/berries-abound-encounter.test.ts +++ b/test/mystery-encounter/encounters/berries-abound-encounter.test.ts @@ -134,7 +134,7 @@ describe("Berries Abound - Mystery Encounter", () => { await runMysteryEncounterToEnd(game, 1, undefined, true); await skipBattleRunMysteryEncounterRewardsPhase(game); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); const berriesAfter = scene.findModifiers(m => m instanceof BerryModifier) as BerryModifier[]; @@ -147,9 +147,7 @@ describe("Berries Abound - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.BERRIES_ABOUND, defaultParty); await runMysteryEncounterToEnd(game, 1, undefined, true); await skipBattleRunMysteryEncounterRewardsPhase(game); - await game.phaseInterceptor.to(SelectModifierPhase, false); - expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( @@ -232,9 +230,9 @@ describe("Berries Abound - Mystery Encounter", () => { }); await runMysteryEncounterToEnd(game, 2); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( diff --git a/test/mystery-encounter/encounters/bug-type-superfan-encounter.test.ts b/test/mystery-encounter/encounters/bug-type-superfan-encounter.test.ts index 205bf996815..1339ee7d69d 100644 --- a/test/mystery-encounter/encounters/bug-type-superfan-encounter.test.ts +++ b/test/mystery-encounter/encounters/bug-type-superfan-encounter.test.ts @@ -368,9 +368,9 @@ describe("Bug-Type Superfan - Mystery Encounter", () => { expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterRewardsPhase.name); game.phaseInterceptor["prompts"] = []; // Clear out prompt handlers game.onNextPrompt("MysteryEncounterRewardsPhase", UiMode.OPTION_SELECT, () => { - game.phaseInterceptor.superEndPhase(); + game.phaseInterceptor.shiftPhase(); }); - await game.phaseInterceptor.run(MysteryEncounterRewardsPhase); + await game.phaseInterceptor.to("MysteryEncounterRewardsPhase"); expect(selectOptionSpy).toHaveBeenCalledTimes(1); const optionData = selectOptionSpy.mock.calls[0][0]; @@ -395,7 +395,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => { it("should NOT be selectable if the player doesn't have any Bug types", async () => { await game.runToMysteryEncounter(MysteryEncounterType.BUG_TYPE_SUPERFAN, [SpeciesId.ABRA]); - await game.phaseInterceptor.to(MysteryEncounterPhase, false); + await game.phaseInterceptor.to("MysteryEncounterPhase", false); const encounterPhase = scene.phaseManager.getCurrentPhase(); expect(encounterPhase?.constructor.name).toBe(MysteryEncounterPhase.name); @@ -417,7 +417,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => { await runMysteryEncounterToEnd(game, 2); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( @@ -436,7 +436,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => { await runMysteryEncounterToEnd(game, 2); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( @@ -458,7 +458,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => { await runMysteryEncounterToEnd(game, 2); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( @@ -482,7 +482,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => { await runMysteryEncounterToEnd(game, 2); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( @@ -530,7 +530,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => { it("should NOT be selectable if the player doesn't have any Bug items", async () => { game.scene.modifiers = []; await game.runToMysteryEncounter(MysteryEncounterType.BUG_TYPE_SUPERFAN, defaultParty); - await game.phaseInterceptor.to(MysteryEncounterPhase, false); + await game.phaseInterceptor.to("MysteryEncounterPhase", false); game.scene.modifiers = []; const encounterPhase = scene.phaseManager.getCurrentPhase(); @@ -558,7 +558,7 @@ describe("Bug-Type Superfan - Mystery Encounter", () => { await runMysteryEncounterToEnd(game, 3, { pokemonNo: 1, optionNo: 1 }); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( diff --git a/test/mystery-encounter/encounters/clowning-around-encounter.test.ts b/test/mystery-encounter/encounters/clowning-around-encounter.test.ts index b573701d568..7fa96e6164a 100644 --- a/test/mystery-encounter/encounters/clowning-around-encounter.test.ts +++ b/test/mystery-encounter/encounters/clowning-around-encounter.test.ts @@ -25,7 +25,6 @@ import * as MysteryEncounters from "#mystery-encounters/mystery-encounters"; import { CommandPhase } from "#phases/command-phase"; import { MovePhase } from "#phases/move-phase"; import { PostMysteryEncounterPhase } from "#phases/mystery-encounter-phases"; -import { NewBattlePhase } from "#phases/new-battle-phase"; import { SelectModifierPhase } from "#phases/select-modifier-phase"; import { runMysteryEncounterToEnd, @@ -200,9 +199,9 @@ describe("Clowning Around - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.CLOWNING_AROUND, defaultParty); await runMysteryEncounterToEnd(game, 1, undefined, true); await skipBattleRunMysteryEncounterRewardsPhase(game); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); const abilityToTrain = scene.currentBattle.mysteryEncounter?.misc.ability; game.onNextPrompt("PostMysteryEncounterPhase", UiMode.MESSAGE, () => { @@ -215,7 +214,7 @@ describe("Clowning Around - Mystery Encounter", () => { const partyUiHandler = game.scene.ui.handlers[UiMode.PARTY] as PartyUiHandler; vi.spyOn(partyUiHandler, "show"); game.endPhase(); - await game.phaseInterceptor.to(PostMysteryEncounterPhase); + await game.phaseInterceptor.to("PostMysteryEncounterPhase"); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(PostMysteryEncounterPhase.name); // Wait for Yes/No confirmation to appear @@ -228,7 +227,7 @@ describe("Clowning Around - Mystery Encounter", () => { // Click "Select" on Pokemon partyUiHandler.processInput(Button.ACTION); // Stop next battle before it runs - await game.phaseInterceptor.to(NewBattlePhase, false); + await game.phaseInterceptor.to("NewBattlePhase", false); const leadPokemon = scene.getPlayerParty()[0]; expect(leadPokemon.customPokemonData?.ability).toBe(abilityToTrain); diff --git a/test/mystery-encounter/encounters/dancing-lessons-encounter.test.ts b/test/mystery-encounter/encounters/dancing-lessons-encounter.test.ts index 97d0ce31367..9624f297d51 100644 --- a/test/mystery-encounter/encounters/dancing-lessons-encounter.test.ts +++ b/test/mystery-encounter/encounters/dancing-lessons-encounter.test.ts @@ -126,9 +126,9 @@ describe("Dancing Lessons - Mystery Encounter", () => { partyLead.calculateStats(); await runMysteryEncounterToEnd(game, 1, undefined, true); await skipBattleRunMysteryEncounterRewardsPhase(game); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( @@ -215,7 +215,7 @@ describe("Dancing Lessons - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.DANCING_LESSONS, defaultParty); const partyCountBefore = scene.getPlayerParty().length; scene.getPlayerParty().forEach(p => (p.moveset = [])); - await game.phaseInterceptor.to(MysteryEncounterPhase, false); + await game.phaseInterceptor.to("MysteryEncounterPhase", false); const encounterPhase = scene.phaseManager.getCurrentPhase(); expect(encounterPhase?.constructor.name).toBe(MysteryEncounterPhase.name); diff --git a/test/mystery-encounter/encounters/department-store-sale-encounter.test.ts b/test/mystery-encounter/encounters/department-store-sale-encounter.test.ts index 3d84d70b47e..785e7597354 100644 --- a/test/mystery-encounter/encounters/department-store-sale-encounter.test.ts +++ b/test/mystery-encounter/encounters/department-store-sale-encounter.test.ts @@ -94,7 +94,7 @@ describe("Department Store Sale - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.DEPARTMENT_STORE_SALE, defaultParty); await runMysteryEncounterToEnd(game, 1); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( @@ -131,7 +131,7 @@ describe("Department Store Sale - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.DEPARTMENT_STORE_SALE, defaultParty); await runMysteryEncounterToEnd(game, 2); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( @@ -171,7 +171,7 @@ describe("Department Store Sale - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.DEPARTMENT_STORE_SALE, defaultParty); await runMysteryEncounterToEnd(game, 3); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( @@ -211,7 +211,7 @@ describe("Department Store Sale - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.DEPARTMENT_STORE_SALE, defaultParty); await runMysteryEncounterToEnd(game, 4); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( diff --git a/test/mystery-encounter/encounters/fight-or-flight-encounter.test.ts b/test/mystery-encounter/encounters/fight-or-flight-encounter.test.ts index 8149212f00f..7d8892393ba 100644 --- a/test/mystery-encounter/encounters/fight-or-flight-encounter.test.ts +++ b/test/mystery-encounter/encounters/fight-or-flight-encounter.test.ts @@ -122,9 +122,9 @@ describe("Fight or Flight - Mystery Encounter", () => { await runMysteryEncounterToEnd(game, 1, undefined, true); await skipBattleRunMysteryEncounterRewardsPhase(game); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( @@ -155,7 +155,7 @@ describe("Fight or Flight - Mystery Encounter", () => { it("should NOT be selectable if the player doesn't have a Stealing move", async () => { await game.runToMysteryEncounter(MysteryEncounterType.FIGHT_OR_FLIGHT, defaultParty); scene.getPlayerParty().forEach(p => (p.moveset = [])); - await game.phaseInterceptor.to(MysteryEncounterPhase, false); + await game.phaseInterceptor.to("MysteryEncounterPhase", false); const encounterPhase = scene.phaseManager.getCurrentPhase(); expect(encounterPhase?.constructor.name).toBe(MysteryEncounterPhase.name); @@ -182,9 +182,9 @@ describe("Fight or Flight - Mystery Encounter", () => { const item = game.scene.currentBattle.mysteryEncounter!.misc; await runMysteryEncounterToEnd(game, 2); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( diff --git a/test/mystery-encounter/encounters/fun-and-games-encounter.test.ts b/test/mystery-encounter/encounters/fun-and-games-encounter.test.ts index b66d0e95ad0..d199ad4e457 100644 --- a/test/mystery-encounter/encounters/fun-and-games-encounter.test.ts +++ b/test/mystery-encounter/encounters/fun-and-games-encounter.test.ts @@ -120,7 +120,7 @@ describe("Fun And Games! - Mystery Encounter", () => { it("should NOT be selectable if the player doesn't have enough money", async () => { game.scene.money = 0; await game.runToMysteryEncounter(MysteryEncounterType.FUN_AND_GAMES, defaultParty); - await game.phaseInterceptor.to(MysteryEncounterPhase, false); + await game.phaseInterceptor.to("MysteryEncounterPhase", false); const encounterPhase = scene.phaseManager.getCurrentPhase(); expect(encounterPhase?.constructor.name).toBe(MysteryEncounterPhase.name); @@ -162,7 +162,7 @@ describe("Fun And Games! - Mystery Encounter", () => { // Turn 3 (game.scene.phaseManager.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, 0, MoveUseMode.NORMAL); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); // Rewards expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); @@ -181,11 +181,11 @@ describe("Fun And Games! - Mystery Encounter", () => { // Skip minigame scene.currentBattle.mysteryEncounter!.misc.turnsRemaining = 0; (game.scene.phaseManager.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, 0, MoveUseMode.NORMAL); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); // Rewards expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( @@ -210,11 +210,11 @@ describe("Fun And Games! - Mystery Encounter", () => { wobbuffet.hp = Math.floor(0.2 * wobbuffet.getMaxHp()); scene.currentBattle.mysteryEncounter!.misc.turnsRemaining = 0; (game.scene.phaseManager.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, 0, MoveUseMode.NORMAL); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); // Rewards expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( @@ -240,11 +240,11 @@ describe("Fun And Games! - Mystery Encounter", () => { wobbuffet.hp = Math.floor(0.1 * wobbuffet.getMaxHp()); scene.currentBattle.mysteryEncounter!.misc.turnsRemaining = 0; (game.scene.phaseManager.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, 0, MoveUseMode.NORMAL); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); // Rewards expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( @@ -270,11 +270,11 @@ describe("Fun And Games! - Mystery Encounter", () => { wobbuffet.hp = 1; scene.currentBattle.mysteryEncounter!.misc.turnsRemaining = 0; (game.scene.phaseManager.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, 0, MoveUseMode.NORMAL); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); // Rewards expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( diff --git a/test/mystery-encounter/encounters/global-trade-system-encounter.test.ts b/test/mystery-encounter/encounters/global-trade-system-encounter.test.ts index 867a33f6ab6..f8c18a1742f 100644 --- a/test/mystery-encounter/encounters/global-trade-system-encounter.test.ts +++ b/test/mystery-encounter/encounters/global-trade-system-encounter.test.ts @@ -227,7 +227,7 @@ describe("Global Trade System - Mystery Encounter", () => { await runMysteryEncounterToEnd(game, 3, { pokemonNo: 1, optionNo: 1 }); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( diff --git a/test/mystery-encounter/encounters/mysterious-challengers-encounter.test.ts b/test/mystery-encounter/encounters/mysterious-challengers-encounter.test.ts index 5412f269122..0c4e3044bbd 100644 --- a/test/mystery-encounter/encounters/mysterious-challengers-encounter.test.ts +++ b/test/mystery-encounter/encounters/mysterious-challengers-encounter.test.ts @@ -161,9 +161,9 @@ describe("Mysterious Challengers - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.MYSTERIOUS_CHALLENGERS, defaultParty); await runMysteryEncounterToEnd(game, 1, undefined, true); await skipBattleRunMysteryEncounterRewardsPhase(game); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( @@ -205,9 +205,9 @@ describe("Mysterious Challengers - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.MYSTERIOUS_CHALLENGERS, defaultParty); await runMysteryEncounterToEnd(game, 2, undefined, true); await skipBattleRunMysteryEncounterRewardsPhase(game); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( @@ -262,9 +262,9 @@ describe("Mysterious Challengers - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.MYSTERIOUS_CHALLENGERS, defaultParty); await runMysteryEncounterToEnd(game, 3, undefined, true); await skipBattleRunMysteryEncounterRewardsPhase(game); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( diff --git a/test/mystery-encounter/encounters/teleporting-hijinks-encounter.test.ts b/test/mystery-encounter/encounters/teleporting-hijinks-encounter.test.ts index 43d497c57bb..aa534dd4385 100644 --- a/test/mystery-encounter/encounters/teleporting-hijinks-encounter.test.ts +++ b/test/mystery-encounter/encounters/teleporting-hijinks-encounter.test.ts @@ -146,7 +146,7 @@ describe("Teleporting Hijinks - Mystery Encounter", () => { it("should NOT be selectable if the player doesn't have enough money", async () => { game.scene.money = 0; await game.runToMysteryEncounter(MysteryEncounterType.TELEPORTING_HIJINKS, defaultParty); - await game.phaseInterceptor.to(MysteryEncounterPhase, false); + await game.phaseInterceptor.to("MysteryEncounterPhase", false); const encounterPhase = scene.phaseManager.getCurrentPhase(); expect(encounterPhase?.constructor.name).toBe(MysteryEncounterPhase.name); @@ -218,7 +218,7 @@ describe("Teleporting Hijinks - Mystery Encounter", () => { it("should NOT be selectable if the player doesn't the right type pokemon", async () => { await game.runToMysteryEncounter(MysteryEncounterType.TELEPORTING_HIJINKS, [SpeciesId.BLASTOISE]); - await game.phaseInterceptor.to(MysteryEncounterPhase, false); + await game.phaseInterceptor.to("MysteryEncounterPhase", false); const encounterPhase = scene.phaseManager.getCurrentPhase(); expect(encounterPhase?.constructor.name).toBe(MysteryEncounterPhase.name); @@ -299,9 +299,9 @@ describe("Teleporting Hijinks - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.TELEPORTING_HIJINKS, defaultParty); await runMysteryEncounterToEnd(game, 3, undefined, true); await skipBattleRunMysteryEncounterRewardsPhase(game); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( diff --git a/test/mystery-encounter/encounters/the-expert-breeder-encounter.test.ts b/test/mystery-encounter/encounters/the-expert-breeder-encounter.test.ts index 4556f7a7f45..768d6aa7b8f 100644 --- a/test/mystery-encounter/encounters/the-expert-breeder-encounter.test.ts +++ b/test/mystery-encounter/encounters/the-expert-breeder-encounter.test.ts @@ -13,7 +13,6 @@ import * as MysteryEncounters from "#mystery-encounters/mystery-encounters"; import { HUMAN_TRANSITABLE_BIOMES } from "#mystery-encounters/mystery-encounters"; import { TheExpertPokemonBreederEncounter } from "#mystery-encounters/the-expert-pokemon-breeder-encounter"; import { CommandPhase } from "#phases/command-phase"; -import { PostMysteryEncounterPhase } from "#phases/mystery-encounter-phases"; import { SelectModifierPhase } from "#phases/select-modifier-phase"; import { runMysteryEncounterToEnd, @@ -176,7 +175,7 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => { await runMysteryEncounterToEnd(game, 1, undefined, true); await skipBattleRunMysteryEncounterRewardsPhase(game); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); const eggsAfter = scene.gameData.eggs; @@ -187,8 +186,8 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => { expect(eggsAfter.filter(egg => egg.tier === EggTier.COMMON).length).toBe(commonEggs); expect(eggsAfter.filter(egg => egg.tier === EggTier.RARE).length).toBe(rareEggs); - game.phaseInterceptor.superEndPhase(); - await game.phaseInterceptor.to(PostMysteryEncounterPhase); + game.phaseInterceptor.shiftPhase(); + await game.phaseInterceptor.to("PostMysteryEncounterPhase"); const friendshipAfter = scene.currentBattle.mysteryEncounter!.misc.pokemon1.friendship; // 20 from ME + extra from winning battle (that extra is not accurate to what happens in game. @@ -261,7 +260,7 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => { await runMysteryEncounterToEnd(game, 2, undefined, true); await skipBattleRunMysteryEncounterRewardsPhase(game); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); const eggsAfter = scene.gameData.eggs; @@ -272,8 +271,8 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => { expect(eggsAfter.filter(egg => egg.tier === EggTier.COMMON).length).toBe(commonEggs); expect(eggsAfter.filter(egg => egg.tier === EggTier.RARE).length).toBe(rareEggs); - game.phaseInterceptor.superEndPhase(); - await game.phaseInterceptor.to(PostMysteryEncounterPhase); + game.phaseInterceptor.shiftPhase(); + await game.phaseInterceptor.to("PostMysteryEncounterPhase"); const friendshipAfter = scene.currentBattle.mysteryEncounter!.misc.pokemon2.friendship; expect(friendshipAfter).toBe(friendshipBefore + 20 + FRIENDSHIP_GAIN_FROM_BATTLE); // 20 from ME + extra for friendship gained from winning battle @@ -343,7 +342,7 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => { await runMysteryEncounterToEnd(game, 3, undefined, true); await skipBattleRunMysteryEncounterRewardsPhase(game); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); const eggsAfter = scene.gameData.eggs; @@ -354,8 +353,8 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => { expect(eggsAfter.filter(egg => egg.tier === EggTier.COMMON).length).toBe(commonEggs); expect(eggsAfter.filter(egg => egg.tier === EggTier.RARE).length).toBe(rareEggs); - game.phaseInterceptor.superEndPhase(); - await game.phaseInterceptor.to(PostMysteryEncounterPhase); + game.phaseInterceptor.shiftPhase(); + await game.phaseInterceptor.to("PostMysteryEncounterPhase"); const friendshipAfter = scene.currentBattle.mysteryEncounter!.misc.pokemon3.friendship; expect(friendshipAfter).toBe(friendshipBefore + 20 + FRIENDSHIP_GAIN_FROM_BATTLE); // 20 + extra for friendship gained from winning battle diff --git a/test/mystery-encounter/encounters/the-strong-stuff-encounter.test.ts b/test/mystery-encounter/encounters/the-strong-stuff-encounter.test.ts index a314a14485f..3592e2dc774 100644 --- a/test/mystery-encounter/encounters/the-strong-stuff-encounter.test.ts +++ b/test/mystery-encounter/encounters/the-strong-stuff-encounter.test.ts @@ -229,9 +229,9 @@ describe("The Strong Stuff - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.THE_STRONG_STUFF, defaultParty); await runMysteryEncounterToEnd(game, 2, undefined, true); await skipBattleRunMysteryEncounterRewardsPhase(game); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( diff --git a/test/mystery-encounter/encounters/the-winstrate-challenge-encounter.test.ts b/test/mystery-encounter/encounters/the-winstrate-challenge-encounter.test.ts index ae2f9fd79ff..8c38d6b5d94 100644 --- a/test/mystery-encounter/encounters/the-winstrate-challenge-encounter.test.ts +++ b/test/mystery-encounter/encounters/the-winstrate-challenge-encounter.test.ts @@ -16,7 +16,6 @@ import * as MysteryEncounters from "#mystery-encounters/mystery-encounters"; import { HUMAN_TRANSITABLE_BIOMES } from "#mystery-encounters/mystery-encounters"; import { TheWinstrateChallengeEncounter } from "#mystery-encounters/the-winstrate-challenge-encounter"; import { CommandPhase } from "#phases/command-phase"; -import { MysteryEncounterRewardsPhase } from "#phases/mystery-encounter-phases"; import { PartyHealPhase } from "#phases/party-heal-phase"; import { SelectModifierPhase } from "#phases/select-modifier-phase"; import { VictoryPhase } from "#phases/victory-phase"; @@ -295,9 +294,9 @@ describe("The Winstrate Challenge - Mystery Encounter", () => { // Should have Macho Brace in the rewards await skipBattleToNextBattle(game, true); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( @@ -339,7 +338,7 @@ describe("The Winstrate Challenge - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.THE_WINSTRATE_CHALLENGE, defaultParty); await runMysteryEncounterToEnd(game, 2); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( @@ -366,11 +365,10 @@ async function skipBattleToNextBattle(game: GameManager, isFinalBattle = false) p.status = new Status(StatusEffect.FAINT); game.scene.field.remove(p); }); - game.phaseInterceptor["onHold"] = []; game.scene.phaseManager.pushPhase(new VictoryPhase(0)); - game.phaseInterceptor.superEndPhase(); + game.endPhase(); if (isFinalBattle) { - await game.phaseInterceptor.to(MysteryEncounterRewardsPhase); + await game.phaseInterceptor.to("MysteryEncounterRewardsPhase"); } else { await game.toNextTurn(); } diff --git a/test/mystery-encounter/encounters/trash-to-treasure-encounter.test.ts b/test/mystery-encounter/encounters/trash-to-treasure-encounter.test.ts index 133fbfb10ba..b32dcddadb8 100644 --- a/test/mystery-encounter/encounters/trash-to-treasure-encounter.test.ts +++ b/test/mystery-encounter/encounters/trash-to-treasure-encounter.test.ts @@ -172,7 +172,7 @@ describe("Trash to Treasure - Mystery Encounter", () => { it("should give 2 Leftovers, 1 Shell Bell, and Black Sludge", async () => { await game.runToMysteryEncounter(MysteryEncounterType.TRASH_TO_TREASURE, defaultParty); await runMysteryEncounterToEnd(game, 1); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); const leftovers = scene.findModifier(m => m instanceof TurnHealModifier) as TurnHealModifier; @@ -242,9 +242,9 @@ describe("Trash to Treasure - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.TRASH_TO_TREASURE, defaultParty); await runMysteryEncounterToEnd(game, 2, undefined, true); await skipBattleRunMysteryEncounterRewardsPhase(game); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( diff --git a/test/mystery-encounter/encounters/weird-dream-encounter.test.ts b/test/mystery-encounter/encounters/weird-dream-encounter.test.ts index e9fcc9797d1..8e9855fd619 100644 --- a/test/mystery-encounter/encounters/weird-dream-encounter.test.ts +++ b/test/mystery-encounter/encounters/weird-dream-encounter.test.ts @@ -116,7 +116,7 @@ describe("Weird Dream - Mystery Encounter", () => { const bstsPrior = pokemonPrior.map(species => species.getSpeciesForm().getBaseStatTotal()); await runMysteryEncounterToEnd(game, 1); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); const pokemonAfter = scene.getPlayerParty(); @@ -139,9 +139,9 @@ describe("Weird Dream - Mystery Encounter", () => { it("should have 1 Memory Mushroom, 5 Rogue Balls, and 3 Mints in rewards", async () => { await game.runToMysteryEncounter(MysteryEncounterType.WEIRD_DREAM, defaultParty); await runMysteryEncounterToEnd(game, 1); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( @@ -195,9 +195,9 @@ describe("Weird Dream - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.WEIRD_DREAM, defaultParty); await runMysteryEncounterToEnd(game, 2, undefined, true); await skipBattleRunMysteryEncounterRewardsPhase(game); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); - await game.phaseInterceptor.run(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( diff --git a/test/phases/mystery-encounter-phase.test.ts b/test/phases/mystery-encounter-phase.test.ts index ad71a4151ac..cea613cf883 100644 --- a/test/phases/mystery-encounter-phase.test.ts +++ b/test/phases/mystery-encounter-phase.test.ts @@ -37,7 +37,7 @@ describe("Mystery Encounter Phases", () => { SpeciesId.VOLCARONA, ]); - await game.phaseInterceptor.to(MysteryEncounterPhase, false); + await game.phaseInterceptor.to("MysteryEncounterPhase", false); expect(game.scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterPhase.name); }); @@ -49,9 +49,9 @@ describe("Mystery Encounter Phases", () => { game.onNextPrompt("MysteryEncounterPhase", UiMode.MYSTERY_ENCOUNTER, () => { // End phase early for test - game.phaseInterceptor.superEndPhase(); + game.endPhase(); }); - await game.phaseInterceptor.run(MysteryEncounterPhase); + await game.phaseInterceptor.to("MysteryEncounterPhase"); expect(game.scene.mysteryEncounterSaveData.encounteredEvents.length).toBeGreaterThan(0); expect(game.scene.mysteryEncounterSaveData.encounteredEvents[0].type).toEqual( @@ -75,7 +75,7 @@ describe("Mystery Encounter Phases", () => { handler.processInput(Button.ACTION); }); - await game.phaseInterceptor.run(MysteryEncounterPhase); + await game.phaseInterceptor.to("MysteryEncounterPhase"); // Select option 1 for encounter const handler = game.scene.ui.getHandler() as MysteryEncounterUiHandler; diff --git a/test/test-utils/game-manager.ts b/test/test-utils/game-manager.ts index 23a2e6240f8..47b41f173fb 100644 --- a/test/test-utils/game-manager.ts +++ b/test/test-utils/game-manager.ts @@ -20,13 +20,11 @@ import { ModifierTypeOption } from "#modifiers/modifier-type"; import { CheckSwitchPhase } from "#phases/check-switch-phase"; import { CommandPhase } from "#phases/command-phase"; import { EncounterPhase } from "#phases/encounter-phase"; -import { LoginPhase } from "#phases/login-phase"; import { MovePhase } from "#phases/move-phase"; import { MysteryEncounterPhase } from "#phases/mystery-encounter-phases"; import { NewBattlePhase } from "#phases/new-battle-phase"; import { SelectStarterPhase } from "#phases/select-starter-phase"; import type { SelectTargetPhase } from "#phases/select-target-phase"; -import { TitlePhase } from "#phases/title-phase"; import { TurnEndPhase } from "#phases/turn-end-phase"; import { TurnInitPhase } from "#phases/turn-init-phase"; import { TurnStartPhase } from "#phases/turn-start-phase"; @@ -178,9 +176,10 @@ export class GameManager { * @returns A promise that resolves when the title phase is reached. */ async runToTitle(): Promise { - await this.phaseInterceptor.whenAboutToRun(LoginPhase); - this.phaseInterceptor.pop(); - await this.phaseInterceptor.run(TitlePhase); + // Go to login phase and skip past it + await this.phaseInterceptor.to("LoginPhase", false); + this.phaseInterceptor.shiftPhase(); + await this.phaseInterceptor.to("TitlePhase"); this.scene.gameSpeed = 5; this.scene.moveAnimations = false; @@ -260,7 +259,7 @@ export class GameManager { true, ); - await this.phaseInterceptor.run(EncounterPhase); + await this.phaseInterceptor.to("EncounterPhase"); if (!isNullOrUndefined(encounterType)) { expect(this.scene.currentBattle?.mysteryEncounter?.encounterType).toBe(encounterType); } @@ -529,7 +528,7 @@ export class GameManager { * ``` */ async setTurnOrder(order: BattlerIndex[]): Promise { - await this.phaseInterceptor.to(TurnStartPhase, false); + await this.phaseInterceptor.to("TurnStartPhase", false); vi.spyOn(this.scene.phaseManager.getCurrentPhase() as TurnStartPhase, "getSpeedOrder").mockReturnValue(order); } diff --git a/test/test-utils/helpers/challenge-mode-helper.ts b/test/test-utils/helpers/challenge-mode-helper.ts index 3952685a560..d18fa3da82b 100644 --- a/test/test-utils/helpers/challenge-mode-helper.ts +++ b/test/test-utils/helpers/challenge-mode-helper.ts @@ -49,7 +49,7 @@ export class ChallengeModeHelper extends GameManagerHelper { selectStarterPhase.initBattle(starters); }); - await this.game.phaseInterceptor.run(EncounterPhase); + await this.game.phaseInterceptor.to("EncounterPhase"); if (overrides.OPP_HELD_ITEMS_OVERRIDE.length === 0 && this.game.override.removeEnemyStartingItems) { this.game.removeEnemyHeldItems(); } diff --git a/test/test-utils/helpers/reload-helper.ts b/test/test-utils/helpers/reload-helper.ts index a8ed0e21307..c537f5ca15d 100644 --- a/test/test-utils/helpers/reload-helper.ts +++ b/test/test-utils/helpers/reload-helper.ts @@ -57,7 +57,7 @@ export class ReloadHelper extends GameManagerHelper { this.game.scene.modifiers = []; } titlePhase.loadSaveSlot(-1); // Load the desired session data - this.game.phaseInterceptor.shift(); // Loading the save slot also ended TitlePhase, clean it up + this.game.scene.phaseManager.shiftPhase(); // Loading the save slot also ended TitlePhase, clean it up // Run through prompts for switching Pokemon, copied from classicModeHelper.ts if (this.game.scene.battleStyle === BattleStyle.SWITCH) { diff --git a/test/ui/pokedex.test.ts b/test/ui/pokedex.test.ts index 217c1f09a3b..edd9fa879d0 100644 --- a/test/ui/pokedex.test.ts +++ b/test/ui/pokedex.test.ts @@ -69,7 +69,7 @@ describe("UI - Pokedex", () => { // Open the pokedex UI. await game.runToTitle(); - await game.phaseInterceptor.setOverlayMode(UiMode.POKEDEX); + await game.scene.ui.setOverlayMode(UiMode.POKEDEX); // Get the handler for the current UI. const handler = game.scene.ui.getHandler(); @@ -89,7 +89,7 @@ describe("UI - Pokedex", () => { // Open the pokedex UI. await game.runToTitle(); - await game.phaseInterceptor.setOverlayMode(UiMode.POKEDEX_PAGE, species, starterAttributes); + await game.scene.ui.setOverlayMode(UiMode.POKEDEX_PAGE, species, starterAttributes); // Get the handler for the current UI. const handler = game.scene.ui.getHandler(); diff --git a/test/ui/starter-select.test.ts b/test/ui/starter-select.test.ts index a8c6284cf3f..623654d7516 100644 --- a/test/ui/starter-select.test.ts +++ b/test/ui/starter-select.test.ts @@ -6,8 +6,6 @@ import { GameModes } from "#enums/game-modes"; import { Nature } from "#enums/nature"; import { SpeciesId } from "#enums/species-id"; import { UiMode } from "#enums/ui-mode"; -import { EncounterPhase } from "#phases/encounter-phase"; -import { SelectStarterPhase } from "#phases/select-starter-phase"; import type { TitlePhase } from "#phases/title-phase"; import { GameManager } from "#test/test-utils/game-manager"; import type { OptionSelectItem } from "#ui/abstact-option-select-ui-handler"; @@ -54,9 +52,8 @@ describe("UI - Starter select", () => { handler.processInput(Button.RIGHT); handler.processInput(Button.LEFT); handler.processInput(Button.ACTION); - game.phaseInterceptor.unlock(); }); - await game.phaseInterceptor.run(SelectStarterPhase); + await game.phaseInterceptor.to("SelectStarterPhase"); let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; await new Promise(resolve => { @@ -88,7 +85,7 @@ describe("UI - Starter select", () => { resolve(); }); }); - await game.phaseInterceptor.whenAboutToRun(EncounterPhase); + await game.phaseInterceptor.to("EncounterPhase", false); expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.BULBASAUR); expect(game.scene.getPlayerParty()[0].shiny).toBe(true); @@ -115,9 +112,8 @@ describe("UI - Starter select", () => { handler.processInput(Button.LEFT); handler.processInput(Button.CYCLE_GENDER); handler.processInput(Button.ACTION); - game.phaseInterceptor.unlock(); }); - await game.phaseInterceptor.run(SelectStarterPhase); + await game.phaseInterceptor.to("SelectStarterPhase"); let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; await new Promise(resolve => { @@ -149,7 +145,7 @@ describe("UI - Starter select", () => { resolve(); }); }); - await game.phaseInterceptor.whenAboutToRun(EncounterPhase); + await game.phaseInterceptor.to("EncounterPhase", false); expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.BULBASAUR); expect(game.scene.getPlayerParty()[0].shiny).toBe(true); @@ -179,9 +175,8 @@ describe("UI - Starter select", () => { handler.processInput(Button.CYCLE_NATURE); handler.processInput(Button.CYCLE_ABILITY); handler.processInput(Button.ACTION); - game.phaseInterceptor.unlock(); }); - await game.phaseInterceptor.run(SelectStarterPhase); + await game.phaseInterceptor.to("SelectStarterPhase"); let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; await new Promise(resolve => { @@ -213,7 +208,7 @@ describe("UI - Starter select", () => { resolve(); }); }); - await game.phaseInterceptor.whenAboutToRun(EncounterPhase); + await game.phaseInterceptor.to("EncounterPhase", false); expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.BULBASAUR); expect(game.scene.getPlayerParty()[0].shiny).toBe(true); @@ -242,9 +237,8 @@ describe("UI - Starter select", () => { handler.processInput(Button.LEFT); handler.processInput(Button.CYCLE_GENDER); handler.processInput(Button.ACTION); - game.phaseInterceptor.unlock(); }); - await game.phaseInterceptor.run(SelectStarterPhase); + await game.phaseInterceptor.to("SelectStarterPhase"); let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; await new Promise(resolve => { @@ -276,7 +270,7 @@ describe("UI - Starter select", () => { resolve(); }); }); - await game.phaseInterceptor.whenAboutToRun(EncounterPhase); + await game.phaseInterceptor.to("EncounterPhase", false); expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.BULBASAUR); expect(game.scene.getPlayerParty()[0].shiny).toBe(true); @@ -303,9 +297,8 @@ describe("UI - Starter select", () => { handler.processInput(Button.LEFT); handler.processInput(Button.ACTION); handler.processInput(Button.CYCLE_SHINY); - game.phaseInterceptor.unlock(); }); - await game.phaseInterceptor.run(SelectStarterPhase); + await game.phaseInterceptor.to("SelectStarterPhase"); let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; await new Promise(resolve => { @@ -337,7 +330,7 @@ describe("UI - Starter select", () => { resolve(); }); }); - await game.phaseInterceptor.whenAboutToRun(EncounterPhase); + await game.phaseInterceptor.to("EncounterPhase", false); expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.BULBASAUR); expect(game.scene.getPlayerParty()[0].shiny).toBe(false); @@ -365,9 +358,8 @@ describe("UI - Starter select", () => { handler.processInput(Button.CYCLE_SHINY); handler.processInput(Button.CYCLE_SHINY); handler.processInput(Button.ACTION); - game.phaseInterceptor.unlock(); }); - await game.phaseInterceptor.run(SelectStarterPhase); + await game.phaseInterceptor.to("SelectStarterPhase"); let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; await new Promise(resolve => { @@ -399,7 +391,7 @@ describe("UI - Starter select", () => { resolve(); }); }); - await game.phaseInterceptor.whenAboutToRun(EncounterPhase); + await game.phaseInterceptor.to("EncounterPhase", false); expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.BULBASAUR); expect(game.scene.getPlayerParty()[0].shiny).toBe(true); @@ -426,9 +418,8 @@ describe("UI - Starter select", () => { handler.processInput(Button.CYCLE_SHINY); handler.processInput(Button.CYCLE_SHINY); handler.processInput(Button.ACTION); - game.phaseInterceptor.unlock(); }); - await game.phaseInterceptor.run(SelectStarterPhase); + await game.phaseInterceptor.to("SelectStarterPhase"); let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; await new Promise(resolve => { @@ -460,7 +451,7 @@ describe("UI - Starter select", () => { resolve(); }); }); - await game.phaseInterceptor.whenAboutToRun(EncounterPhase); + await game.phaseInterceptor.to("EncounterPhase", false); expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.BULBASAUR); expect(game.scene.getPlayerParty()[0].shiny).toBe(true); @@ -486,9 +477,8 @@ describe("UI - Starter select", () => { handler.processInput(Button.RIGHT); handler.processInput(Button.RIGHT); handler.processInput(Button.ACTION); - game.phaseInterceptor.unlock(); }); - await game.phaseInterceptor.run(SelectStarterPhase); + await game.phaseInterceptor.to("SelectStarterPhase"); let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; await new Promise(resolve => { @@ -527,7 +517,7 @@ describe("UI - Starter select", () => { const saveSlotSelectUiHandler = game.scene.ui.getHandler() as SaveSlotSelectUiHandler; saveSlotSelectUiHandler.processInput(Button.ACTION); }); - await game.phaseInterceptor.whenAboutToRun(EncounterPhase); + await game.phaseInterceptor.to("EncounterPhase", false); expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.CATERPIE); }); @@ -551,9 +541,8 @@ describe("UI - Starter select", () => { handler.processInput(Button.RIGHT); handler.processInput(Button.DOWN); handler.processInput(Button.ACTION); - game.phaseInterceptor.unlock(); }); - await game.phaseInterceptor.run(SelectStarterPhase); + await game.phaseInterceptor.to("SelectStarterPhase"); let options: OptionSelectItem[] = []; let optionSelectUiHandler: OptionSelectUiHandler | undefined; await new Promise(resolve => { @@ -593,7 +582,7 @@ describe("UI - Starter select", () => { const saveSlotSelectUiHandler = game.scene.ui.getHandler() as SaveSlotSelectUiHandler; saveSlotSelectUiHandler.processInput(Button.ACTION); }); - await game.phaseInterceptor.whenAboutToRun(EncounterPhase); + await game.phaseInterceptor.to("EncounterPhase", false); expect(game.scene.getPlayerParty()[0].species.speciesId).toBe(SpeciesId.NIDORAN_M); }); }); diff --git a/test/ui/transfer-item.test.ts b/test/ui/transfer-item.test.ts index 0d101b5b4ef..8e42149acc3 100644 --- a/test/ui/transfer-item.test.ts +++ b/test/ui/transfer-item.test.ts @@ -72,8 +72,6 @@ describe("UI - Transfer Items", () => { expect( handler.optionsContainer.list.some(option => RegExp(/Lum Berry\[color.*(2)/).exec((option as BBCodeText).text)), ).toBe(true); - - game.phaseInterceptor.unlock(); }); await game.phaseInterceptor.to("SelectModifierPhase"); @@ -93,8 +91,6 @@ describe("UI - Transfer Items", () => { expect(handler.optionsContainer.list.some(option => (option as BBCodeText).text?.includes("Transfer"))).toBe( true, ); - - game.phaseInterceptor.unlock(); }); await game.phaseInterceptor.to("SelectModifierPhase"); diff --git a/test/ui/type-hints.test.ts b/test/ui/type-hints.test.ts index f1f27322a64..5a626081751 100644 --- a/test/ui/type-hints.test.ts +++ b/test/ui/type-hints.test.ts @@ -2,7 +2,6 @@ import { Button } from "#enums/buttons"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import { UiMode } from "#enums/ui-mode"; -import { CommandPhase } from "#phases/command-phase"; import { GameManager } from "#test/test-utils/game-manager"; import type { MockText } from "#test/test-utils/mocks/mocks-container/mock-text"; import { FightUiHandler } from "#ui/fight-ui-handler"; @@ -46,7 +45,6 @@ describe("UI - Type Hints", () => { const { ui } = game.scene; const handler = ui.getHandler(); handler.processInput(Button.ACTION); // select "Fight" - game.phaseInterceptor.unlock(); }); game.onNextPrompt("CommandPhase", UiMode.FIGHT, () => { @@ -59,7 +57,7 @@ describe("UI - Type Hints", () => { expect.soft(dragonClawText.color).toBe("#929292"); ui.getHandler().processInput(Button.ACTION); }); - await game.phaseInterceptor.to(CommandPhase); + await game.toNextTurn(); }); it("check status move color", async () => { @@ -71,7 +69,6 @@ describe("UI - Type Hints", () => { const { ui } = game.scene; const handler = ui.getHandler(); handler.processInput(Button.ACTION); // select "Fight" - game.phaseInterceptor.unlock(); }); game.onNextPrompt("CommandPhase", UiMode.FIGHT, () => { @@ -84,7 +81,7 @@ describe("UI - Type Hints", () => { expect.soft(growlText.color).toBe(undefined); ui.getHandler().processInput(Button.ACTION); }); - await game.phaseInterceptor.to(CommandPhase); + await game.toNextTurn(); }); it("should show the proper hint for a move in doubles after one of the enemy pokemon flees", async () => { @@ -107,7 +104,6 @@ describe("UI - Type Hints", () => { const { ui } = game.scene; const handler = ui.getHandler(); handler.processInput(Button.ACTION); // select "Fight" - game.phaseInterceptor.unlock(); }); game.onNextPrompt("CommandPhase", UiMode.FIGHT, () => { @@ -121,6 +117,6 @@ describe("UI - Type Hints", () => { expect.soft(shadowBallText.color).toBe(undefined); ui.getHandler().processInput(Button.ACTION); }); - await game.phaseInterceptor.to(CommandPhase); + await game.toNextTurn(); }); });