From b458d512f11ab7553181b03eaf494423ac9251f5 Mon Sep 17 00:00:00 2001 From: Bertie690 Date: Wed, 18 Jun 2025 18:24:43 -0400 Subject: [PATCH 1/9] Fixed up phase interceptor --- test/testUtils/errorInterceptor.ts | 49 --- test/testUtils/gameManager.ts | 11 +- test/testUtils/helpers/reloadHelper.ts | 2 +- test/testUtils/phaseInterceptor.ts | 557 +++++++------------------ test/vitest.setup.ts | 2 - tsconfig.json | 1 + 6 files changed, 156 insertions(+), 466 deletions(-) delete mode 100644 test/testUtils/errorInterceptor.ts diff --git a/test/testUtils/errorInterceptor.ts b/test/testUtils/errorInterceptor.ts deleted file mode 100644 index a8fb3284b78..00000000000 --- a/test/testUtils/errorInterceptor.ts +++ /dev/null @@ -1,49 +0,0 @@ -export default class ErrorInterceptor { - private static instance: ErrorInterceptor; - public running; - - constructor() { - this.running = []; - } - - public static getInstance(): ErrorInterceptor { - if (!ErrorInterceptor.instance) { - ErrorInterceptor.instance = new ErrorInterceptor(); - } - return ErrorInterceptor.instance; - } - - clear() { - this.running = []; - } - - add(obj) { - this.running.push(obj); - } - - remove(obj) { - const index = this.running.indexOf(obj); - if (index !== -1) { - this.running.splice(index, 1); - } - } -} - -process.on("uncaughtException", error => { - console.log(error); - const toStop = ErrorInterceptor.getInstance().running; - for (const elm of toStop) { - elm.rejectAll(error); - } - global.testFailed = true; -}); - -// Global error handler for unhandled promise rejections -process.on("unhandledRejection", (reason, _promise) => { - console.log(reason); - const toStop = ErrorInterceptor.getInstance().running; - for (const elm of toStop) { - elm.rejectAll(reason); - } - global.testFailed = true; -}); diff --git a/test/testUtils/gameManager.ts b/test/testUtils/gameManager.ts index b9f499d4e0c..f18ff6e98f7 100644 --- a/test/testUtils/gameManager.ts +++ b/test/testUtils/gameManager.ts @@ -13,13 +13,11 @@ import { CheckSwitchPhase } from "#app/phases/check-switch-phase"; import { CommandPhase } from "#app/phases/command-phase"; import { EncounterPhase } from "#app/phases/encounter-phase"; import { FaintPhase } from "#app/phases/faint-phase"; -import { LoginPhase } from "#app/phases/login-phase"; import { MovePhase } from "#app/phases/move-phase"; import { MysteryEncounterPhase } from "#app/phases/mystery-encounter-phases"; import { NewBattlePhase } from "#app/phases/new-battle-phase"; import { SelectStarterPhase } from "#app/phases/select-starter-phase"; import type { SelectTargetPhase } from "#app/phases/select-target-phase"; -import { TitlePhase } from "#app/phases/title-phase"; import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { TurnInitPhase } from "#app/phases/turn-init-phase"; import { TurnStartPhase } from "#app/phases/turn-start-phase"; @@ -129,6 +127,8 @@ export default class GameManager { // Disables Mystery Encounters on all tests (can be overridden at test level) this.override.mysteryEncounterChance(0); + this.scene.moveAnimations = false; // Disable move animations + global.fetch = vi.fn(MockFetch) as any; } @@ -182,9 +182,10 @@ export default 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; diff --git a/test/testUtils/helpers/reloadHelper.ts b/test/testUtils/helpers/reloadHelper.ts index 4f9d6c810f8..5a10b0a7235 100644 --- a/test/testUtils/helpers/reloadHelper.ts +++ b/test/testUtils/helpers/reloadHelper.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/testUtils/phaseInterceptor.ts b/test/testUtils/phaseInterceptor.ts index 9d046fc85ba..b14b943db8e 100644 --- a/test/testUtils/phaseInterceptor.ts +++ b/test/testUtils/phaseInterceptor.ts @@ -1,184 +1,49 @@ -import { Phase } from "#app/phase"; -import ErrorInterceptor from "#test/testUtils/errorInterceptor"; -import { AttemptRunPhase } from "#app/phases/attempt-run-phase"; -import { BattleEndPhase } from "#app/phases/battle-end-phase"; -import { BerryPhase } from "#app/phases/berry-phase"; -import { CheckSwitchPhase } from "#app/phases/check-switch-phase"; -import { CommandPhase } from "#app/phases/command-phase"; -import { DamageAnimPhase } from "#app/phases/damage-anim-phase"; -import { EggLapsePhase } from "#app/phases/egg-lapse-phase"; -import { EncounterPhase } from "#app/phases/encounter-phase"; -import { EndEvolutionPhase } from "#app/phases/end-evolution-phase"; -import { EnemyCommandPhase } from "#app/phases/enemy-command-phase"; -import { EvolutionPhase } from "#app/phases/evolution-phase"; -import { FaintPhase } from "#app/phases/faint-phase"; -import { FormChangePhase } from "#app/phases/form-change-phase"; -import { LearnMovePhase } from "#app/phases/learn-move-phase"; -import { LevelCapPhase } from "#app/phases/level-cap-phase"; -import { LoginPhase } from "#app/phases/login-phase"; -import { MessagePhase } from "#app/phases/message-phase"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase"; -import { MoveEndPhase } from "#app/phases/move-end-phase"; -import { MovePhase } from "#app/phases/move-phase"; -import { NewBattlePhase } from "#app/phases/new-battle-phase"; -import { NewBiomeEncounterPhase } from "#app/phases/new-biome-encounter-phase"; -import { NextEncounterPhase } from "#app/phases/next-encounter-phase"; -import { PostSummonPhase } from "#app/phases/post-summon-phase"; -import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase"; -import { SelectGenderPhase } from "#app/phases/select-gender-phase"; -import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; -import { SelectStarterPhase } from "#app/phases/select-starter-phase"; -import { SelectTargetPhase } from "#app/phases/select-target-phase"; -import { ShinySparklePhase } from "#app/phases/shiny-sparkle-phase"; -import { ShowAbilityPhase } from "#app/phases/show-ability-phase"; -import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase"; -import { SummonPhase } from "#app/phases/summon-phase"; -import { SwitchPhase } from "#app/phases/switch-phase"; -import { SwitchSummonPhase } from "#app/phases/switch-summon-phase"; -import { TitlePhase } from "#app/phases/title-phase"; -import { ToggleDoublePositionPhase } from "#app/phases/toggle-double-position-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; -import { TurnInitPhase } from "#app/phases/turn-init-phase"; -import { TurnStartPhase } from "#app/phases/turn-start-phase"; -import { UnavailablePhase } from "#app/phases/unavailable-phase"; -import { VictoryPhase } from "#app/phases/victory-phase"; -import { PartyHealPhase } from "#app/phases/party-heal-phase"; -import UI from "#app/ui/ui"; +import type BattleScene from "#app/battle-scene"; +import type { Phase } from "#app/phase"; import { UiMode } from "#enums/ui-mode"; -import { SelectBiomePhase } from "#app/phases/select-biome-phase"; -import { - MysteryEncounterBattlePhase, - MysteryEncounterOptionSelectedPhase, - MysteryEncounterPhase, - MysteryEncounterRewardsPhase, - PostMysteryEncounterPhase, -} from "#app/phases/mystery-encounter-phases"; -import { ModifierRewardPhase } from "#app/phases/modifier-reward-phase"; -import { PartyExpPhase } from "#app/phases/party-exp-phase"; -import { ExpPhase } from "#app/phases/exp-phase"; -import { GameOverPhase } from "#app/phases/game-over-phase"; -import { RibbonModifierRewardPhase } from "#app/phases/ribbon-modifier-reward-phase"; -import { GameOverModifierRewardPhase } from "#app/phases/game-over-modifier-reward-phase"; -import { UnlockPhase } from "#app/phases/unlock-phase"; -import { PostGameOverPhase } from "#app/phases/post-game-over-phase"; -import { RevivalBlessingPhase } from "#app/phases/revival-blessing-phase"; +import UI from "#app/ui/ui"; +import type { PhaseString } from "#app/@types/phase-types"; +import { vi } from "vitest"; -import type { PhaseClass, PhaseString } from "#app/@types/phase-types"; - -export interface PromptHandler { - phaseTarget?: string; +interface PromptHandler { + phaseTarget?: PhaseString; mode?: UiMode; callback?: () => void; - expireFn?: () => void; + expireFn?: () => boolean; awaitingActionInput?: boolean; } -type PhaseInterceptorPhase = PhaseClass | PhaseString; +/** Array of phases which end via player input. */ +const endBySetMode: Set = new Set([ + "TitlePhase", + "SelectGenderPhase", + "CommandPhase", + "SelectModifierPhase", + "MysteryEncounterPhase", + "PostMysteryEncounterPhase", +]); +/** + * The PhaseInterceptor is a wrapper around the `BattleScene`'s {@linkcode PhaseManager}. + * It allows tests to exert finer control over the phase system, providing logging, + */ export default class PhaseInterceptor { - public scene; - public phases = {}; - public log: string[]; - private onHold; - private interval; - private promptInterval; - private intervalRun; - private prompts: PromptHandler[]; - private phaseFrom; - private inProgress; - private originalSetMode; - private originalSetOverlayMode; - private originalSuperEnd; - - /** - * List of phases with their corresponding start methods. - * - * CAUTION: If a phase and its subclasses (if any) both appear in this list, - * make sure that this list contains said phase AFTER all of its subclasses. - * This way, the phase's `prototype.start` is properly preserved during - * `initPhases()` so that its subclasses can use `super.start()` properly. - */ - private PHASES = [ - [LoginPhase, this.startPhase], - [TitlePhase, this.startPhase], - [SelectGenderPhase, this.startPhase], - [NewBiomeEncounterPhase, this.startPhase], - [SelectStarterPhase, this.startPhase], - [PostSummonPhase, this.startPhase], - [SummonPhase, this.startPhase], - [ToggleDoublePositionPhase, this.startPhase], - [CheckSwitchPhase, this.startPhase], - [ShowAbilityPhase, this.startPhase], - [MessagePhase, this.startPhase], - [TurnInitPhase, this.startPhase], - [CommandPhase, this.startPhase], - [EnemyCommandPhase, this.startPhase], - [TurnStartPhase, this.startPhase], - [MovePhase, this.startPhase], - [MoveEffectPhase, this.startPhase], - [DamageAnimPhase, this.startPhase], - [FaintPhase, this.startPhase], - [BerryPhase, this.startPhase], - [TurnEndPhase, this.startPhase], - [BattleEndPhase, this.startPhase], - [EggLapsePhase, this.startPhase], - [SelectModifierPhase, this.startPhase], - [NextEncounterPhase, this.startPhase], - [NewBattlePhase, this.startPhase], - [VictoryPhase, this.startPhase], - [LearnMovePhase, this.startPhase], - [MoveEndPhase, this.startPhase], - [StatStageChangePhase, this.startPhase], - [ShinySparklePhase, this.startPhase], - [SelectTargetPhase, this.startPhase], - [UnavailablePhase, this.startPhase], - [QuietFormChangePhase, this.startPhase], - [SwitchPhase, this.startPhase], - [SwitchSummonPhase, this.startPhase], - [PartyHealPhase, this.startPhase], - [FormChangePhase, this.startPhase], - [EvolutionPhase, this.startPhase], - [EndEvolutionPhase, this.startPhase], - [LevelCapPhase, this.startPhase], - [AttemptRunPhase, this.startPhase], - [SelectBiomePhase, this.startPhase], - [MysteryEncounterPhase, this.startPhase], - [MysteryEncounterOptionSelectedPhase, this.startPhase], - [MysteryEncounterBattlePhase, this.startPhase], - [MysteryEncounterRewardsPhase, this.startPhase], - [PostMysteryEncounterPhase, this.startPhase], - [RibbonModifierRewardPhase, this.startPhase], - [GameOverModifierRewardPhase, this.startPhase], - [ModifierRewardPhase, this.startPhase], - [PartyExpPhase, this.startPhase], - [ExpPhase, this.startPhase], - [EncounterPhase, this.startPhase], - [GameOverPhase, this.startPhase], - [UnlockPhase, this.startPhase], - [PostGameOverPhase, this.startPhase], - [RevivalBlessingPhase, this.startPhase], - ]; - - private endBySetMode = [ - TitlePhase, - SelectGenderPhase, - CommandPhase, - SelectModifierPhase, - MysteryEncounterPhase, - PostMysteryEncounterPhase, - ]; + private scene: BattleScene; + /** A log of phases having been executed. */ + public log: PhaseString[] = []; + private promptInterval: NodeJS.Timeout; + private intervalRun: NodeJS.Timeout; + // TODO: Move prompts to a separate class + private prompts: PromptHandler[] = []; /** * Constructor to initialize the scene and properties, and to start the phase handling. * @param scene - The scene to be managed. */ - constructor(scene) { + constructor(scene: BattleScene) { this.scene = scene; - this.onHold = []; - this.prompts = []; - this.clearLogs(); + this.initMocks(); this.startPromptHandler(); - this.initPhases(); } /** @@ -188,264 +53,148 @@ export default class PhaseInterceptor { this.log = []; } - rejectAll(error) { - if (this.inProgress) { - clearInterval(this.promptInterval); - clearInterval(this.interval); - clearInterval(this.intervalRun); - this.inProgress.onError(error); - } - } - /** - * Method to set the starting phase. - * @param phaseFrom - The phase to start from. - * @returns The instance of the PhaseInterceptor. + * Method to initialize various mocks for intercepting phases. */ - runFrom(phaseFrom: PhaseInterceptorPhase): PhaseInterceptor { - this.phaseFrom = phaseFrom; - return this; - } + initMocks() { + const originalSetMode = UI.prototype.setMode; + vi.spyOn(UI.prototype, "setMode").mockImplementation((mode, ...args) => + this.setMode(originalSetMode, mode, ...args), + ); - /** - * Method to transition to a target phase. - * @param phaseTo - The phase to transition to. - * @param runTarget - Whether or not to run the target phase; default `true`. - * @returns A promise that resolves when the transition is complete. - */ - async to(phaseTo: PhaseInterceptorPhase, runTarget = true): Promise { - return new Promise(async (resolve, reject) => { - ErrorInterceptor.getInstance().add(this); - if (this.phaseFrom) { - await this.run(this.phaseFrom).catch(e => reject(e)); - this.phaseFrom = null; - } - const targetName = typeof phaseTo === "string" ? phaseTo : phaseTo.name; - this.intervalRun = setInterval(async () => { - const currentPhase = this.onHold?.length && this.onHold[0]; - if (currentPhase && currentPhase.name === targetName) { - clearInterval(this.intervalRun); - if (!runTarget) { - return resolve(); - } - await this.run(currentPhase).catch(e => { - clearInterval(this.intervalRun); - return reject(e); - }); - return resolve(); - } - if (currentPhase && currentPhase.name !== targetName) { - await this.run(currentPhase).catch(e => { - clearInterval(this.intervalRun); - return reject(e); - }); - } - }); - }); - } - - /** - * Method to run a phase with an optional skip function. - * @param phaseTarget - The phase to run. - * @param skipFn - Optional skip function. - * @returns A promise that resolves when the phase is run. - */ - run(phaseTarget: PhaseInterceptorPhase, skipFn?: (className: PhaseClass) => boolean): Promise { - const targetName = typeof phaseTarget === "string" ? phaseTarget : phaseTarget.name; - this.scene.moveAnimations = null; // Mandatory to avoid crash - return new Promise(async (resolve, reject) => { - ErrorInterceptor.getInstance().add(this); - const interval = setInterval(async () => { - const currentPhase = this.onHold.shift(); - if (currentPhase) { - if (currentPhase.name !== targetName) { - clearInterval(interval); - const skip = skipFn?.(currentPhase.name); - if (skip) { - this.onHold.unshift(currentPhase); - ErrorInterceptor.getInstance().remove(this); - return resolve(); - } - clearInterval(interval); - return reject(`Wrong phase: this is ${currentPhase.name} and not ${targetName}`); - } - clearInterval(interval); - this.inProgress = { - name: currentPhase.name, - callback: () => { - ErrorInterceptor.getInstance().remove(this); - resolve(); - }, - onError: error => reject(error), - }; - currentPhase.call(); - } - }); - }); - } - - whenAboutToRun(phaseTarget: PhaseInterceptorPhase, _skipFn?: (className: PhaseClass) => boolean): Promise { - const targetName = typeof phaseTarget === "string" ? phaseTarget : phaseTarget.name; - this.scene.moveAnimations = null; // Mandatory to avoid crash - return new Promise(async (resolve, _reject) => { - ErrorInterceptor.getInstance().add(this); - const interval = setInterval(async () => { - const currentPhase = this.onHold[0]; - if (currentPhase?.name === targetName) { - clearInterval(interval); - resolve(); - } - }); - }); - } - - pop() { - this.onHold.pop(); - this.scene.phaseManager.shiftPhase(); - } - - /** - * Remove the current phase from the phase interceptor. - * - * Do not call this unless absolutely necessary. This function is intended - * for cleaning up the phase interceptor when, for whatever reason, a phase - * is manually ended without using the phase interceptor. - * - * @param shouldRun Whether or not the current scene should also be run. - */ - shift(shouldRun = false): void { - this.onHold.shift(); - if (shouldRun) { - this.scene.phaseManager.shiftPhase(); - } - } - - /** - * Method to initialize phases and their corresponding methods. - */ - initPhases() { - this.originalSetMode = UI.prototype.setMode; - this.originalSetOverlayMode = UI.prototype.setOverlayMode; - this.originalSuperEnd = Phase.prototype.end; - UI.prototype.setMode = (mode, ...args) => this.setMode.call(this, mode, ...args); - Phase.prototype.end = () => this.superEndPhase.call(this); - for (const [phase, methodStart] of this.PHASES) { - const originalStart = phase.prototype.start; - this.phases[phase.name] = { - start: originalStart, - endBySetMode: this.endBySetMode.some(elm => elm.name === phase.name), - }; - phase.prototype.start = () => methodStart.call(this, phase); - } - } - - /** - * Method to start a phase and log it. - * @param phase - The phase to start. - */ - startPhase(phase: PhaseClass) { - this.log.push(phase.name); - const instance = this.scene.phaseManager.getCurrentPhase(); - this.onHold.push({ - name: phase.name, - call: () => { - this.phases[phase.name].start.apply(instance); - }, - }); - } - - unlock() { - this.inProgress?.callback(); - this.inProgress = undefined; - } - - /** - * Method to end a phase and log it. - * @param phase - The phase to start. - */ - superEndPhase() { - const instance = this.scene.phaseManager.getCurrentPhase(); - this.originalSuperEnd.apply(instance); - this.inProgress?.callback(); - this.inProgress = undefined; - } - - /** - * m2m to set mode. - * @param mode - The {@linkcode UiMode} to set. - * @param args - Additional arguments to pass to the original method. - */ - setMode(mode: UiMode, ...args: unknown[]): Promise { - const currentPhase = this.scene.phaseManager.getCurrentPhase(); - const instance = this.scene.ui; - console.log("setMode", `${UiMode[mode]} (=${mode})`, args); - const ret = this.originalSetMode.apply(instance, [mode, ...args]); - if (!this.phases[currentPhase.constructor.name]) { - throw new Error( - `missing ${currentPhase.constructor.name} in phaseInterceptor PHASES list --- Add it to PHASES inside of /test/utils/phaseInterceptor.ts`, - ); - } - if (this.phases[currentPhase.constructor.name].endBySetMode) { - this.inProgress?.callback(); - this.inProgress = undefined; - } - return ret; - } - - /** - * mock to set overlay mode - * @param mode - The {@linkcode Mode} to set. - * @param args - Additional arguments to pass to the original method. - */ - setOverlayMode(mode: UiMode, ...args: unknown[]): Promise { - const instance = this.scene.ui; - console.log("setOverlayMode", `${UiMode[mode]} (=${mode})`, args); - const ret = this.originalSetOverlayMode.apply(instance, [mode, ...args]); - return ret; + // Mock the private startCurrentPhase method to do nothing to let us + // handle starting phases manually in the `run` method. + vi.fn(this.scene.phaseManager["startCurrentPhase"]).mockImplementation(() => {}); } /** * Method to start the prompt handler. */ - startPromptHandler() { + private startPromptHandler() { this.promptInterval = setInterval(() => { - if (this.prompts.length) { - const actionForNextPrompt = this.prompts[0]; - const expireFn = actionForNextPrompt.expireFn?.(); - const currentMode = this.scene.ui.getMode(); - const currentPhase = this.scene.phaseManager.getCurrentPhase()?.constructor.name; - const currentHandler = this.scene.ui.getHandler(); - if (expireFn) { - this.prompts.shift(); - } else if ( - currentMode === actionForNextPrompt.mode && - currentPhase === actionForNextPrompt.phaseTarget && - currentHandler.active && - (!actionForNextPrompt.awaitingActionInput || - (actionForNextPrompt.awaitingActionInput && currentHandler.awaitingActionInput)) - ) { - const prompt = this.prompts.shift(); - if (prompt?.callback) { - prompt.callback(); - } + const actionForNextPrompt = this.prompts[0] as PromptHandler | undefined; + if (!actionForNextPrompt) { + return; + } + const expireFn = actionForNextPrompt.expireFn?.(); + const currentMode = this.scene.ui.getMode(); + const currentPhase = this.scene.phaseManager.getCurrentPhase()?.phaseName; + const currentHandler = this.scene.ui.getHandler(); + if (expireFn) { + this.prompts.shift(); + } else if ( + currentMode === actionForNextPrompt.mode && + currentPhase === actionForNextPrompt.phaseTarget && + currentHandler.active && + (!actionForNextPrompt.awaitingActionInput || currentHandler["awaitingActionInput"]) + ) { + const prompt = this.prompts.shift(); + if (prompt?.callback) { + prompt.callback(); } } }); } + /** + * Method to log the start of a phase. + * @param phaseName - The name of the phase to log. + */ + private logPhase(phaseName: PhaseString) { + // Exclude normal green highlighting due to issues with consoles + console.log(`Start Phase ${phaseName}`); + this.log.push(phaseName); + } + + /** + * Method to transition to a target phase. + * @param targetPhase - The name of the phase to transition to. + * @param runTarget - Whether or not to run the target phase; default `true`. + * @returns A promise that resolves when the transition is complete. + */ + public async to(targetPhase: PhaseString, runTarget = true): Promise { + this.intervalRun = setInterval(async () => { + const currentPhase = this.scene.phaseManager.getCurrentPhase(); + if (!currentPhase) { + console.log("No phases left to run; resolving."); + return; + } + + if (!currentPhase.is(targetPhase)) { + // Current phase is different; run and wait for it to finish + await this.run(currentPhase); + return; + } + + // target phase reached; run as applicable and resolve + clearInterval(this.intervalRun); + if (!runTarget) { + console.log(`PhaseInterceptor.to: Stopping on run of ${targetPhase}`); + this.scene.phaseManager.unshiftPhase(currentPhase); + return; + } + await this.run(currentPhase); + return; + }); + } + + /** + * Method to run a phase with an optional skip function. + * @param phaseTarget - The {@linkcode Phase} to run. + * @returns A Promise that resolves when the phase is run. + */ + private async run(phaseTarget: Phase): Promise { + const currentPhase = this.scene.phaseManager.getCurrentPhase(); + if (!currentPhase?.is(phaseTarget.phaseName)) { + throw new Error( + `Wrong phase passed to PhaseInterceptor.run;\nthis is ${currentPhase?.phaseName} and not ${phaseTarget.phaseName}`, + ); + } + + try { + this.logPhase(currentPhase.phaseName); + currentPhase.start(); + } catch (error: unknown) { + throw error instanceof Error + ? error + : new Error(`Unknown error ${error} occurred while running phase ${currentPhase?.phaseName}!`); + } + } + + /** Alias for {@linkcode PhaseManager.shiftPhase()} */ + shiftPhase() { + return this.scene.phaseManager.shiftPhase(); + } + + /** + * Method to set mode. + * @param originalSetMode - The original setMode method from the UI. + * @param mode - The {@linkcode UiMode} to set. + * @param args - Additional arguments to pass to the original method. + */ + private async setMode(originalSetMode: typeof UI.prototype.setMode, mode: UiMode, ...args: unknown[]): Promise { + const currentPhase = this.scene.phaseManager.getCurrentPhase(); + console.log("setMode", `${UiMode[mode]} (=${mode})`, args); + const ret = originalSetMode.apply(this.scene.ui, [mode, ...args]); + if (currentPhase && endBySetMode.has(currentPhase.phaseName)) { + await this.run(currentPhase); + } + return ret; + } + /** * Method to add an action to the next prompt. * @param phaseTarget - The target phase for the prompt. * @param mode - The mode of the UI. * @param callback - The callback function to execute. * @param expireFn - The function to determine if the prompt has expired. - * @param awaitingActionInput - ???; default `false` + * @param awaitingActionInput */ addToNextPrompt( - phaseTarget: string, + phaseTarget: PhaseString, mode: UiMode, callback: () => void, - expireFn?: () => void, + expireFn?: () => boolean, awaitingActionInput = false, ) { this.prompts.push({ @@ -459,19 +208,9 @@ export default class PhaseInterceptor { /** * Restores the original state of phases and clears intervals. - * - * This function iterates through all phases and resets their `start` method to the original - * function stored in `this.phases`. Additionally, it clears the `promptInterval` and `interval`. */ restoreOg() { - for (const [phase] of this.PHASES) { - phase.prototype.start = this.phases[phase.name].start; - } - UI.prototype.setMode = this.originalSetMode; - UI.prototype.setOverlayMode = this.originalSetOverlayMode; - Phase.prototype.end = this.originalSuperEnd; clearInterval(this.promptInterval); - clearInterval(this.interval); clearInterval(this.intervalRun); } } diff --git a/test/vitest.setup.ts b/test/vitest.setup.ts index 93b439e540f..f6d49100ef3 100644 --- a/test/vitest.setup.ts +++ b/test/vitest.setup.ts @@ -49,8 +49,6 @@ vi.mock("i18next", async importOriginal => { return await importOriginal(); }); -global.testFailed = false; - beforeAll(() => { initTestFile(); }); diff --git a/tsconfig.json b/tsconfig.json index 6af3e9ce650..dce71e23536 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,6 +13,7 @@ "paths": { "#enums/*": ["./enums/*.ts"], "#app/*": ["*.ts"], + "#phases/*": ["../src/phases/*.ts"], "#test/*": ["../test/*.ts"] }, "outDir": "./build", From 3ab2fe83a52278b8a236e46acd818ed1a09edff4 Mon Sep 17 00:00:00 2001 From: Bertie690 Date: Wed, 18 Jun 2025 18:25:05 -0400 Subject: [PATCH 2/9] Cleaned up a few phase files to call `super.start` --- src/phase-manager.ts | 73 ++++++++++++------- src/phase.ts | 2 + src/phases/check-status-effect-phase.ts | 4 +- src/phases/common-anim-phase.ts | 1 + src/phases/money-reward-phase.ts | 1 + src/phases/obtain-status-effect-phase.ts | 2 + src/phases/pokemon-heal-phase.ts | 5 +- .../post-summon-activate-ability-phase.ts | 2 + src/phases/post-turn-status-effect-phase.ts | 2 + src/phases/stat-stage-change-phase.ts | 1 + src/phases/trainer-victory-phase.ts | 2 + src/phases/weather-effect-phase.ts | 1 + 12 files changed, 66 insertions(+), 30 deletions(-) diff --git a/src/phase-manager.ts b/src/phase-manager.ts index 9390e6dd75d..c59bd42eea6 100644 --- a/src/phase-manager.ts +++ b/src/phase-manager.ts @@ -217,13 +217,28 @@ export type PhaseConstructorMap = typeof PHASES; * PhaseManager is responsible for managing the phases in the battle scene */ export class PhaseManager { - /** PhaseQueue: dequeue/remove the first element to get the next phase */ + /** + * A queue of yet-unexecuted {@linkcode Phase}s to be run. \ + * Each time the current phase ends, all phases from {@linkcode phaseQueuePrepend} are added + * to the front of this queue and the next phase is started. + */ public phaseQueue: Phase[] = []; - public conditionalQueue: Array<[() => boolean, Phase]> = []; - /** PhaseQueuePrepend: is a temp storage of what will be added to PhaseQueue */ + /** + * A queue of yet-unexecuted {@linkcode Phase}s with conditions for their execution. \ + * Each entry is evaluated whenever a new phase starts, being added to the {@linkcode phaseQueue} if the condition is satisfied. + * + */ + public conditionalQueue: Array<[condition: () => boolean, phase: Phase]> = []; + /** A temporary storage of {@linkcode Phase}s */ private phaseQueuePrepend: Phase[] = []; - /** overrides default of inserting phases to end of phaseQueuePrepend array. Useful for inserting Phases "out of order" */ + /** + * If set, will cause subsequent calls to {@linkcode unshiftPhase} to insert at this index in **LIFO** order. + * Useful for inserting Phases "out of order". + * + * Is cleared whenever a phase ends, or when {@linkcode clearPhaseQueueSplice} is called. + * @defaultValue `-1` + */ private phaseQueuePrependSpliceIndex = -1; private nextCommandPhaseQueue: Phase[] = []; @@ -238,9 +253,14 @@ export class PhaseManager { constructor() { this.dynamicPhaseQueues = [new PostSummonPhasePriorityQueue()]; this.dynamicPhaseTypes = [PostSummonPhase]; - } + } /* Phase Functions */ - /* Phase Functions */ + /** + * Getter function to return the currently-in-progess {@linkcode Phase}. + * @returns The current Phase, or `null` if no phase is currently active. + * @remarks + * Type narrowing can be done by the caller using {@linkcode Phase.is}. + */ getCurrentPhase(): Phase | null { return this.currentPhase; } @@ -255,18 +275,17 @@ export class PhaseManager { * This method allows deferring the execution of a phase until certain conditions are met, which is useful for handling * situations like abilities and entry hazards that depend on specific game states. * - * @param phase - The phase to be added to the conditional queue. + * @param phase - The {@linkcode Phase} to add to the conditional queue. * @param condition - A function that returns a boolean indicating whether the phase should be executed. - * */ pushConditionalPhase(phase: Phase, condition: () => boolean): void { this.conditionalQueue.push([condition, phase]); } /** - * Adds a phase to nextCommandPhaseQueue, as long as boolean passed in is false - * @param phase {@linkcode Phase} the phase to add - * @param defer boolean on which queue to add to, defaults to false, and adds to phaseQueue + * Add a phase to the end of the {@linkcode phaseQueue}. + * @param phase - The {@linkcode Phase} to be queued. + * @param defer If `true`, will add the phase to {@linkcode nextCommandPhaseQueue} instead of the normal {@linkcode phaseQueue}; default `false`. */ pushPhase(phase: Phase, defer = false): void { if (this.getDynamicPhaseType(phase) !== undefined) { @@ -277,8 +296,13 @@ export class PhaseManager { } /** - * Adds Phase(s) to the end of phaseQueuePrepend, or at phaseQueuePrependSpliceIndex - * @param phases {@linkcode Phase} the phase(s) to add + * Adds one or more phase(s) to the **END** of {@linkcode phaseQueuePrepend}. + * If called multiple times, phases will be ran in **FIFO** order. + * @param phases - One or more {@linkcode Phase}s to add. + * @todo Find a better name for this given that "unshift" implies adding to the front. + * @remarks + * If {@linkcode phaseQueuePrependSpliceIndex} is set, the phases will be inserted at that index + * in **LIFO** order. */ unshiftPhase(...phases: Phase[]): void { if (this.phaseQueuePrependSpliceIndex === -1) { @@ -337,14 +361,8 @@ export class PhaseManager { if (this.phaseQueuePrependSpliceIndex > -1) { this.clearPhaseQueueSplice(); } - if (this.phaseQueuePrepend.length) { - while (this.phaseQueuePrepend.length) { - const poppedPhase = this.phaseQueuePrepend.pop(); - if (poppedPhase) { - this.phaseQueue.unshift(poppedPhase); - } - } - } + this.phaseQueue.unshift(...this.phaseQueuePrepend); + if (!this.phaseQueue.length) { this.populatePhaseQueue(); // Clear the conditionalQueue if there are no phases left in the phaseQueue @@ -370,11 +388,15 @@ export class PhaseManager { } } this.conditionalQueue.push(...unactivatedConditionalPhases); + this.startCurrentPhase(); + } - if (this.currentPhase) { - console.log(`%cStart Phase ${this.currentPhase.constructor.name}`, "color:green;"); - this.currentPhase.start(); + private startCurrentPhase(): void { + if (!this.currentPhase) { + return; } + console.log(`%cStart Phase ${this.currentPhase.phaseName}`, "color:green;"); + this.currentPhase.start(); } overridePhase(phase: Phase): boolean { @@ -384,8 +406,7 @@ export class PhaseManager { this.standbyPhase = this.currentPhase; this.currentPhase = phase; - console.log(`%cStart Phase ${phase.constructor.name}`, "color:green;"); - phase.start(); + this.startCurrentPhase(); return true; } diff --git a/src/phase.ts b/src/phase.ts index 5e81679d29e..54c439b6644 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/src/phases/check-status-effect-phase.ts b/src/phases/check-status-effect-phase.ts index 43495e038e9..45b600ff09e 100644 --- a/src/phases/check-status-effect-phase.ts +++ b/src/phases/check-status-effect-phase.ts @@ -11,12 +11,14 @@ export class CheckStatusEffectPhase extends Phase { } start() { + super.start(); + const field = globalScene.getField(); for (const o of this.order) { if (field[o].status?.isPostTurn()) { globalScene.phaseManager.unshiftNew("PostTurnStatusEffectPhase", o); } } - this.end(); + super.end(); } } diff --git a/src/phases/common-anim-phase.ts b/src/phases/common-anim-phase.ts index abfe8ed99f0..f4a9afc3587 100644 --- a/src/phases/common-anim-phase.ts +++ b/src/phases/common-anim-phase.ts @@ -30,6 +30,7 @@ export class CommonAnimPhase extends PokemonPhase { } start() { + super.start(); const target = this.targetIndex !== undefined ? (this.player ? globalScene.getEnemyField() : globalScene.getPlayerField())[this.targetIndex] diff --git a/src/phases/money-reward-phase.ts b/src/phases/money-reward-phase.ts index 52cb9ecb3ff..c3ebc5a864d 100644 --- a/src/phases/money-reward-phase.ts +++ b/src/phases/money-reward-phase.ts @@ -16,6 +16,7 @@ export class MoneyRewardPhase extends BattlePhase { } start() { + super.start(); const moneyAmount = new NumberHolder(globalScene.getWaveMoneyAmount(this.moneyMultiplier)); globalScene.applyModifiers(MoneyMultiplierModifier, true, moneyAmount); diff --git a/src/phases/obtain-status-effect-phase.ts b/src/phases/obtain-status-effect-phase.ts index dc26d070029..d26bad2ed10 100644 --- a/src/phases/obtain-status-effect-phase.ts +++ b/src/phases/obtain-status-effect-phase.ts @@ -34,6 +34,8 @@ export class ObtainStatusEffectPhase extends PokemonPhase { } start() { + super.start(); + const pokemon = this.getPokemon(); if (pokemon && !pokemon.status) { if (pokemon.trySetStatus(this.statusEffect, false, this.sourcePokemon)) { diff --git a/src/phases/pokemon-heal-phase.ts b/src/phases/pokemon-heal-phase.ts index cf6cf40a923..5f263ed2a7b 100644 --- a/src/phases/pokemon-heal-phase.ts +++ b/src/phases/pokemon-heal-phase.ts @@ -48,9 +48,8 @@ export class PokemonHealPhase extends CommonAnimPhase { } start() { - if (!this.skipAnim && (this.revive || this.getPokemon().hp) && !this.getPokemon().isFullHp()) { - super.start(); - } else { + super.start(); + if (!(this.skipAnim && (this.revive || this.getPokemon().hp) && !this.getPokemon().isFullHp())) { this.end(); } } diff --git a/src/phases/post-summon-activate-ability-phase.ts b/src/phases/post-summon-activate-ability-phase.ts index ba6c80d4ee0..e647695cef5 100644 --- a/src/phases/post-summon-activate-ability-phase.ts +++ b/src/phases/post-summon-activate-ability-phase.ts @@ -16,6 +16,8 @@ export class PostSummonActivateAbilityPhase extends PostSummonPhase { } start() { + super.start(); + applyPostSummonAbAttrs("PostSummonAbAttr", this.getPokemon(), this.passive, false); this.end(); diff --git a/src/phases/post-turn-status-effect-phase.ts b/src/phases/post-turn-status-effect-phase.ts index e0a3bb5c00b..fa5f3f8b204 100644 --- a/src/phases/post-turn-status-effect-phase.ts +++ b/src/phases/post-turn-status-effect-phase.ts @@ -18,6 +18,8 @@ export class PostTurnStatusEffectPhase extends PokemonPhase { } start() { + super.start(); + const pokemon = this.getPokemon(); if (pokemon?.isActive(true) && pokemon.status && pokemon.status.isPostTurn() && !pokemon.switchOutStatus) { pokemon.status.incrementTurn(); diff --git a/src/phases/stat-stage-change-phase.ts b/src/phases/stat-stage-change-phase.ts index e73f72f7a63..2398834b388 100644 --- a/src/phases/stat-stage-change-phase.ts +++ b/src/phases/stat-stage-change-phase.ts @@ -83,6 +83,7 @@ export class StatStageChangePhase extends PokemonPhase { return this.end(); } + super.start(); const pokemon = this.getPokemon(); let opponentPokemon: Pokemon | undefined; diff --git a/src/phases/trainer-victory-phase.ts b/src/phases/trainer-victory-phase.ts index 554b8109f02..5830fbde673 100644 --- a/src/phases/trainer-victory-phase.ts +++ b/src/phases/trainer-victory-phase.ts @@ -14,6 +14,8 @@ import { timedEventManager } from "#app/global-event-manager"; export class TrainerVictoryPhase extends BattlePhase { public readonly phaseName = "TrainerVictoryPhase"; start() { + super.start(); + globalScene.disableMenu = true; globalScene.playBgm(globalScene.currentBattle.trainer?.config.victoryBgm); diff --git a/src/phases/weather-effect-phase.ts b/src/phases/weather-effect-phase.ts index d9239220376..d609b1feccb 100644 --- a/src/phases/weather-effect-phase.ts +++ b/src/phases/weather-effect-phase.ts @@ -28,6 +28,7 @@ export class WeatherEffectPhase extends CommonAnimPhase { } start() { + super.start(); // Update weather state with any changes that occurred during the turn this.weather = globalScene?.arena?.weather; From 194ced277b3a87bc817878e5976e5af05059c599 Mon Sep 17 00:00:00 2001 From: Bertie690 Date: Wed, 18 Jun 2025 18:58:16 -0400 Subject: [PATCH 3/9] Enforced use of `PhaseString`s inside `to`; removed `run` from public use --- test/abilities/battery.test.ts | 8 +- test/abilities/competitive.test.ts | 7 +- test/abilities/costar.test.ts | 12 +- test/abilities/defiant.test.ts | 7 +- test/abilities/flash_fire.test.ts | 22 ++-- test/abilities/flower_gift.test.ts | 5 +- test/abilities/forecast.test.ts | 17 +-- test/abilities/heatproof.test.ts | 5 +- test/abilities/ice_face.test.ts | 43 +++--- test/abilities/imposter.test.ts | 7 +- test/abilities/intimidate.test.ts | 3 +- test/abilities/intrepid_sword.test.ts | 3 +- test/abilities/libero.test.ts | 35 +++-- test/abilities/magic_guard.test.ts | 39 +++--- test/abilities/moxie.test.ts | 7 +- test/abilities/mycelium_might.test.ts | 13 +- test/abilities/no_guard.test.ts | 7 +- test/abilities/pastel_veil.test.ts | 10 +- test/abilities/power_construct.test.ts | 10 +- test/abilities/power_spot.test.ts | 8 +- test/abilities/protean.test.ts | 35 +++-- test/abilities/quick_draw.test.ts | 7 +- test/abilities/sand_veil.test.ts | 9 +- test/abilities/sap_sipper.test.ts | 16 +-- test/abilities/schooling.test.ts | 6 +- test/abilities/screen_cleaner.test.ts | 14 +- test/abilities/shield_dust.test.ts | 4 +- test/abilities/shields_down.test.ts | 20 ++- test/abilities/speed_boost.test.ts | 4 +- test/abilities/stall.test.ts | 8 +- test/abilities/sturdy.test.ts | 10 +- test/abilities/supreme_overlord.test.ts | 5 +- test/abilities/sweet_veil.test.ts | 10 +- test/abilities/unseen_fist.test.ts | 6 +- test/abilities/victory_star.test.ts | 5 +- test/abilities/volt_absorb.test.ts | 3 +- test/abilities/wind_power.test.ts | 9 +- test/abilities/wonder_skin.test.ts | 7 +- test/abilities/zero_to_hero.test.ts | 10 +- test/arena/weather_fog.test.ts | 3 +- test/arena/weather_strong_winds.test.ts | 9 +- test/battle/battle-order.test.ts | 14 +- test/battle/battle.test.ts | 123 +----------------- test/battle/double_battle.test.ts | 6 +- test/escape-calculations.test.ts | 10 +- test/items/dire_hit.test.ts | 9 +- test/items/leek.test.ts | 13 +- test/items/leftovers.test.ts | 6 +- test/items/scope_lens.test.ts | 3 +- test/items/temp_stat_stage_booster.test.ts | 13 +- test/moves/after_you.test.ts | 6 +- test/moves/alluring_voice.test.ts | 3 +- test/moves/aromatherapy.test.ts | 7 +- test/moves/assist.test.ts | 5 +- test/moves/astonish.test.ts | 12 +- test/moves/aurora_veil.test.ts | 13 +- test/moves/beak_blast.test.ts | 21 ++- test/moves/beat_up.test.ts | 7 +- test/moves/belly_drum.test.ts | 9 +- test/moves/ceaseless_edge.test.ts | 14 +- test/moves/clangorous_soul.test.ts | 9 +- test/moves/crafty_shield.test.ts | 18 ++- test/moves/double_team.test.ts | 3 +- test/moves/dragon_rage.test.ts | 13 +- test/moves/dynamax_cannon.test.ts | 35 +++-- test/moves/fillet_away.test.ts | 9 +- test/moves/fissure.test.ts | 8 +- test/moves/flame_burst.test.ts | 9 +- test/moves/flower_shield.test.ts | 9 +- test/moves/focus_punch.test.ts | 17 +-- test/moves/follow_me.test.ts | 9 +- test/moves/foresight.test.ts | 5 +- test/moves/freezy_frost.test.ts | 5 +- test/moves/fusion_flare.test.ts | 3 +- test/moves/fusion_flare_bolt.test.ts | 85 ++++++------ test/moves/growth.test.ts | 4 +- test/moves/guard_split.test.ts | 7 +- test/moves/guard_swap.test.ts | 6 +- test/moves/hard_press.test.ts | 9 +- test/moves/haze.test.ts | 7 +- test/moves/heal_bell.test.ts | 7 +- test/moves/heart_swap.test.ts | 6 +- test/moves/hyper_beam.test.ts | 8 +- test/moves/jaw_lock.test.ts | 24 ++-- test/moves/last_respects.test.ts | 5 +- test/moves/light_screen.test.ts | 9 +- test/moves/lunar_blessing.test.ts | 5 +- test/moves/lunar_dance.test.ts | 7 +- test/moves/magnet_rise.test.ts | 8 +- test/moves/make_it_rain.test.ts | 10 +- test/moves/mat_block.test.ts | 21 ++- test/moves/metronome.test.ts | 3 +- test/moves/miracle_eye.test.ts | 3 +- test/moves/parting_shot.test.ts | 65 +++------ test/moves/powder.test.ts | 29 ++--- test/moves/power_split.test.ts | 7 +- test/moves/power_swap.test.ts | 6 +- test/moves/power_trick.test.ts | 11 +- test/moves/purify.test.ts | 5 +- test/moves/reflect.test.ts | 11 +- test/moves/rollout.test.ts | 3 +- test/moves/roost.test.ts | 38 +++--- test/moves/scale_shot.test.ts | 14 +- test/moves/shell_trap.test.ts | 20 ++- test/moves/sparkly_swirl.test.ts | 5 +- test/moves/spectral_thief.test.ts | 19 ++- test/moves/speed_swap.test.ts | 3 +- test/moves/spit_up.test.ts | 16 +-- test/moves/spotlight.test.ts | 3 +- test/moves/stockpile.test.ts | 12 +- test/moves/swallow.test.ts | 16 +-- test/moves/tackle.test.ts | 6 +- test/moves/tail_whip.test.ts | 4 +- test/moves/thousand_arrows.test.ts | 12 +- test/moves/tidy_up.test.ts | 24 ++-- test/moves/torment.test.ts | 3 +- test/moves/transform.test.ts | 7 +- test/moves/wide_guard.test.ts | 18 ++- .../mystery-encounter/encounter-test-utils.ts | 11 +- .../a-trainers-test-encounter.test.ts | 4 +- .../absolute-avarice-encounter.test.ts | 2 +- ...an-offer-you-cant-refuse-encounter.test.ts | 5 +- .../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 +- .../encounters/delibirdy-encounter.test.ts | 6 +- .../department-store-sale-encounter.test.ts | 8 +- .../encounters/field-trip-encounter.test.ts | 13 +- .../fiery-fallout-encounter.test.ts | 6 +- .../fight-or-flight-encounter.test.ts | 10 +- .../fun-and-games-encounter.test.ts | 24 ++-- .../global-trade-system-encounter.test.ts | 2 +- .../encounters/lost-at-sea-encounter.test.ts | 9 +- .../mysterious-challengers-encounter.test.ts | 12 +- .../encounters/part-timer-encounter.test.ts | 2 +- .../encounters/safari-zone.test.ts | 2 +- .../teleporting-hijinks-encounter.test.ts | 8 +- .../the-expert-breeder-encounter.test.ts | 13 +- .../the-pokemon-salesman-encounter.test.ts | 2 +- .../the-strong-stuff-encounter.test.ts | 4 +- .../the-winstrate-challenge-encounter.test.ts | 11 +- .../trash-to-treasure-encounter.test.ts | 6 +- .../uncommon-breed-encounter.test.ts | 4 +- .../encounters/weird-dream-encounter.test.ts | 10 +- .../mystery-encounter.test.ts | 2 +- test/phases/learn-move-phase.test.ts | 7 +- test/phases/mystery-encounter-phase.test.ts | 8 +- test/phases/phases.test.ts | 6 +- test/phases/select-modifier-phase.test.ts | 6 +- test/testUtils/gameManager.ts | 11 +- test/testUtils/helpers/challengeModeHelper.ts | 2 +- test/testUtils/helpers/classicModeHelper.ts | 4 +- test/testUtils/helpers/dailyModeHelper.ts | 5 +- test/testUtils/helpers/moveHelper.ts | 6 +- test/testUtils/helpers/reloadHelper.ts | 2 +- test/ui/battle_info.test.ts | 3 +- test/ui/starter-select.test.ts | 30 ++--- test/ui/type-hints.test.ts | 7 +- 159 files changed, 741 insertions(+), 1080 deletions(-) diff --git a/test/abilities/battery.test.ts b/test/abilities/battery.test.ts index db129e72b0b..cfcd39286a3 100644 --- a/test/abilities/battery.test.ts +++ b/test/abilities/battery.test.ts @@ -1,7 +1,5 @@ import { allMoves } from "#app/data/data-lists"; import { AbilityId } from "#enums/ability-id"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import GameManager from "#test/testUtils/gameManager"; @@ -44,7 +42,7 @@ describe("Abilities - Battery", () => { game.move.select(MoveId.DAZZLING_GLEAM); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower * batteryMultiplier); }); @@ -59,7 +57,7 @@ describe("Abilities - Battery", () => { game.move.select(MoveId.BREAKING_SWIPE); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower); }); @@ -74,7 +72,7 @@ describe("Abilities - Battery", () => { game.move.select(MoveId.DAZZLING_GLEAM); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower); }); diff --git a/test/abilities/competitive.test.ts b/test/abilities/competitive.test.ts index f12b06837dc..f0de1f53aa5 100644 --- a/test/abilities/competitive.test.ts +++ b/test/abilities/competitive.test.ts @@ -1,5 +1,4 @@ import { Stat } from "#enums/stat"; -import { TurnInitPhase } from "#app/phases/turn-init-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -38,7 +37,7 @@ describe("Abilities - Competitive", () => { const playerPokemon = game.scene.getPlayerPokemon()!; game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); expect(playerPokemon.getStatStage(Stat.ATK)).toBe(-1); expect(playerPokemon.getStatStage(Stat.DEF)).toBe(-1); @@ -51,7 +50,7 @@ describe("Abilities - Competitive", () => { const playerPokemon = game.scene.getPlayerPokemon()!; game.move.select(MoveId.CLOSE_COMBAT); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); expect(playerPokemon.getStatStage(Stat.SPDEF)).toBe(-1); expect(playerPokemon.getStatStage(Stat.DEF)).toBe(-1); @@ -64,7 +63,7 @@ describe("Abilities - Competitive", () => { const playerPokemon = game.scene.getPlayerPokemon()!; game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); expect(playerPokemon.getStatStage(Stat.ATK)).toBe(0); expect(playerPokemon.getStatStage(Stat.DEF)).toBe(0); diff --git a/test/abilities/costar.test.ts b/test/abilities/costar.test.ts index a40d84e72f5..873adb9de44 100644 --- a/test/abilities/costar.test.ts +++ b/test/abilities/costar.test.ts @@ -2,8 +2,6 @@ import { Stat } from "#enums/stat"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; -import { CommandPhase } from "#app/phases/command-phase"; -import { MessagePhase } from "#app/phases/message-phase"; import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; @@ -39,7 +37,7 @@ describe("Abilities - COSTAR", () => { let [leftPokemon, rightPokemon] = game.scene.getPlayerField(); game.move.select(MoveId.NASTY_PLOT); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SPLASH, 1); await game.toNextTurn(); @@ -47,9 +45,9 @@ describe("Abilities - COSTAR", () => { expect(rightPokemon.getStatStage(Stat.SPATK)).toBe(0); game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.doSwitchPokemon(2); - await game.phaseInterceptor.to(MessagePhase); + await game.phaseInterceptor.to("MessagePhase"); [leftPokemon, rightPokemon] = game.scene.getPlayerField(); expect(leftPokemon.getStatStage(Stat.SPATK)).toBe(2); @@ -67,9 +65,9 @@ describe("Abilities - COSTAR", () => { expect(leftPokemon.getStatStage(Stat.ATK)).toBe(-2); game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.doSwitchPokemon(2); - await game.phaseInterceptor.to(MessagePhase); + await game.phaseInterceptor.to("MessagePhase"); [leftPokemon, rightPokemon] = game.scene.getPlayerField(); expect(leftPokemon.getStatStage(Stat.ATK)).toBe(-2); diff --git a/test/abilities/defiant.test.ts b/test/abilities/defiant.test.ts index ef26b5bfca3..fae05575c0b 100644 --- a/test/abilities/defiant.test.ts +++ b/test/abilities/defiant.test.ts @@ -1,5 +1,4 @@ import { Stat } from "#enums/stat"; -import { TurnInitPhase } from "#app/phases/turn-init-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -38,7 +37,7 @@ describe("Abilities - Defiant", () => { const playerPokemon = game.scene.getPlayerPokemon()!; game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); expect(playerPokemon.getStatStage(Stat.ATK)).toBe(3); expect(playerPokemon.getStatStage(Stat.DEF)).toBe(-1); @@ -50,7 +49,7 @@ describe("Abilities - Defiant", () => { const playerPokemon = game.scene.getPlayerPokemon()!; game.move.select(MoveId.CLOSE_COMBAT); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); expect(playerPokemon.getStatStage(Stat.SPDEF)).toBe(-1); expect(playerPokemon.getStatStage(Stat.DEF)).toBe(-1); @@ -63,7 +62,7 @@ describe("Abilities - Defiant", () => { const playerPokemon = game.scene.getPlayerPokemon()!; game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); expect(playerPokemon.getStatStage(Stat.DEF)).toBe(0); expect(playerPokemon.getStatStage(Stat.ATK)).toBe(3); diff --git a/test/abilities/flash_fire.test.ts b/test/abilities/flash_fire.test.ts index 3be156a1578..261be75962d 100644 --- a/test/abilities/flash_fire.test.ts +++ b/test/abilities/flash_fire.test.ts @@ -1,8 +1,6 @@ import { BattlerIndex } from "#enums/battler-index"; import { BattlerTagType } from "#app/enums/battler-tag-type"; import { SpeciesId } from "#enums/species-id"; -import { MovePhase } from "#app/phases/move-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { StatusEffect } from "#enums/status-effect"; @@ -42,7 +40,7 @@ describe("Abilities - Flash Fire", () => { const blissey = game.scene.getPlayerPokemon()!; game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(blissey.hp).toBe(blissey.getMaxHp()); }); @@ -53,7 +51,7 @@ describe("Abilities - Flash Fire", () => { const blissey = game.scene.getPlayerPokemon()!; game.move.select(MoveId.PROTECT); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(blissey!.getTag(BattlerTagType.FIRE_BOOST)).toBeUndefined(); }); @@ -65,10 +63,10 @@ describe("Abilities - Flash Fire", () => { game.move.select(MoveId.SPLASH); await game.move.forceHit(); - await game.phaseInterceptor.to(MovePhase, false); + await game.phaseInterceptor.to("MovePhase", false); await game.move.forceHit(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(blissey!.getTag(BattlerTagType.FIRE_BOOST)).toBeDefined(); }); @@ -80,7 +78,7 @@ describe("Abilities - Flash Fire", () => { game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(blissey!.getTag(BattlerTagType.FIRE_BOOST)).toBeDefined(); }); @@ -94,7 +92,7 @@ describe("Abilities - Flash Fire", () => { game.doSelectPartyPokemon(1); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const chansey = game.scene.getPlayerPokemon()!; expect(game.scene.getPlayerPokemon()!.species.speciesId).toBe(SpeciesId.CHANSEY); expect(chansey!.getTag(BattlerTagType.FIRE_BOOST)).toBeUndefined(); @@ -114,7 +112,7 @@ describe("Abilities - Flash Fire", () => { // first turn game.move.select(MoveId.EMBER); await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const originalDmg = initialHP - blissey.hp; expect(blissey.hp > 0); @@ -122,7 +120,7 @@ describe("Abilities - Flash Fire", () => { // second turn game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const flashFireDmg = initialHP - blissey.hp; expect(flashFireDmg).toBeGreaterThan(originalDmg); @@ -146,7 +144,7 @@ describe("Abilities - Flash Fire", () => { await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.phaseInterceptor.to("MoveEffectPhase"); await game.move.forceMiss(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const originalDmg = initialHP - blissey.hp; expect(blissey.hp > 0); @@ -154,7 +152,7 @@ describe("Abilities - Flash Fire", () => { // second turn game.move.select(MoveId.FIRE_PLEDGE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const flashFireDmg = initialHP - blissey.hp; expect(flashFireDmg).toBeGreaterThan(originalDmg); diff --git a/test/abilities/flower_gift.test.ts b/test/abilities/flower_gift.test.ts index f072afe7f34..2477ddb90be 100644 --- a/test/abilities/flower_gift.test.ts +++ b/test/abilities/flower_gift.test.ts @@ -3,7 +3,6 @@ import { allAbilities } from "#app/data/data-lists"; import { AbilityId } from "#enums/ability-id"; import { Stat } from "#app/enums/stat"; import { WeatherType } from "#app/enums/weather-type"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import GameManager from "#test/testUtils/gameManager"; @@ -72,7 +71,7 @@ describe("Abilities - Flower Gift", () => { await game.move.selectEnemyMove(MoveId.SPLASH); // Ensure sunny day is used last. await game.setTurnOrder([attacker_index, target_index, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER]); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const damageWithoutGift = initialHp - target.hp; target.hp = initialHp; @@ -83,7 +82,7 @@ describe("Abilities - Flower Gift", () => { await game.move.selectEnemyMove(enemy_move, BattlerIndex.PLAYER_2); await game.move.selectEnemyMove(MoveId.SPLASH); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY_2, target_index, attacker_index]); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const damageWithGift = initialHp - target.hp; return [damageWithoutGift, damageWithGift]; diff --git a/test/abilities/forecast.test.ts b/test/abilities/forecast.test.ts index 9111766ebdf..4b14ae6ec02 100644 --- a/test/abilities/forecast.test.ts +++ b/test/abilities/forecast.test.ts @@ -2,11 +2,6 @@ import { BattlerIndex } from "#enums/battler-index"; import { allAbilities } from "#app/data/data-lists"; import { AbilityId } from "#enums/ability-id"; import { WeatherType } from "#app/enums/weather-type"; -import { DamageAnimPhase } from "#app/phases/damage-anim-phase"; -import { MovePhase } from "#app/phases/move-phase"; -import { PostSummonPhase } from "#app/phases/post-summon-phase"; -import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import GameManager from "#test/testUtils/gameManager"; @@ -184,7 +179,7 @@ describe("Abilities - Forecast", () => { await game.classicMode.startBattle([SpeciesId.CASTFORM]); game.move.select(MoveId.RAIN_DANCE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(game.scene.getPlayerPokemon()?.formIndex).toBe(RAINY_FORM); expect(game.scene.getEnemyPokemon()?.formIndex).not.toBe(RAINY_FORM); @@ -202,7 +197,7 @@ describe("Abilities - Forecast", () => { await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.move.forceHit(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(castform.summonData.abilitySuppressed).toBe(true); expect(castform.formIndex).toBe(NORMAL_FORM); @@ -215,7 +210,7 @@ describe("Abilities - Forecast", () => { // Third turn - switch in Castform game.doSwitchPokemon(1); - await game.phaseInterceptor.to(MovePhase); + await game.phaseInterceptor.to("MovePhase"); expect(castform.summonData.abilitySuppressed).toBe(false); expect(castform.formIndex).toBe(RAINY_FORM); @@ -231,16 +226,16 @@ describe("Abilities - Forecast", () => { // Second turn - switch in Castform, regains Forecast game.doSwitchPokemon(1); - await game.phaseInterceptor.to(PostSummonPhase); + await game.phaseInterceptor.to("PostSummonPhase"); const castform = game.scene.getPlayerPokemon()!; // Damage phase should come first - await game.phaseInterceptor.to(DamageAnimPhase); + await game.phaseInterceptor.to("DamageAnimPhase"); expect(castform.hp).toBeLessThan(castform.getMaxHp()); // Then change form - await game.phaseInterceptor.to(QuietFormChangePhase); + await game.phaseInterceptor.to("QuietFormChangePhase"); expect(castform.formIndex).toBe(RAINY_FORM); }); diff --git a/test/abilities/heatproof.test.ts b/test/abilities/heatproof.test.ts index 39c9dff8289..48b94b4fee5 100644 --- a/test/abilities/heatproof.test.ts +++ b/test/abilities/heatproof.test.ts @@ -1,6 +1,5 @@ import { SpeciesId } from "#enums/species-id"; import { StatusEffect } from "#app/enums/status-effect"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { toDmgValue } from "#app/utils/common"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; @@ -45,14 +44,14 @@ describe("Abilities - Heatproof", () => { enemy.hp = initialHP; game.move.select(MoveId.FLAMETHROWER); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const heatproofDamage = initialHP - enemy.hp; enemy.hp = initialHP; game.override.enemyAbility(AbilityId.BALL_FETCH); game.move.select(MoveId.FLAMETHROWER); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const regularDamage = initialHP - enemy.hp; expect(heatproofDamage).toBeLessThanOrEqual(regularDamage / 2 + 1); diff --git a/test/abilities/ice_face.test.ts b/test/abilities/ice_face.test.ts index c42713d7e6c..89577bd61aa 100644 --- a/test/abilities/ice_face.test.ts +++ b/test/abilities/ice_face.test.ts @@ -1,9 +1,4 @@ import { BattlerIndex } from "#enums/battler-index"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase"; -import { MoveEndPhase } from "#app/phases/move-end-phase"; -import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; -import { TurnInitPhase } from "#app/phases/turn-init-phase"; import { AbilityId } from "#enums/ability-id"; import { BattlerTagType } from "#enums/battler-tag-type"; import { MoveId } from "#enums/move-id"; @@ -42,7 +37,7 @@ describe("Abilities - Ice Face", () => { game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); const eiscue = game.scene.getEnemyPokemon()!; @@ -61,17 +56,17 @@ describe("Abilities - Ice Face", () => { expect(eiscue.getTag(BattlerTagType.ICE_FACE)).toBeDefined(); // First hit - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(eiscue.isFullHp()).toBe(true); expect(eiscue.formIndex).toBe(icefaceForm); expect(eiscue.getTag(BattlerTagType.ICE_FACE)).toBeUndefined(); // Second hit - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(eiscue.hp).lessThan(eiscue.getMaxHp()); expect(eiscue.formIndex).toBe(noiceForm); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); expect(eiscue.hp).lessThan(eiscue.getMaxHp()); expect(eiscue.formIndex).toBe(noiceForm); @@ -83,7 +78,7 @@ describe("Abilities - Ice Face", () => { game.move.select(MoveId.ICE_BEAM); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); const eiscue = game.scene.getEnemyPokemon()!; @@ -97,7 +92,7 @@ describe("Abilities - Ice Face", () => { game.move.select(MoveId.TOXIC_THREAD); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); const eiscue = game.scene.getEnemyPokemon()!; @@ -112,7 +107,7 @@ describe("Abilities - Ice Face", () => { game.move.select(MoveId.QUICK_ATTACK); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); const eiscue = game.scene.getEnemyPokemon()!; @@ -120,7 +115,7 @@ describe("Abilities - Ice Face", () => { expect(eiscue.formIndex).toBe(noiceForm); expect(eiscue.getTag(BattlerTagType.ICE_FACE)).toBeUndefined(); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); expect(eiscue.getTag(BattlerTagType.ICE_FACE)).not.toBeNull(); expect(eiscue.formIndex).toBe(icefaceForm); @@ -133,7 +128,7 @@ describe("Abilities - Ice Face", () => { game.move.select(MoveId.SNOWSCAPE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); let eiscue = game.scene.getPlayerPokemon()!; expect(eiscue.getTag(BattlerTagType.ICE_FACE)).toBeUndefined(); @@ -145,7 +140,7 @@ describe("Abilities - Ice Face", () => { await game.toNextTurn(); game.doSwitchPokemon(1); - await game.phaseInterceptor.to(QuietFormChangePhase); + await game.phaseInterceptor.to("QuietFormChangePhase"); eiscue = game.scene.getPlayerPokemon()!; expect(eiscue.formIndex).toBe(icefaceForm); @@ -160,12 +155,12 @@ describe("Abilities - Ice Face", () => { game.move.select(MoveId.HAIL); const eiscue = game.scene.getPlayerPokemon()!; - await game.phaseInterceptor.to(QuietFormChangePhase); + await game.phaseInterceptor.to("QuietFormChangePhase"); expect(eiscue.formIndex).toBe(noiceForm); expect(eiscue.getTag(BattlerTagType.ICE_FACE)).toBeUndefined(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(eiscue.formIndex).toBe(noiceForm); expect(eiscue.getTag(BattlerTagType.ICE_FACE)).toBeUndefined(); @@ -178,7 +173,7 @@ describe("Abilities - Ice Face", () => { game.move.select(MoveId.ICE_BEAM); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); let eiscue = game.scene.getPlayerPokemon()!; expect(eiscue.getTag(BattlerTagType.ICE_FACE)).toBeUndefined(); @@ -188,7 +183,7 @@ describe("Abilities - Ice Face", () => { await game.toNextTurn(); game.doSwitchPokemon(1); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); eiscue = game.scene.getPlayerParty()[1]; expect(eiscue.formIndex).toBe(noiceForm); @@ -213,9 +208,9 @@ describe("Abilities - Ice Face", () => { game.move.select(MoveId.ICE_BEAM); await game.doKillOpponents(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); game.doSelectModifier(); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); expect(eiscue.formIndex).toBe(icefaceForm); expect(eiscue.getTag(BattlerTagType.ICE_FACE)).not.toBe(undefined); @@ -239,7 +234,7 @@ describe("Abilities - Ice Face", () => { game.move.select(MoveId.GASTRO_ACID); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const eiscue = game.scene.getEnemyPokemon()!; @@ -255,7 +250,7 @@ describe("Abilities - Ice Face", () => { game.move.select(MoveId.SKILL_SWAP); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const eiscue = game.scene.getEnemyPokemon()!; @@ -271,7 +266,7 @@ describe("Abilities - Ice Face", () => { game.move.select(MoveId.SIMPLE_BEAM); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); const eiscue = game.scene.getEnemyPokemon()!; diff --git a/test/abilities/imposter.test.ts b/test/abilities/imposter.test.ts index 30491139877..5d0850bfc78 100644 --- a/test/abilities/imposter.test.ts +++ b/test/abilities/imposter.test.ts @@ -2,7 +2,6 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import Phaser from "phaser"; import GameManager from "#test/testUtils/gameManager"; import { SpeciesId } from "#enums/species-id"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { MoveId } from "#enums/move-id"; import { Stat, BATTLE_STATS, EFFECTIVE_STATS } from "#enums/stat"; import { AbilityId } from "#enums/ability-id"; @@ -39,7 +38,7 @@ describe("Abilities - Imposter", () => { await game.classicMode.startBattle([SpeciesId.DITTO]); game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const player = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; @@ -86,7 +85,7 @@ describe("Abilities - Imposter", () => { const avgSpAtk = Math.floor((player.getStat(Stat.SPATK, false) + enemy.getStat(Stat.SPATK, false)) / 2); game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(player.getStat(Stat.ATK, false)).toBe(avgAtk); expect(enemy.getStat(Stat.ATK, false)).toBe(avgAtk); @@ -102,7 +101,7 @@ describe("Abilities - Imposter", () => { const player = game.scene.getPlayerPokemon()!; game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); player.getMoveset().forEach(move => { // Should set correct maximum PP without touching `ppUp` diff --git a/test/abilities/intimidate.test.ts b/test/abilities/intimidate.test.ts index 3dcd9bcd129..2b411ba20c3 100644 --- a/test/abilities/intimidate.test.ts +++ b/test/abilities/intimidate.test.ts @@ -55,8 +55,7 @@ describe("Abilities - Intimidate", () => { expect(playerPokemon.getStatStage(Stat.ATK)).toBe(-1); game.doSwitchPokemon(1); - await game.phaseInterceptor.run("CommandPhase"); - await game.phaseInterceptor.to("CommandPhase"); + await game.toNextTurn(); playerPokemon = game.scene.getPlayerPokemon()!; expect(playerPokemon.species.speciesId).toBe(SpeciesId.POOCHYENA); diff --git a/test/abilities/intrepid_sword.test.ts b/test/abilities/intrepid_sword.test.ts index d9b81e9552e..256452fafd9 100644 --- a/test/abilities/intrepid_sword.test.ts +++ b/test/abilities/intrepid_sword.test.ts @@ -1,6 +1,5 @@ import { Stat } from "#enums/stat"; import GameManager from "#test/testUtils/gameManager"; -import { CommandPhase } from "#app/phases/command-phase"; import { AbilityId } from "#enums/ability-id"; import { SpeciesId } from "#enums/species-id"; import Phaser from "phaser"; @@ -35,7 +34,7 @@ describe("Abilities - Intrepid Sword", () => { const playerPokemon = game.scene.getPlayerPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!; - await game.phaseInterceptor.to(CommandPhase, false); + await game.phaseInterceptor.to("CommandPhase", false); expect(playerPokemon.getStatStage(Stat.ATK)).toBe(1); expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(1); diff --git a/test/abilities/libero.test.ts b/test/abilities/libero.test.ts index eaa2630e90d..fb9ef3efc2e 100644 --- a/test/abilities/libero.test.ts +++ b/test/abilities/libero.test.ts @@ -2,7 +2,6 @@ import { allMoves } from "#app/data/data-lists"; import { PokemonType } from "#enums/pokemon-type"; import { Weather } from "#app/data/weather"; import type { PlayerPokemon } from "#app/field/pokemon"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { AbilityId } from "#enums/ability-id"; import { BattlerTagType } from "#enums/battler-tag-type"; import { BiomeId } from "#enums/biome-id"; @@ -46,7 +45,7 @@ describe("Abilities - Libero", () => { expect(leadPokemon).not.toBe(undefined); game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); testPokemonTypeMatchesDefaultMoveType(leadPokemon, MoveId.SPLASH); }); @@ -61,12 +60,12 @@ describe("Abilities - Libero", () => { expect(leadPokemon).not.toBe(undefined); game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); testPokemonTypeMatchesDefaultMoveType(leadPokemon, MoveId.SPLASH); game.move.select(MoveId.AGILITY); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.waveData.abilitiesApplied).toContain(AbilityId.LIBERO); const leadPokemonType = PokemonType[leadPokemon.getTypes()[0]]; @@ -83,7 +82,7 @@ describe("Abilities - Libero", () => { expect(leadPokemon).not.toBe(undefined); game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); testPokemonTypeMatchesDefaultMoveType(leadPokemon, MoveId.SPLASH); }); @@ -98,7 +97,7 @@ describe("Abilities - Libero", () => { game.scene.arena.weather = new Weather(WeatherType.SUNNY); game.move.select(MoveId.WEATHER_BALL); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.waveData.abilitiesApplied).toContain(AbilityId.LIBERO); expect(leadPokemon.getTypes()).toHaveLength(1); @@ -116,7 +115,7 @@ describe("Abilities - Libero", () => { expect(leadPokemon).not.toBe(undefined); game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.waveData.abilitiesApplied).toContain(AbilityId.LIBERO); expect(leadPokemon.getTypes()).toHaveLength(1); @@ -135,7 +134,7 @@ describe("Abilities - Libero", () => { game.scene.arena.biomeType = BiomeId.MOUNTAIN; game.move.select(MoveId.NATURE_POWER); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); testPokemonTypeMatchesDefaultMoveType(leadPokemon, MoveId.AIR_SLASH); }); @@ -149,7 +148,7 @@ describe("Abilities - Libero", () => { expect(leadPokemon).not.toBe(undefined); game.move.select(MoveId.DIG); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); testPokemonTypeMatchesDefaultMoveType(leadPokemon, MoveId.DIG); }); @@ -164,7 +163,7 @@ describe("Abilities - Libero", () => { game.move.select(MoveId.TACKLE); await game.move.forceMiss(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon.isFullHp()).toBe(true); @@ -180,7 +179,7 @@ describe("Abilities - Libero", () => { expect(leadPokemon).not.toBe(undefined); game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); testPokemonTypeMatchesDefaultMoveType(leadPokemon, MoveId.TACKLE); }); @@ -194,7 +193,7 @@ describe("Abilities - Libero", () => { expect(leadPokemon).not.toBe(undefined); game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); testPokemonTypeMatchesDefaultMoveType(leadPokemon, MoveId.TACKLE); }); @@ -209,7 +208,7 @@ describe("Abilities - Libero", () => { leadPokemon.summonData.types = [allMoves[MoveId.SPLASH].type]; game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.waveData.abilitiesApplied).not.toContain(AbilityId.LIBERO); }); @@ -225,7 +224,7 @@ describe("Abilities - Libero", () => { leadPokemon.isTerastallized = true; game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.waveData.abilitiesApplied).not.toContain(AbilityId.LIBERO); }); @@ -239,7 +238,7 @@ describe("Abilities - Libero", () => { expect(leadPokemon).not.toBe(undefined); game.move.select(MoveId.STRUGGLE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.waveData.abilitiesApplied).not.toContain(AbilityId.LIBERO); }); @@ -253,7 +252,7 @@ describe("Abilities - Libero", () => { expect(leadPokemon).not.toBe(undefined); game.move.select(MoveId.BURN_UP); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.waveData.abilitiesApplied).not.toContain(AbilityId.LIBERO); }); @@ -267,7 +266,7 @@ describe("Abilities - Libero", () => { expect(leadPokemon).not.toBe(undefined); game.move.select(MoveId.TRICK_OR_TREAT); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); testPokemonTypeMatchesDefaultMoveType(leadPokemon, MoveId.TRICK_OR_TREAT); }); @@ -281,7 +280,7 @@ describe("Abilities - Libero", () => { expect(leadPokemon).not.toBe(undefined); game.move.select(MoveId.CURSE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); testPokemonTypeMatchesDefaultMoveType(leadPokemon, MoveId.CURSE); expect(leadPokemon.getTag(BattlerTagType.CURSED)).not.toBe(undefined); diff --git a/test/abilities/magic_guard.test.ts b/test/abilities/magic_guard.test.ts index f135a761bba..9fcf834a50d 100644 --- a/test/abilities/magic_guard.test.ts +++ b/test/abilities/magic_guard.test.ts @@ -1,7 +1,6 @@ import { getArenaTag } from "#app/data/arena-tag"; import { ArenaTagSide } from "#enums/arena-tag-side"; import { getStatusEffectCatchRateMultiplier } from "#app/data/status-effect"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { AbilityId } from "#enums/ability-id"; import { ArenaTagType } from "#enums/arena-tag-type"; import { BattlerTagType } from "#enums/battler-tag-type"; @@ -56,7 +55,7 @@ describe("Abilities - Magic Guard", () => { game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); /** * Expect: @@ -77,7 +76,7 @@ describe("Abilities - Magic Guard", () => { game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); /** * Expect: @@ -97,7 +96,7 @@ describe("Abilities - Magic Guard", () => { game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); /** * Expect: @@ -115,7 +114,7 @@ describe("Abilities - Magic Guard", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); /** * Expect: @@ -139,7 +138,7 @@ describe("Abilities - Magic Guard", () => { const toxicStartCounter = enemyPokemon.status!.toxicTurnCount; //should be 0 - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); /** * Expect: @@ -164,7 +163,7 @@ describe("Abilities - Magic Guard", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); /** * Expect: @@ -189,7 +188,7 @@ describe("Abilities - Magic Guard", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); /** * Expect: @@ -213,7 +212,7 @@ describe("Abilities - Magic Guard", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); /** * Expect: @@ -235,7 +234,7 @@ describe("Abilities - Magic Guard", () => { game.move.select(MoveId.HIGH_JUMP_KICK); await game.move.forceMiss(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); /** * Expect: @@ -252,7 +251,7 @@ describe("Abilities - Magic Guard", () => { game.move.select(MoveId.TAKE_DOWN); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); /** * Expect: @@ -269,7 +268,7 @@ describe("Abilities - Magic Guard", () => { game.move.select(MoveId.STRUGGLE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); /** * Expect: @@ -287,7 +286,7 @@ describe("Abilities - Magic Guard", () => { game.move.select(MoveId.STEEL_BEAM); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); /** * Expect: @@ -302,7 +301,7 @@ describe("Abilities - Magic Guard", () => { game.move.select(MoveId.CHARM); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); }); */ @@ -314,7 +313,7 @@ describe("Abilities - Magic Guard", () => { game.move.select(MoveId.BELLY_DRUM); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); /** * Expect: @@ -337,7 +336,7 @@ describe("Abilities - Magic Guard", () => { game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); /** * Expect: @@ -360,7 +359,7 @@ describe("Abilities - Magic Guard", () => { enemyPokemon.hp = 1; game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); /** * Expect: @@ -382,7 +381,7 @@ describe("Abilities - Magic Guard", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); /** * Expect: @@ -404,7 +403,7 @@ describe("Abilities - Magic Guard", () => { const enemyPokemon = game.scene.getEnemyPokemon()!; game.move.select(MoveId.ABSORB); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); /** * Expect: @@ -421,7 +420,7 @@ describe("Abilities - Magic Guard", () => { await game.classicMode.startBattle([SpeciesId.MAGIKARP]); const leadPokemon = game.scene.getPlayerPokemon()!; game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); /** * Expect: diff --git a/test/abilities/moxie.test.ts b/test/abilities/moxie.test.ts index a85ed081448..73ef79ea54f 100644 --- a/test/abilities/moxie.test.ts +++ b/test/abilities/moxie.test.ts @@ -6,9 +6,6 @@ import { SpeciesId } from "#enums/species-id"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { BattlerIndex } from "#enums/battler-index"; -import { EnemyCommandPhase } from "#app/phases/enemy-command-phase"; -import { VictoryPhase } from "#app/phases/victory-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; describe("Abilities - Moxie", () => { let phaserGame: Phaser.Game; @@ -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); }); @@ -68,7 +65,7 @@ describe("Abilities - Moxie", () => { game.move.select(moveToUse); game.selectTarget(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/mycelium_might.test.ts b/test/abilities/mycelium_might.test.ts index 2cdda4353b5..108a395094d 100644 --- a/test/abilities/mycelium_might.test.ts +++ b/test/abilities/mycelium_might.test.ts @@ -1,5 +1,4 @@ -import { TurnEndPhase } from "#app/phases/turn-end-phase"; -import { TurnStartPhase } from "#app/phases/turn-start-phase"; +import type { TurnStartPhase } from "#app/phases/turn-start-phase"; import GameManager from "#test/testUtils/gameManager"; import { AbilityId } from "#enums/ability-id"; import { Stat } from "#enums/stat"; @@ -51,7 +50,7 @@ describe("Abilities - Mycelium Might", () => { game.move.select(MoveId.BABY_DOLL_EYES); - await game.phaseInterceptor.to(TurnStartPhase, false); + await game.phaseInterceptor.to("TurnStartPhase", false); const phase = game.scene.phaseManager.getCurrentPhase() as TurnStartPhase; const speedOrder = phase.getSpeedOrder(); const commandOrder = phase.getCommandOrder(); @@ -59,7 +58,7 @@ describe("Abilities - Mycelium Might", () => { // The player Pokemon (with Mycelium Might) goes last despite having higher speed than the opponent. expect(speedOrder).toEqual([playerIndex, enemyIndex]); expect(commandOrder).toEqual([enemyIndex, playerIndex]); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); // Despite the opponent's ability (Clear Body), its ATK stat stage is still reduced. expect(enemyPokemon?.getStatStage(Stat.ATK)).toBe(-1); @@ -75,7 +74,7 @@ describe("Abilities - Mycelium Might", () => { game.move.select(MoveId.BABY_DOLL_EYES); - await game.phaseInterceptor.to(TurnStartPhase, false); + await game.phaseInterceptor.to("TurnStartPhase", false); const phase = game.scene.phaseManager.getCurrentPhase() as TurnStartPhase; const speedOrder = phase.getSpeedOrder(); const commandOrder = phase.getCommandOrder(); @@ -83,7 +82,7 @@ describe("Abilities - Mycelium Might", () => { // The enemy Pokemon goes second because its move is in a lower priority bracket. expect(speedOrder).toEqual([playerIndex, enemyIndex]); expect(commandOrder).toEqual([playerIndex, enemyIndex]); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); // Despite the opponent's ability (Clear Body), its ATK stat stage is still reduced. expect(enemyPokemon?.getStatStage(Stat.ATK)).toBe(-1); }); @@ -96,7 +95,7 @@ describe("Abilities - Mycelium Might", () => { game.move.select(MoveId.QUICK_ATTACK); - await game.phaseInterceptor.to(TurnStartPhase, false); + await game.phaseInterceptor.to("TurnStartPhase", false); const phase = game.scene.phaseManager.getCurrentPhase() as TurnStartPhase; const speedOrder = phase.getSpeedOrder(); const commandOrder = phase.getCommandOrder(); diff --git a/test/abilities/no_guard.test.ts b/test/abilities/no_guard.test.ts index dc35e0e1b9a..6784ac06f6c 100644 --- a/test/abilities/no_guard.test.ts +++ b/test/abilities/no_guard.test.ts @@ -1,6 +1,5 @@ import { BattlerIndex } from "#enums/battler-index"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase"; -import { MoveEndPhase } from "#app/phases/move-end-phase"; +import type { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -43,12 +42,12 @@ describe("Abilities - No Guard", () => { await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); const moveEffectPhase = game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase; vi.spyOn(moveEffectPhase, "hitCheck"); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); expect(moveEffectPhase.hitCheck).toHaveReturnedWith([HitCheckResult.HIT, 1]); }); diff --git a/test/abilities/pastel_veil.test.ts b/test/abilities/pastel_veil.test.ts index b8e8873ed36..b511a28a033 100644 --- a/test/abilities/pastel_veil.test.ts +++ b/test/abilities/pastel_veil.test.ts @@ -1,7 +1,5 @@ import { BattlerIndex } from "#enums/battler-index"; import { AbilityId } from "#enums/ability-id"; -import { CommandPhase } from "#app/phases/command-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import { StatusEffect } from "#enums/status-effect"; @@ -44,7 +42,7 @@ describe("Abilities - Pastel Veil", () => { game.move.select(MoveId.SPLASH); game.move.select(MoveId.TOXIC_THREAD, 1, BattlerIndex.PLAYER); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(magikarp.status?.effect).toBeUndefined(); }); @@ -60,13 +58,13 @@ describe("Abilities - Pastel Veil", () => { game.move.select(MoveId.SPLASH); game.move.select(MoveId.TOXIC_THREAD, 1, BattlerIndex.PLAYER); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(magikarp.status?.effect).toBe(StatusEffect.POISON); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SPLASH); game.doSwitchPokemon(2); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(magikarp.status?.effect).toBeUndefined(); }); diff --git a/test/abilities/power_construct.test.ts b/test/abilities/power_construct.test.ts index 2ea14597ef9..638a35bbe65 100644 --- a/test/abilities/power_construct.test.ts +++ b/test/abilities/power_construct.test.ts @@ -1,6 +1,4 @@ import { Status } from "#app/data/status-effect"; -import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -51,9 +49,9 @@ describe("Abilities - POWER CONSTRUCT", () => { game.move.select(MoveId.SPLASH); await game.doKillOpponents(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); game.doSelectModifier(); - await game.phaseInterceptor.to(QuietFormChangePhase); + await game.phaseInterceptor.to("QuietFormChangePhase"); expect(zygarde!.formIndex).toBe(baseForm); }); @@ -77,9 +75,9 @@ describe("Abilities - POWER CONSTRUCT", () => { game.move.select(MoveId.SPLASH); await game.doKillOpponents(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); game.doSelectModifier(); - await game.phaseInterceptor.to(QuietFormChangePhase); + await game.phaseInterceptor.to("QuietFormChangePhase"); expect(zygarde!.formIndex).toBe(baseForm); }); diff --git a/test/abilities/power_spot.test.ts b/test/abilities/power_spot.test.ts index 11f75588386..902fb2916a3 100644 --- a/test/abilities/power_spot.test.ts +++ b/test/abilities/power_spot.test.ts @@ -1,7 +1,5 @@ import { allMoves } from "#app/data/data-lists"; import { AbilityId } from "#enums/ability-id"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import GameManager from "#test/testUtils/gameManager"; @@ -43,7 +41,7 @@ describe("Abilities - Power Spot", () => { await game.classicMode.startBattle([SpeciesId.REGIELEKI, SpeciesId.STONJOURNER]); game.move.select(MoveId.DAZZLING_GLEAM); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower * powerSpotMultiplier); }); @@ -57,7 +55,7 @@ describe("Abilities - Power Spot", () => { await game.classicMode.startBattle([SpeciesId.REGIELEKI, SpeciesId.STONJOURNER]); game.move.select(MoveId.BREAKING_SWIPE); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower * powerSpotMultiplier); }); @@ -71,7 +69,7 @@ describe("Abilities - Power Spot", () => { await game.classicMode.startBattle([SpeciesId.STONJOURNER, SpeciesId.REGIELEKI]); game.move.select(MoveId.BREAKING_SWIPE); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower); }); diff --git a/test/abilities/protean.test.ts b/test/abilities/protean.test.ts index 09c9addbc35..67c248ce82e 100644 --- a/test/abilities/protean.test.ts +++ b/test/abilities/protean.test.ts @@ -2,7 +2,6 @@ import { allMoves } from "#app/data/data-lists"; import { PokemonType } from "#enums/pokemon-type"; import { Weather } from "#app/data/weather"; import type { PlayerPokemon } from "#app/field/pokemon"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { AbilityId } from "#enums/ability-id"; import { BattlerTagType } from "#enums/battler-tag-type"; import { BiomeId } from "#enums/biome-id"; @@ -46,7 +45,7 @@ describe("Abilities - Protean", () => { expect(leadPokemon).not.toBe(undefined); game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); testPokemonTypeMatchesDefaultMoveType(leadPokemon, MoveId.SPLASH); }); @@ -61,12 +60,12 @@ describe("Abilities - Protean", () => { expect(leadPokemon).not.toBe(undefined); game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); testPokemonTypeMatchesDefaultMoveType(leadPokemon, MoveId.SPLASH); game.move.select(MoveId.AGILITY); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.waveData.abilitiesApplied).toContain(AbilityId.PROTEAN); const leadPokemonType = PokemonType[leadPokemon.getTypes()[0]]; @@ -83,7 +82,7 @@ describe("Abilities - Protean", () => { expect(leadPokemon).not.toBe(undefined); game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); testPokemonTypeMatchesDefaultMoveType(leadPokemon, MoveId.SPLASH); }); @@ -98,7 +97,7 @@ describe("Abilities - Protean", () => { game.scene.arena.weather = new Weather(WeatherType.SUNNY); game.move.select(MoveId.WEATHER_BALL); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.waveData.abilitiesApplied).toContain(AbilityId.PROTEAN); expect(leadPokemon.getTypes()).toHaveLength(1); @@ -116,7 +115,7 @@ describe("Abilities - Protean", () => { expect(leadPokemon).not.toBe(undefined); game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.waveData.abilitiesApplied).toContain(AbilityId.PROTEAN); expect(leadPokemon.getTypes()).toHaveLength(1); @@ -135,7 +134,7 @@ describe("Abilities - Protean", () => { game.scene.arena.biomeType = BiomeId.MOUNTAIN; game.move.select(MoveId.NATURE_POWER); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); testPokemonTypeMatchesDefaultMoveType(leadPokemon, MoveId.AIR_SLASH); }); @@ -149,7 +148,7 @@ describe("Abilities - Protean", () => { expect(leadPokemon).not.toBe(undefined); game.move.select(MoveId.DIG); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); testPokemonTypeMatchesDefaultMoveType(leadPokemon, MoveId.DIG); }); @@ -164,7 +163,7 @@ describe("Abilities - Protean", () => { game.move.select(MoveId.TACKLE); await game.move.forceMiss(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const enemyPokemon = game.scene.getEnemyPokemon()!; expect(enemyPokemon.isFullHp()).toBe(true); @@ -180,7 +179,7 @@ describe("Abilities - Protean", () => { expect(leadPokemon).not.toBe(undefined); game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); testPokemonTypeMatchesDefaultMoveType(leadPokemon, MoveId.TACKLE); }); @@ -194,7 +193,7 @@ describe("Abilities - Protean", () => { expect(leadPokemon).not.toBe(undefined); game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); testPokemonTypeMatchesDefaultMoveType(leadPokemon, MoveId.TACKLE); }); @@ -209,7 +208,7 @@ describe("Abilities - Protean", () => { leadPokemon.summonData.types = [allMoves[MoveId.SPLASH].type]; game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.waveData.abilitiesApplied).not.toContain(AbilityId.PROTEAN); }); @@ -225,7 +224,7 @@ describe("Abilities - Protean", () => { leadPokemon.isTerastallized = true; game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.waveData.abilitiesApplied).not.toContain(AbilityId.PROTEAN); }); @@ -239,7 +238,7 @@ describe("Abilities - Protean", () => { expect(leadPokemon).not.toBe(undefined); game.move.select(MoveId.STRUGGLE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.waveData.abilitiesApplied).not.toContain(AbilityId.PROTEAN); }); @@ -253,7 +252,7 @@ describe("Abilities - Protean", () => { expect(leadPokemon).not.toBe(undefined); game.move.select(MoveId.BURN_UP); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.waveData.abilitiesApplied).not.toContain(AbilityId.PROTEAN); }); @@ -267,7 +266,7 @@ describe("Abilities - Protean", () => { expect(leadPokemon).not.toBe(undefined); game.move.select(MoveId.TRICK_OR_TREAT); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); testPokemonTypeMatchesDefaultMoveType(leadPokemon, MoveId.TRICK_OR_TREAT); }); @@ -281,7 +280,7 @@ describe("Abilities - Protean", () => { expect(leadPokemon).not.toBe(undefined); game.move.select(MoveId.CURSE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); testPokemonTypeMatchesDefaultMoveType(leadPokemon, MoveId.CURSE); expect(leadPokemon.getTag(BattlerTagType.CURSED)).not.toBe(undefined); diff --git a/test/abilities/quick_draw.test.ts b/test/abilities/quick_draw.test.ts index 11418f31375..ab941f558dd 100644 --- a/test/abilities/quick_draw.test.ts +++ b/test/abilities/quick_draw.test.ts @@ -1,5 +1,4 @@ import { allAbilities } from "#app/data/data-lists"; -import { FaintPhase } from "#app/phases/faint-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -50,7 +49,7 @@ describe("Abilities - Quick Draw", () => { enemy.hp = 1; game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(FaintPhase, false); + await game.phaseInterceptor.to("FaintPhase", false); expect(pokemon.isFainted()).toBe(false); expect(enemy.isFainted()).toBe(true); @@ -72,7 +71,7 @@ describe("Abilities - Quick Draw", () => { enemy.hp = 1; game.move.select(MoveId.TAIL_WHIP); - await game.phaseInterceptor.to(FaintPhase, false); + await game.phaseInterceptor.to("FaintPhase", false); expect(pokemon.isFainted()).toBe(true); expect(enemy.isFainted()).toBe(false); @@ -92,7 +91,7 @@ describe("Abilities - Quick Draw", () => { enemy.hp = 1; game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(FaintPhase, false); + await game.phaseInterceptor.to("FaintPhase", false); expect(pokemon.isFainted()).toBe(true); expect(enemy.isFainted()).toBe(false); diff --git a/test/abilities/sand_veil.test.ts b/test/abilities/sand_veil.test.ts index 35a0a3347ff..bfc5cf1ddee 100644 --- a/test/abilities/sand_veil.test.ts +++ b/test/abilities/sand_veil.test.ts @@ -1,7 +1,4 @@ import { allAbilities } from "#app/data/data-lists"; -import { CommandPhase } from "#app/phases/command-phase"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase"; -import { MoveEndPhase } from "#app/phases/move-end-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -61,13 +58,13 @@ describe("Abilities - Sand Veil", () => { game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); - await game.phaseInterceptor.to(MoveEndPhase, false); + await game.phaseInterceptor.to("MoveEndPhase", false); expect(leadPokemon[0].isFullHp()).toBe(true); expect(leadPokemon[1].hp).toBeLessThan(leadPokemon[1].getMaxHp()); diff --git a/test/abilities/sap_sipper.test.ts b/test/abilities/sap_sipper.test.ts index c70730f0711..7e12d6bf07f 100644 --- a/test/abilities/sap_sipper.test.ts +++ b/test/abilities/sap_sipper.test.ts @@ -1,7 +1,5 @@ import { Stat } from "#enums/stat"; import { TerrainType } from "#app/data/terrain"; -import { MoveEndPhase } from "#app/phases/move-end-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { AbilityId } from "#enums/ability-id"; import { BattlerTagType } from "#enums/battler-tag-type"; import { MoveId } from "#enums/move-id"; @@ -50,7 +48,7 @@ describe("Abilities - Sap Sipper", () => { game.move.select(moveToUse); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(initialEnemyHp - enemyPokemon.hp).toBe(0); expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(1); @@ -67,7 +65,7 @@ describe("Abilities - Sap Sipper", () => { game.move.select(moveToUse); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(enemyPokemon.status).toBeUndefined(); expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(1); @@ -82,7 +80,7 @@ describe("Abilities - Sap Sipper", () => { game.move.select(moveToUse); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(game.scene.arena.terrain).toBeDefined(); expect(game.scene.arena.terrain!.terrainType).toBe(TerrainType.GRASSY); @@ -101,7 +99,7 @@ describe("Abilities - Sap Sipper", () => { game.move.select(moveToUse); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(initialEnemyHp - enemyPokemon.hp).toBe(0); expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(1); @@ -118,11 +116,11 @@ describe("Abilities - Sap Sipper", () => { game.move.select(moveToUse); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); expect(playerPokemon.getTag(BattlerTagType.SPIKY_SHIELD)).toBeDefined(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(playerPokemon.getStatStage(Stat.ATK)).toBe(0); expect(game.phaseInterceptor.log).not.toContain("ShowAbilityPhase"); @@ -145,7 +143,7 @@ describe("Abilities - Sap Sipper", () => { game.move.select(moveToUse); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(initialEnemyHp - enemyPokemon.hp).toBe(0); expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(1); diff --git a/test/abilities/schooling.test.ts b/test/abilities/schooling.test.ts index 646beafb80f..b6ddb791871 100644 --- a/test/abilities/schooling.test.ts +++ b/test/abilities/schooling.test.ts @@ -1,6 +1,4 @@ import { Status } from "#app/data/status-effect"; -import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -47,9 +45,9 @@ describe("Abilities - SCHOOLING", () => { game.move.select(MoveId.SPLASH); await game.doKillOpponents(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); game.doSelectModifier(); - await game.phaseInterceptor.to(QuietFormChangePhase); + await game.phaseInterceptor.to("QuietFormChangePhase"); expect(wishiwashi.formIndex).toBe(soloForm); }); diff --git a/test/abilities/screen_cleaner.test.ts b/test/abilities/screen_cleaner.test.ts index e896d2e51f9..c652edec07a 100644 --- a/test/abilities/screen_cleaner.test.ts +++ b/test/abilities/screen_cleaner.test.ts @@ -1,6 +1,4 @@ import { ArenaTagType } from "#app/enums/arena-tag-type"; -import { PostSummonPhase } from "#app/phases/post-summon-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -33,13 +31,13 @@ describe("Abilities - Screen Cleaner", () => { await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.MAGIKARP]); game.move.select(MoveId.HAIL); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(game.scene.arena.getTag(ArenaTagType.AURORA_VEIL)).toBeDefined(); await game.toNextTurn(); game.doSwitchPokemon(1); - await game.phaseInterceptor.to(PostSummonPhase); + await game.phaseInterceptor.to("PostSummonPhase"); expect(game.scene.arena.getTag(ArenaTagType.AURORA_VEIL)).toBeUndefined(); }); @@ -50,13 +48,13 @@ describe("Abilities - Screen Cleaner", () => { await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.MAGIKARP]); game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(game.scene.arena.getTag(ArenaTagType.LIGHT_SCREEN)).toBeDefined(); await game.toNextTurn(); game.doSwitchPokemon(1); - await game.phaseInterceptor.to(PostSummonPhase); + await game.phaseInterceptor.to("PostSummonPhase"); expect(game.scene.arena.getTag(ArenaTagType.LIGHT_SCREEN)).toBeUndefined(); }); @@ -67,13 +65,13 @@ describe("Abilities - Screen Cleaner", () => { await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.MAGIKARP]); game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(game.scene.arena.getTag(ArenaTagType.REFLECT)).toBeDefined(); await game.toNextTurn(); game.doSwitchPokemon(1); - await game.phaseInterceptor.to(PostSummonPhase); + await game.phaseInterceptor.to("PostSummonPhase"); expect(game.scene.arena.getTag(ArenaTagType.REFLECT)).toBeUndefined(); }); diff --git a/test/abilities/shield_dust.test.ts b/test/abilities/shield_dust.test.ts index 6bb63fd16a5..bd909b47afb 100644 --- a/test/abilities/shield_dust.test.ts +++ b/test/abilities/shield_dust.test.ts @@ -1,6 +1,6 @@ import { BattlerIndex } from "#enums/battler-index"; import { applyAbAttrs, applyPreDefendAbAttrs } from "#app/data/abilities/apply-ab-attrs"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase"; +import type { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { NumberHolder } from "#app/utils/common"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; @@ -44,7 +44,7 @@ describe("Abilities - Shield Dust", () => { game.move.select(MoveId.AIR_SLASH); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); // Shield Dust negates secondary effect const phase = game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase; diff --git a/test/abilities/shields_down.test.ts b/test/abilities/shields_down.test.ts index 7b4803915f1..99a83ba63c4 100644 --- a/test/abilities/shields_down.test.ts +++ b/test/abilities/shields_down.test.ts @@ -1,7 +1,5 @@ import { Status } from "#app/data/status-effect"; import { BattlerTagType } from "#app/enums/battler-tag-type"; -import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -52,9 +50,9 @@ describe("Abilities - SHIELDS DOWN", () => { game.move.select(MoveId.SPLASH); await game.doKillOpponents(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); game.doSelectModifier(); - await game.phaseInterceptor.to(QuietFormChangePhase); + await game.phaseInterceptor.to("QuietFormChangePhase"); expect(minior.formIndex).toBe(meteorForm); }); @@ -64,7 +62,7 @@ describe("Abilities - SHIELDS DOWN", () => { await game.classicMode.startBattle([SpeciesId.MINIOR]); game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(game.scene.getPlayerPokemon()!.status).toBe(undefined); }); @@ -76,7 +74,7 @@ describe("Abilities - SHIELDS DOWN", () => { game.move.select(MoveId.SPLASH); await game.move.selectEnemyMove(MoveId.SPORE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(game.scene.getPlayerPokemon()!.status).toBe(undefined); }); @@ -87,7 +85,7 @@ describe("Abilities - SHIELDS DOWN", () => { await game.classicMode.startBattle([SpeciesId.MINIOR]); game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(game.scene.getPlayerPokemon()!.status).toBe(undefined); }); @@ -99,7 +97,7 @@ describe("Abilities - SHIELDS DOWN", () => { game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(game.scene.getPlayerPokemon()!.status).toBe(undefined); }); @@ -135,7 +133,7 @@ describe("Abilities - SHIELDS DOWN", () => { game.move.select(MoveId.SPLASH); await game.move.selectEnemyMove(MoveId.YAWN); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(game.scene.getPlayerPokemon()!.findTag(tag => tag.tagType === BattlerTagType.DROWSY)).toBe(undefined); }); @@ -147,7 +145,7 @@ describe("Abilities - SHIELDS DOWN", () => { game.move.select(MoveId.SPLASH); await game.move.selectEnemyMove(MoveId.CONFUSE_RAY); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(game.scene.getPlayerPokemon()!.findTag(tag => tag.tagType === BattlerTagType.CONFUSED)).not.toBe(undefined); }); @@ -161,7 +159,7 @@ describe("Abilities - SHIELDS DOWN", () => { game.move.select(MoveId.SPORE); await game.move.selectEnemyMove(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(game.scene.getEnemyPokemon()!.status?.effect).toBe(StatusEffect.SLEEP); }); diff --git a/test/abilities/speed_boost.test.ts b/test/abilities/speed_boost.test.ts index a4445d085f3..e5944bc1981 100644 --- a/test/abilities/speed_boost.test.ts +++ b/test/abilities/speed_boost.test.ts @@ -7,7 +7,7 @@ import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import type { CommandPhase } from "#app/phases/command-phase"; import { Command } from "#enums/command"; -import { AttemptRunPhase } from "#app/phases/attempt-run-phase"; +import type { AttemptRunPhase } from "#app/phases/attempt-run-phase"; describe("Abilities - Speed Boost", () => { let phaserGame: Phaser.Game; @@ -102,7 +102,7 @@ describe("Abilities - Speed Boost", () => { commandPhase.handleCommand(Command.RUN, 0); const runPhase = game.scene.phaseManager.getCurrentPhase() as AttemptRunPhase; runPhase.forceFailEscape = true; - await game.phaseInterceptor.to(AttemptRunPhase); + await game.phaseInterceptor.to("AttemptRunPhase"); await game.toNextTurn(); const playerPokemon = game.scene.getPlayerPokemon()!; diff --git a/test/abilities/stall.test.ts b/test/abilities/stall.test.ts index e8ee23fb972..0d922c038c7 100644 --- a/test/abilities/stall.test.ts +++ b/test/abilities/stall.test.ts @@ -4,7 +4,7 @@ import { SpeciesId } from "#enums/species-id"; import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { TurnStartPhase } from "#app/phases/turn-start-phase"; +import type { TurnStartPhase } from "#app/phases/turn-start-phase"; describe("Abilities - Stall", () => { let phaserGame: Phaser.Game; @@ -45,7 +45,7 @@ describe("Abilities - Stall", () => { game.move.select(MoveId.QUICK_ATTACK); - await game.phaseInterceptor.to(TurnStartPhase, false); + await game.phaseInterceptor.to("TurnStartPhase", false); const phase = game.scene.phaseManager.getCurrentPhase() as TurnStartPhase; const speedOrder = phase.getSpeedOrder(); const commandOrder = phase.getCommandOrder(); @@ -63,7 +63,7 @@ describe("Abilities - Stall", () => { game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(TurnStartPhase, false); + await game.phaseInterceptor.to("TurnStartPhase", false); const phase = game.scene.phaseManager.getCurrentPhase() as TurnStartPhase; const speedOrder = phase.getSpeedOrder(); const commandOrder = phase.getCommandOrder(); @@ -82,7 +82,7 @@ describe("Abilities - Stall", () => { game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(TurnStartPhase, false); + await game.phaseInterceptor.to("TurnStartPhase", false); const phase = game.scene.phaseManager.getCurrentPhase() as TurnStartPhase; const speedOrder = phase.getSpeedOrder(); const commandOrder = phase.getCommandOrder(); diff --git a/test/abilities/sturdy.test.ts b/test/abilities/sturdy.test.ts index e7b2c05040d..f20e40511a4 100644 --- a/test/abilities/sturdy.test.ts +++ b/test/abilities/sturdy.test.ts @@ -1,6 +1,4 @@ import type { EnemyPokemon } from "#app/field/pokemon"; -import { DamageAnimPhase } from "#app/phases/damage-anim-phase"; -import { MoveEndPhase } from "#app/phases/move-end-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -37,7 +35,7 @@ describe("Abilities - Sturdy", () => { test("Sturdy activates when user is at full HP", async () => { await game.classicMode.startBattle(); game.move.select(MoveId.CLOSE_COMBAT); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); expect(game.scene.getEnemyParty()[0].hp).toBe(1); }); @@ -48,7 +46,7 @@ describe("Abilities - Sturdy", () => { enemyPokemon.hp = enemyPokemon.getMaxHp() - 1; game.move.select(MoveId.CLOSE_COMBAT); - await game.phaseInterceptor.to(DamageAnimPhase); + await game.phaseInterceptor.to("DamageAnimPhase"); expect(enemyPokemon.hp).toBe(0); expect(enemyPokemon.isFainted()).toBe(true); @@ -57,7 +55,7 @@ describe("Abilities - Sturdy", () => { test("Sturdy pokemon should be immune to OHKO moves", async () => { await game.classicMode.startBattle(); game.move.select(MoveId.FISSURE); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0]; expect(enemyPokemon.isFullHp()).toBe(true); @@ -68,7 +66,7 @@ describe("Abilities - Sturdy", () => { await game.classicMode.startBattle(); game.move.select(MoveId.CLOSE_COMBAT); - await game.phaseInterceptor.to(DamageAnimPhase); + await game.phaseInterceptor.to("DamageAnimPhase"); const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0]; expect(enemyPokemon.hp).toBe(0); diff --git a/test/abilities/supreme_overlord.test.ts b/test/abilities/supreme_overlord.test.ts index 7143b590f68..50e0d3b681d 100644 --- a/test/abilities/supreme_overlord.test.ts +++ b/test/abilities/supreme_overlord.test.ts @@ -3,7 +3,6 @@ import type Move from "#app/data/moves/move"; import { AbilityId } from "#enums/ability-id"; import { SpeciesId } from "#enums/species-id"; import { BattlerIndex } from "#enums/battler-index"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; @@ -58,7 +57,7 @@ describe("Abilities - Supreme Overlord", () => { game.move.select(MoveId.TACKLE); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(move.calculateBattlePower).toHaveReturnedWith(basePower * 1.2); }); @@ -93,7 +92,7 @@ describe("Abilities - Supreme Overlord", () => { game.move.select(MoveId.TACKLE); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(move.calculateBattlePower).toHaveReturnedWith(basePower * 1.3); }); diff --git a/test/abilities/sweet_veil.test.ts b/test/abilities/sweet_veil.test.ts index ed9cb20afcc..bebcdcef94e 100644 --- a/test/abilities/sweet_veil.test.ts +++ b/test/abilities/sweet_veil.test.ts @@ -1,8 +1,6 @@ import { BattlerIndex } from "#enums/battler-index"; import { AbilityId } from "#enums/ability-id"; import { BattlerTagType } from "#app/enums/battler-tag-type"; -import { CommandPhase } from "#app/phases/command-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import GameManager from "#test/testUtils/gameManager"; @@ -39,7 +37,7 @@ describe("Abilities - Sweet Veil", () => { game.move.select(MoveId.SPLASH); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(game.scene.getPlayerField().every(p => p.status?.effect)).toBe(false); }); @@ -51,7 +49,7 @@ describe("Abilities - Sweet Veil", () => { game.move.select(MoveId.SPLASH); game.move.select(MoveId.REST, 1); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(game.scene.getPlayerField().every(p => p.status?.effect)).toBe(false); }); @@ -63,7 +61,7 @@ describe("Abilities - Sweet Veil", () => { game.move.select(MoveId.SPLASH); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(game.scene.getPlayerField().every(p => !!p.getTag(BattlerTagType.DROWSY))).toBe(false); }); @@ -80,7 +78,7 @@ describe("Abilities - Sweet Veil", () => { expect(game.scene.getPlayerField().some(p => !!p.getTag(BattlerTagType.DROWSY))).toBe(true); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SPLASH); game.doSwitchPokemon(2); diff --git a/test/abilities/unseen_fist.test.ts b/test/abilities/unseen_fist.test.ts index 26de77d4643..864c1ce2115 100644 --- a/test/abilities/unseen_fist.test.ts +++ b/test/abilities/unseen_fist.test.ts @@ -1,4 +1,3 @@ -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -6,7 +5,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { BattlerTagType } from "#app/enums/battler-tag-type"; -import { BerryPhase } from "#app/phases/berry-phase"; describe("Abilities - Unseen Fist", () => { let phaserGame: Phaser.Game; @@ -60,7 +58,7 @@ describe("Abilities - Unseen Fist", () => { game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.getTag(BattlerTagType.SUBSTITUTE)).toBeUndefined(); expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); @@ -86,7 +84,7 @@ async function testUnseenFistHitResult( const enemyStartingHp = enemyPokemon.hp; game.move.select(attackMove); - await game.phaseInterceptor.to(TurnEndPhase, false); + await game.phaseInterceptor.to("TurnEndPhase", false); if (shouldSucceed) { expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp); diff --git a/test/abilities/victory_star.test.ts b/test/abilities/victory_star.test.ts index 4742dd96aa6..3589f2e1f6c 100644 --- a/test/abilities/victory_star.test.ts +++ b/test/abilities/victory_star.test.ts @@ -1,5 +1,4 @@ import { BattlerIndex } from "#enums/battler-index"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -40,7 +39,7 @@ describe("Abilities - Victory Star", () => { vi.spyOn(user, "getAccuracyMultiplier"); game.move.select(MoveId.TACKLE, 0, BattlerIndex.ENEMY); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(user.getAccuracyMultiplier).toHaveReturnedWith(1.1); }); @@ -53,7 +52,7 @@ describe("Abilities - Victory Star", () => { game.move.select(MoveId.TACKLE, 0, BattlerIndex.ENEMY); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(ally.getAccuracyMultiplier).toHaveReturnedWith(1.1); }); diff --git a/test/abilities/volt_absorb.test.ts b/test/abilities/volt_absorb.test.ts index 6bea70ee2a4..3e49681ec90 100644 --- a/test/abilities/volt_absorb.test.ts +++ b/test/abilities/volt_absorb.test.ts @@ -1,5 +1,4 @@ import { Stat } from "#enums/stat"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { AbilityId } from "#enums/ability-id"; import { BattlerTagType } from "#enums/battler-tag-type"; import { MoveId } from "#enums/move-id"; @@ -46,7 +45,7 @@ describe("Abilities - Volt Absorb", () => { game.move.select(moveToUse); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(playerPokemon.getStatStage(Stat.SPDEF)).toBe(1); expect(playerPokemon.getTag(BattlerTagType.CHARGED)).toBeDefined(); diff --git a/test/abilities/wind_power.test.ts b/test/abilities/wind_power.test.ts index 8e657997008..ca167770741 100644 --- a/test/abilities/wind_power.test.ts +++ b/test/abilities/wind_power.test.ts @@ -1,5 +1,4 @@ import { BattlerTagType } from "#app/enums/battler-tag-type"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -38,7 +37,7 @@ describe("Abilities - Wind Power", () => { expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeUndefined(); game.move.select(MoveId.PETAL_BLIZZARD); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeDefined(); }); @@ -52,7 +51,7 @@ describe("Abilities - Wind Power", () => { expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeUndefined(); game.move.select(MoveId.TAILWIND); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeDefined(); }); @@ -69,7 +68,7 @@ describe("Abilities - Wind Power", () => { game.move.select(MoveId.TAILWIND); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeDefined(); expect(magikarp.getTag(BattlerTagType.CHARGED)).toBeUndefined(); @@ -85,7 +84,7 @@ describe("Abilities - Wind Power", () => { game.move.select(MoveId.SANDSTORM); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeUndefined(); }); diff --git a/test/abilities/wonder_skin.test.ts b/test/abilities/wonder_skin.test.ts index 886882ab6fd..5b4afbf423f 100644 --- a/test/abilities/wonder_skin.test.ts +++ b/test/abilities/wonder_skin.test.ts @@ -1,5 +1,4 @@ import { allMoves } from "#app/data/data-lists"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -39,7 +38,7 @@ describe("Abilities - Wonder Skin", () => { await game.classicMode.startBattle([SpeciesId.PIKACHU]); game.move.select(MoveId.CHARM); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(moveToCheck.calculateBattleAccuracy).toHaveReturnedWith(50); }); @@ -51,7 +50,7 @@ describe("Abilities - Wonder Skin", () => { await game.classicMode.startBattle([SpeciesId.PIKACHU]); game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(moveToCheck.calculateBattleAccuracy).toHaveReturnedWith(100); }); @@ -72,7 +71,7 @@ describe("Abilities - Wonder Skin", () => { await game.classicMode.startBattle([SpeciesId.PIKACHU]); game.move.select(MoveId.CHARM); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(moveToCheck.calculateBattleAccuracy).toHaveReturnedWith(100); }); diff --git a/test/abilities/zero_to_hero.test.ts b/test/abilities/zero_to_hero.test.ts index 7d0128a4dbc..2e929f4ffc1 100644 --- a/test/abilities/zero_to_hero.test.ts +++ b/test/abilities/zero_to_hero.test.ts @@ -1,6 +1,4 @@ import { Status } from "#app/data/status-effect"; -import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -50,10 +48,10 @@ describe("Abilities - ZERO TO HERO", () => { game.move.select(MoveId.SPLASH); await game.doKillOpponents(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); game.doSelectModifier(); - await game.phaseInterceptor.to(QuietFormChangePhase); - await game.phaseInterceptor.to(QuietFormChangePhase); + await game.phaseInterceptor.to("QuietFormChangePhase"); + await game.phaseInterceptor.to("QuietFormChangePhase"); expect(palafin1.formIndex).toBe(baseForm); expect(palafin2.formIndex).toBe(baseForm); @@ -66,7 +64,7 @@ describe("Abilities - ZERO TO HERO", () => { expect(palafin.formIndex).toBe(baseForm); game.doSwitchPokemon(1); - await game.phaseInterceptor.to(QuietFormChangePhase); + await game.phaseInterceptor.to("QuietFormChangePhase"); expect(palafin.formIndex).toBe(heroForm); }); diff --git a/test/arena/weather_fog.test.ts b/test/arena/weather_fog.test.ts index e6984e13bd0..68fcb8897df 100644 --- a/test/arena/weather_fog.test.ts +++ b/test/arena/weather_fog.test.ts @@ -1,6 +1,5 @@ import { allMoves } from "#app/data/data-lists"; import { AbilityId } from "#enums/ability-id"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import { WeatherType } from "#enums/weather-type"; @@ -41,7 +40,7 @@ describe("Weather - Fog", () => { await game.classicMode.startBattle([SpeciesId.MAGIKARP]); game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(moveToCheck.calculateBattleAccuracy).toHaveReturnedWith(100 * 0.9); }); diff --git a/test/arena/weather_strong_winds.test.ts b/test/arena/weather_strong_winds.test.ts index d0d256816eb..4bd5f97e5b3 100644 --- a/test/arena/weather_strong_winds.test.ts +++ b/test/arena/weather_strong_winds.test.ts @@ -1,6 +1,5 @@ import { allMoves } from "#app/data/data-lists"; import { StatusEffect } from "#app/enums/status-effect"; -import { TurnStartPhase } from "#app/phases/turn-start-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -41,7 +40,7 @@ describe("Weather - Strong Winds", () => { game.move.select(MoveId.THUNDERBOLT); - await game.phaseInterceptor.to(TurnStartPhase); + await game.phaseInterceptor.to("TurnStartPhase"); expect(enemy.getAttackTypeEffectiveness(allMoves[MoveId.THUNDERBOLT].type, pikachu)).toBe(0.5); }); @@ -52,7 +51,7 @@ describe("Weather - Strong Winds", () => { game.move.select(MoveId.THUNDERBOLT); - await game.phaseInterceptor.to(TurnStartPhase); + await game.phaseInterceptor.to("TurnStartPhase"); expect(enemy.getAttackTypeEffectiveness(allMoves[MoveId.THUNDERBOLT].type, pikachu)).toBe(1); }); @@ -63,7 +62,7 @@ describe("Weather - Strong Winds", () => { game.move.select(MoveId.ICE_BEAM); - await game.phaseInterceptor.to(TurnStartPhase); + await game.phaseInterceptor.to("TurnStartPhase"); expect(enemy.getAttackTypeEffectiveness(allMoves[MoveId.ICE_BEAM].type, pikachu)).toBe(1); }); @@ -74,7 +73,7 @@ describe("Weather - Strong Winds", () => { game.move.select(MoveId.ROCK_SLIDE); - await game.phaseInterceptor.to(TurnStartPhase); + await game.phaseInterceptor.to("TurnStartPhase"); expect(enemy.getAttackTypeEffectiveness(allMoves[MoveId.ROCK_SLIDE].type, pikachu)).toBe(1); }); diff --git a/test/battle/battle-order.test.ts b/test/battle/battle-order.test.ts index 114592c8c8e..57199057cdf 100644 --- a/test/battle/battle-order.test.ts +++ b/test/battle/battle-order.test.ts @@ -1,6 +1,4 @@ -import { EnemyCommandPhase } from "#app/phases/enemy-command-phase"; -import { SelectTargetPhase } from "#app/phases/select-target-phase"; -import { TurnStartPhase } from "#app/phases/turn-start-phase"; +import type { TurnStartPhase } from "#app/phases/turn-start-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -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 bf2c3968aa6..a4f08a9b870 100644 --- a/test/battle/battle.test.ts +++ b/test/battle/battle.test.ts @@ -1,26 +1,11 @@ import { allSpecies } from "#app/data/data-lists"; import { Stat } from "#enums/stat"; -import { getGameMode } from "#app/game-mode"; -import { GameModes } from "#enums/game-modes"; -import { BattleEndPhase } from "#app/phases/battle-end-phase"; import { CommandPhase } from "#app/phases/command-phase"; -import { DamageAnimPhase } from "#app/phases/damage-anim-phase"; -import { EncounterPhase } from "#app/phases/encounter-phase"; -import { EnemyCommandPhase } from "#app/phases/enemy-command-phase"; -import { LoginPhase } from "#app/phases/login-phase"; import { NextEncounterPhase } from "#app/phases/next-encounter-phase"; -import { SelectGenderPhase } from "#app/phases/select-gender-phase"; -import { SelectStarterPhase } from "#app/phases/select-starter-phase"; -import { SummonPhase } from "#app/phases/summon-phase"; -import { SwitchPhase } from "#app/phases/switch-phase"; -import { TitlePhase } from "#app/phases/title-phase"; -import { TurnInitPhase } from "#app/phases/turn-init-phase"; import GameManager from "#test/testUtils/gameManager"; -import { generateStarter } from "#test/testUtils/gameManagerUtils"; import { UiMode } from "#enums/ui-mode"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; -import { PlayerGender } from "#enums/player-gender"; import { SpeciesId } from "#enums/species-id"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; @@ -45,44 +30,6 @@ describe("Test 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); @@ -107,7 +54,7 @@ describe("Test 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 +82,6 @@ describe("Test 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("2vs1", async () => { game.override.battleStyle("single"); game.override.enemySpecies(SpeciesId.MIGHTYENA); @@ -254,7 +139,7 @@ describe("Test 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"); @@ -318,7 +203,7 @@ describe("Test 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(); @@ -330,6 +215,6 @@ describe("Test Battle Phase", () => { }, () => game.isCurrentPhase(NextEncounterPhase), ); - await game.phaseInterceptor.to(SwitchPhase); + await game.phaseInterceptor.to("SwitchPhase"); }); }); diff --git a/test/battle/double_battle.test.ts b/test/battle/double_battle.test.ts index 8e606a99ae0..28aa2371a6d 100644 --- a/test/battle/double_battle.test.ts +++ b/test/battle/double_battle.test.ts @@ -2,8 +2,6 @@ import { Status } from "#app/data/status-effect"; import { AbilityId } from "#enums/ability-id"; import { getGameMode } from "#app/game-mode"; import { GameModes } from "#enums/game-modes"; -import { BattleEndPhase } from "#app/phases/battle-end-phase"; -import { TurnInitPhase } from "#app/phases/turn-init-phase"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import { StatusEffect } from "#enums/status-effect"; @@ -48,13 +46,13 @@ describe("Double Battles", () => { await game.doKillOpponents(); - await game.phaseInterceptor.to(BattleEndPhase); + await game.phaseInterceptor.to("BattleEndPhase"); game.doSelectModifier(); const charizard = game.scene.getPlayerParty().findIndex(p => p.species.speciesId === SpeciesId.CHARIZARD); game.doRevivePokemon(charizard); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); expect(game.scene.getPlayerField().filter(p => !p.isFainted())).toHaveLength(2); }); diff --git a/test/escape-calculations.test.ts b/test/escape-calculations.test.ts index 2cc0934f7c1..676c7430e77 100644 --- a/test/escape-calculations.test.ts +++ b/test/escape-calculations.test.ts @@ -1,4 +1,4 @@ -import { AttemptRunPhase } from "#app/phases/attempt-run-phase"; +import type { AttemptRunPhase } from "#app/phases/attempt-run-phase"; import type { CommandPhase } from "#app/phases/command-phase"; import { Command } from "#enums/command"; import { NumberHolder } from "#app/utils/common"; @@ -43,7 +43,7 @@ describe("Escape chance calculations", () => { const commandPhase = game.scene.phaseManager.getCurrentPhase() as CommandPhase; commandPhase.handleCommand(Command.RUN, 0); - await game.phaseInterceptor.to(AttemptRunPhase, false); + await game.phaseInterceptor.to("AttemptRunPhase", false); const phase = game.scene.phaseManager.getCurrentPhase() as AttemptRunPhase; const escapePercentage = new NumberHolder(0); @@ -116,7 +116,7 @@ describe("Escape chance calculations", () => { const commandPhase = game.scene.phaseManager.getCurrentPhase() as CommandPhase; commandPhase.handleCommand(Command.RUN, 0); - await game.phaseInterceptor.to(AttemptRunPhase, false); + await game.phaseInterceptor.to("AttemptRunPhase", false); const phase = game.scene.phaseManager.getCurrentPhase() as AttemptRunPhase; const escapePercentage = new NumberHolder(0); @@ -195,7 +195,7 @@ describe("Escape chance calculations", () => { const commandPhase = game.scene.phaseManager.getCurrentPhase() as CommandPhase; commandPhase.handleCommand(Command.RUN, 0); - await game.phaseInterceptor.to(AttemptRunPhase, false); + await game.phaseInterceptor.to("AttemptRunPhase", false); const phase = game.scene.phaseManager.getCurrentPhase() as AttemptRunPhase; const escapePercentage = new NumberHolder(0); @@ -281,7 +281,7 @@ describe("Escape chance calculations", () => { const commandPhase = game.scene.phaseManager.getCurrentPhase() as CommandPhase; commandPhase.handleCommand(Command.RUN, 0); - await game.phaseInterceptor.to(AttemptRunPhase, false); + await game.phaseInterceptor.to("AttemptRunPhase", false); const phase = game.scene.phaseManager.getCurrentPhase() as AttemptRunPhase; const escapePercentage = new NumberHolder(0); diff --git a/test/items/dire_hit.test.ts b/test/items/dire_hit.test.ts index 25fe9c8b876..d6c219a4512 100644 --- a/test/items/dire_hit.test.ts +++ b/test/items/dire_hit.test.ts @@ -1,17 +1,14 @@ -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import GameManager from "#test/testUtils/gameManager"; import Phase from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { BattleEndPhase } from "#app/phases/battle-end-phase"; import { TempCritBoosterModifier } from "#app/modifier/modifier"; import { UiMode } from "#enums/ui-mode"; import type ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; import { Button } from "#app/enums/buttons"; import { CommandPhase } from "#app/phases/command-phase"; import { NewBattlePhase } from "#app/phases/new-battle-phase"; -import { TurnInitPhase } from "#app/phases/turn-init-phase"; import { ShopCursorTarget } from "#app/enums/shop-cursor-target"; describe("Items - Dire Hit", () => { @@ -48,7 +45,7 @@ describe("Items - Dire Hit", () => { game.move.select(MoveId.POUND); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(enemyPokemon.getCritStage).toHaveReturnedWith(1); }); @@ -62,7 +59,7 @@ describe("Items - Dire Hit", () => { await game.doKillOpponents(); - await game.phaseInterceptor.to(BattleEndPhase); + await game.phaseInterceptor.to("BattleEndPhase"); const modifier = game.scene.findModifier(m => m instanceof TempCritBoosterModifier) as TempCritBoosterModifier; expect(modifier.getBattleCount()).toBe(4); @@ -82,7 +79,7 @@ describe("Items - Dire Hit", () => { true, ); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); // Making sure only one booster is in the modifier list even after picking up another let count = 0; diff --git a/test/items/leek.test.ts b/test/items/leek.test.ts index eedb6667b9b..b04f7324516 100644 --- a/test/items/leek.test.ts +++ b/test/items/leek.test.ts @@ -1,4 +1,3 @@ -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { randInt } from "#app/utils/common"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -40,7 +39,7 @@ describe("Items - Leek", () => { game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(enemyMember.getCritStage).toHaveReturnedWith(2); }); @@ -54,7 +53,7 @@ describe("Items - Leek", () => { game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(enemyMember.getCritStage).toHaveReturnedWith(2); }); @@ -68,7 +67,7 @@ describe("Items - Leek", () => { game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(enemyMember.getCritStage).toHaveReturnedWith(2); }); @@ -96,7 +95,7 @@ describe("Items - Leek", () => { game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(enemyMember.getCritStage).toHaveReturnedWith(2); }); @@ -124,7 +123,7 @@ describe("Items - Leek", () => { game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(enemyMember.getCritStage).toHaveReturnedWith(2); }); @@ -138,7 +137,7 @@ describe("Items - Leek", () => { game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(enemyMember.getCritStage).toHaveReturnedWith(0); }); diff --git a/test/items/leftovers.test.ts b/test/items/leftovers.test.ts index 21319d2c9d7..d91daf4cc9a 100644 --- a/test/items/leftovers.test.ts +++ b/test/items/leftovers.test.ts @@ -1,5 +1,3 @@ -import { DamageAnimPhase } from "#app/phases/damage-anim-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -48,13 +46,13 @@ describe("Items - Leftovers", () => { game.move.select(MoveId.SPLASH); // We should have less hp after the attack - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp()); const leadHpAfterDamage = leadPokemon.hp; // Check if leftovers heal us - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.hp).toBeGreaterThan(leadHpAfterDamage); }); }); diff --git a/test/items/scope_lens.test.ts b/test/items/scope_lens.test.ts index 16be8aab930..fdf1349c3ef 100644 --- a/test/items/scope_lens.test.ts +++ b/test/items/scope_lens.test.ts @@ -1,4 +1,3 @@ -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import GameManager from "#test/testUtils/gameManager"; @@ -39,7 +38,7 @@ describe("Items - Scope Lens", () => { game.move.select(MoveId.POUND); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(enemyPokemon.getCritStage).toHaveReturnedWith(1); }); diff --git a/test/items/temp_stat_stage_booster.test.ts b/test/items/temp_stat_stage_booster.test.ts index b8cd0cde4eb..94ec4357474 100644 --- a/test/items/temp_stat_stage_booster.test.ts +++ b/test/items/temp_stat_stage_booster.test.ts @@ -4,7 +4,6 @@ import { SpeciesId } from "#enums/species-id"; import Phase from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { MoveId } from "#enums/move-id"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { AbilityId } from "#enums/ability-id"; import { TempStatStageBoosterModifier } from "#app/modifier/modifier"; import { UiMode } from "#enums/ui-mode"; @@ -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/moves/after_you.test.ts b/test/moves/after_you.test.ts index 37186dcc7a5..505a38a2b77 100644 --- a/test/moves/after_you.test.ts +++ b/test/moves/after_you.test.ts @@ -1,7 +1,7 @@ import { BattlerIndex } from "#enums/battler-index"; import { AbilityId } from "#enums/ability-id"; import { MoveResult } from "#enums/move-result"; -import { MovePhase } from "#app/phases/move-phase"; +import type { MovePhase } from "#app/phases/move-phase"; import { MoveUseMode } from "#enums/move-use-mode"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -42,7 +42,7 @@ describe("Moves - After You", () => { game.move.select(MoveId.SPLASH, 1); await game.phaseInterceptor.to("MoveEffectPhase"); - await game.phaseInterceptor.to(MovePhase, false); + await game.phaseInterceptor.to("MovePhase", false); const phase = game.scene.phaseManager.getCurrentPhase() as MovePhase; expect(phase.pokemon).toBe(game.scene.getPlayerField()[1]); await game.phaseInterceptor.to("MoveEndPhase"); @@ -57,7 +57,7 @@ describe("Moves - After You", () => { await game.phaseInterceptor.to("MoveEndPhase"); await game.phaseInterceptor.to("MoveEndPhase"); - await game.phaseInterceptor.to(MovePhase); + await game.phaseInterceptor.to("MovePhase"); expect(game.scene.getPlayerField()[1].getLastXMoves(1)[0].result).toBe(MoveResult.FAIL); }); diff --git a/test/moves/alluring_voice.test.ts b/test/moves/alluring_voice.test.ts index ba096391f1b..9ff6ee59b16 100644 --- a/test/moves/alluring_voice.test.ts +++ b/test/moves/alluring_voice.test.ts @@ -1,7 +1,6 @@ import { BattlerIndex } from "#enums/battler-index"; import { AbilityId } from "#enums/ability-id"; import { BattlerTagType } from "#app/enums/battler-tag-type"; -import { BerryPhase } from "#app/phases/berry-phase"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import GameManager from "#test/testUtils/gameManager"; @@ -42,7 +41,7 @@ describe("Moves - Alluring Voice", () => { game.move.use(MoveId.ALLURING_VOICE); await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); - await game.phaseInterceptor.to(BerryPhase); + await game.phaseInterceptor.to("BerryPhase"); expect(enemy.getTag(BattlerTagType.CONFUSED)?.tagType).toBe("CONFUSED"); }); diff --git a/test/moves/aromatherapy.test.ts b/test/moves/aromatherapy.test.ts index bfe315a1390..b1c0de4f46d 100644 --- a/test/moves/aromatherapy.test.ts +++ b/test/moves/aromatherapy.test.ts @@ -1,5 +1,4 @@ import { StatusEffect } from "#app/enums/status-effect"; -import { CommandPhase } from "#app/phases/command-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -40,7 +39,7 @@ describe("Moves - Aromatherapy", () => { vi.spyOn(partyPokemon, "resetStatus"); game.move.select(MoveId.AROMATHERAPY, 0); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SPLASH, 1); await game.toNextTurn(); @@ -62,7 +61,7 @@ describe("Moves - Aromatherapy", () => { vi.spyOn(rightOpp, "resetStatus"); game.move.select(MoveId.AROMATHERAPY, 0); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SPLASH, 1); await game.toNextTurn(); @@ -86,7 +85,7 @@ describe("Moves - Aromatherapy", () => { vi.spyOn(partyPokemon, "resetStatus"); game.move.select(MoveId.AROMATHERAPY, 0); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SPLASH, 1); await game.toNextTurn(); diff --git a/test/moves/assist.test.ts b/test/moves/assist.test.ts index 27aa5528f17..9e31f940c0e 100644 --- a/test/moves/assist.test.ts +++ b/test/moves/assist.test.ts @@ -1,7 +1,6 @@ import { BattlerIndex } from "#enums/battler-index"; import { Stat } from "#app/enums/stat"; import { MoveResult } from "#enums/move-result"; -import { CommandPhase } from "#app/phases/command-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -80,7 +79,7 @@ describe("Moves - Assist", () => { // Player uses Sketch to copy Swords Dance, Player_2 stalls a turn. Player will attempt Assist and should have no usable moves await game.toNextTurn(); game.move.select(MoveId.ASSIST, 0); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.PROTECT, 1); await game.toNextTurn(); @@ -96,7 +95,7 @@ describe("Moves - Assist", () => { game.move.changeMoveset(shuckle, [MoveId.ASSIST, MoveId.SKETCH, MoveId.PROTECT, MoveId.DRAGON_TAIL]); game.move.select(MoveId.ASSIST, 0); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.ASSIST, 1); await game.toNextTurn(); diff --git a/test/moves/astonish.test.ts b/test/moves/astonish.test.ts index 48deadf7a01..c3df446e80d 100644 --- a/test/moves/astonish.test.ts +++ b/test/moves/astonish.test.ts @@ -1,9 +1,5 @@ import { allMoves } from "#app/data/data-lists"; import { BattlerTagType } from "#app/enums/battler-tag-type"; -import { BerryPhase } from "#app/phases/berry-phase"; -import { CommandPhase } from "#app/phases/command-phase"; -import { MoveEndPhase } from "#app/phases/move-end-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -48,20 +44,20 @@ describe("Moves - Astonish", () => { game.move.select(MoveId.ASTONISH); - await game.phaseInterceptor.to(MoveEndPhase, false); + await game.phaseInterceptor.to("MoveEndPhase", false); expect(enemyPokemon.getTag(BattlerTagType.FLINCHED)).toBeDefined(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); expect(enemyPokemon.getTag(BattlerTagType.FLINCHED)).toBeUndefined(); - await game.phaseInterceptor.to(CommandPhase, false); + await game.phaseInterceptor.to("CommandPhase", false); game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp()); }); diff --git a/test/moves/aurora_veil.test.ts b/test/moves/aurora_veil.test.ts index b9ae79e4155..2b4e97cefc9 100644 --- a/test/moves/aurora_veil.test.ts +++ b/test/moves/aurora_veil.test.ts @@ -4,7 +4,6 @@ import type Move from "#app/data/moves/move"; import { allMoves } from "#app/data/data-lists"; import { ArenaTagType } from "#app/enums/arena-tag-type"; import type Pokemon from "#app/field/pokemon"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { NumberHolder } from "#app/utils/common"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; @@ -52,7 +51,7 @@ describe("Moves - Aurora Veil", () => { game.move.select(moveToUse); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const mockedDmg = getMockedMoveDamage( game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, @@ -71,7 +70,7 @@ describe("Moves - Aurora Veil", () => { game.move.select(moveToUse); game.move.select(moveToUse, 1); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const mockedDmg = getMockedMoveDamage( game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, @@ -87,7 +86,7 @@ describe("Moves - Aurora Veil", () => { game.move.select(moveToUse); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const mockedDmg = getMockedMoveDamage( game.scene.getEnemyPokemon()!, @@ -107,7 +106,7 @@ describe("Moves - Aurora Veil", () => { game.move.select(moveToUse); game.move.select(moveToUse, 1); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const mockedDmg = getMockedMoveDamage( game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, @@ -123,7 +122,7 @@ describe("Moves - Aurora Veil", () => { await game.classicMode.startBattle([SpeciesId.SHUCKLE]); game.move.select(moveToUse); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const mockedDmg = getMockedMoveDamage( game.scene.getEnemyPokemon()!, @@ -140,7 +139,7 @@ describe("Moves - Aurora Veil", () => { await game.classicMode.startBattle([SpeciesId.SHUCKLE]); game.move.select(moveToUse); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const mockedDmg = getMockedMoveDamage( game.scene.getEnemyPokemon()!, diff --git a/test/moves/beak_blast.test.ts b/test/moves/beak_blast.test.ts index 2cb9f9bdd6f..887ceb75ed4 100644 --- a/test/moves/beak_blast.test.ts +++ b/test/moves/beak_blast.test.ts @@ -1,8 +1,5 @@ import { BattlerTagType } from "#app/enums/battler-tag-type"; import { StatusEffect } from "#app/enums/status-effect"; -import { BerryPhase } from "#app/phases/berry-phase"; -import { MovePhase } from "#app/phases/move-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -45,10 +42,10 @@ describe("Moves - Beak Blast", () => { game.move.select(MoveId.BEAK_BLAST); - await game.phaseInterceptor.to(MovePhase, false); + await game.phaseInterceptor.to("MovePhase", false); expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeDefined(); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.status?.effect).toBe(StatusEffect.BURN); }); @@ -62,10 +59,10 @@ describe("Moves - Beak Blast", () => { game.move.select(MoveId.BEAK_BLAST); - await game.phaseInterceptor.to(MovePhase, false); + await game.phaseInterceptor.to("MovePhase", false); expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeDefined(); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.status?.effect).toBe(StatusEffect.BURN); }); @@ -79,10 +76,10 @@ describe("Moves - Beak Blast", () => { game.move.select(MoveId.BEAK_BLAST); - await game.phaseInterceptor.to(MovePhase, false); + await game.phaseInterceptor.to("MovePhase", false); expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeDefined(); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.status?.effect).not.toBe(StatusEffect.BURN); }); @@ -95,7 +92,7 @@ describe("Moves - Beak Blast", () => { game.move.select(MoveId.BEAK_BLAST); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(leadPokemon.turnData.hitCount).toBe(2); }); @@ -109,10 +106,10 @@ describe("Moves - Beak Blast", () => { game.move.select(MoveId.BEAK_BLAST); - await game.phaseInterceptor.to(MovePhase, false); + await game.phaseInterceptor.to("MovePhase", false); expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeDefined(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeUndefined(); }); diff --git a/test/moves/beat_up.test.ts b/test/moves/beat_up.test.ts index 7c4686ab4fa..10b1060862b 100644 --- a/test/moves/beat_up.test.ts +++ b/test/moves/beat_up.test.ts @@ -2,7 +2,6 @@ import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import { StatusEffect } from "#app/enums/status-effect"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; @@ -49,14 +48,14 @@ describe("Moves - Beat Up", () => { game.move.select(MoveId.BEAT_UP); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(playerPokemon.turnData.hitCount).toBe(6); expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp); while (playerPokemon.turnData.hitsLeft > 0) { enemyStartingHp = enemyPokemon.hp; - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp); } }); @@ -77,7 +76,7 @@ describe("Moves - Beat Up", () => { game.move.select(MoveId.BEAT_UP); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(playerPokemon.turnData.hitCount).toBe(5); }); diff --git a/test/moves/belly_drum.test.ts b/test/moves/belly_drum.test.ts index 239b3c3d794..84bd2b156b9 100644 --- a/test/moves/belly_drum.test.ts +++ b/test/moves/belly_drum.test.ts @@ -1,4 +1,3 @@ -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { toDmgValue } from "#app/utils/common"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -48,7 +47,7 @@ describe("Moves - BELLY DRUM", () => { const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); game.move.select(MoveId.BELLY_DRUM); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); expect(leadPokemon.getStatStage(Stat.ATK)).toBe(6); @@ -65,7 +64,7 @@ describe("Moves - BELLY DRUM", () => { leadPokemon.setStatStage(Stat.SPATK, 6); game.move.select(MoveId.BELLY_DRUM); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); expect(leadPokemon.getStatStage(Stat.ATK)).toBe(6); @@ -80,7 +79,7 @@ describe("Moves - BELLY DRUM", () => { leadPokemon.setStatStage(Stat.ATK, 6); game.move.select(MoveId.BELLY_DRUM); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); expect(leadPokemon.getStatStage(Stat.ATK)).toBe(6); @@ -94,7 +93,7 @@ describe("Moves - BELLY DRUM", () => { leadPokemon.hp = hpLost - PREDAMAGE; game.move.select(MoveId.BELLY_DRUM); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.hp).toBe(hpLost - PREDAMAGE); expect(leadPokemon.getStatStage(Stat.ATK)).toBe(0); diff --git a/test/moves/ceaseless_edge.test.ts b/test/moves/ceaseless_edge.test.ts index 1dec98fe3a8..23959f347a7 100644 --- a/test/moves/ceaseless_edge.test.ts +++ b/test/moves/ceaseless_edge.test.ts @@ -3,8 +3,6 @@ import { ArenaTagSide } from "#enums/arena-tag-side"; import { allMoves } from "#app/data/data-lists"; import { AbilityId } from "#enums/ability-id"; import { ArenaTagType } from "#app/enums/arena-tag-type"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import GameManager from "#test/testUtils/gameManager"; @@ -48,12 +46,12 @@ describe("Moves - Ceaseless Edge", () => { game.move.select(MoveId.CEASELESS_EDGE); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); // Spikes should not have any layers before move effect is applied const tagBefore = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag; expect(tagBefore instanceof ArenaTrapTag).toBeFalsy(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const tagAfter = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag; expect(tagAfter instanceof ArenaTrapTag).toBeTruthy(); expect(tagAfter.layers).toBe(1); @@ -70,12 +68,12 @@ describe("Moves - Ceaseless Edge", () => { game.move.select(MoveId.CEASELESS_EDGE); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); // Spikes should not have any layers before move effect is applied const tagBefore = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag; expect(tagBefore instanceof ArenaTrapTag).toBeFalsy(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const tagAfter = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag; expect(tagAfter instanceof ArenaTrapTag).toBeTruthy(); expect(tagAfter.layers).toBe(2); @@ -88,7 +86,7 @@ describe("Moves - Ceaseless Edge", () => { await game.classicMode.startBattle([SpeciesId.ILLUMISE]); game.move.select(MoveId.CEASELESS_EDGE); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); // Spikes should not have any layers before move effect is applied const tagBefore = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag; expect(tagBefore instanceof ArenaTrapTag).toBeFalsy(); @@ -102,7 +100,7 @@ describe("Moves - Ceaseless Edge", () => { // Check HP of pokemon that WILL BE switched in (index 1) game.forceEnemyToSwitch(); game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase, false); + await game.phaseInterceptor.to("TurnEndPhase", false); expect(game.scene.currentBattle.enemyParty[0].hp).toBeLessThan(hpBeforeSpikes); }); }); diff --git a/test/moves/clangorous_soul.test.ts b/test/moves/clangorous_soul.test.ts index f08503acdc6..2d2c25c4384 100644 --- a/test/moves/clangorous_soul.test.ts +++ b/test/moves/clangorous_soul.test.ts @@ -1,7 +1,6 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import Phaser from "phaser"; import GameManager from "#test/testUtils/gameManager"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import { Stat } from "#enums/stat"; @@ -45,7 +44,7 @@ describe("Moves - Clangorous Soul", () => { const hpLost = Math.floor(leadPokemon.getMaxHp() / RATIO); game.move.select(MoveId.CLANGOROUS_SOUL); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); expect(leadPokemon.getStatStage(Stat.ATK)).toBe(1); @@ -68,7 +67,7 @@ describe("Moves - Clangorous Soul", () => { leadPokemon.setStatStage(Stat.SPDEF, 4); game.move.select(MoveId.CLANGOROUS_SOUL); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); expect(leadPokemon.getStatStage(Stat.ATK)).toBe(6); @@ -90,7 +89,7 @@ describe("Moves - Clangorous Soul", () => { leadPokemon.setStatStage(Stat.SPD, 6); game.move.select(MoveId.CLANGOROUS_SOUL); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); expect(leadPokemon.getStatStage(Stat.ATK)).toBe(6); @@ -108,7 +107,7 @@ describe("Moves - Clangorous Soul", () => { leadPokemon.hp = hpLost - PREDAMAGE; game.move.select(MoveId.CLANGOROUS_SOUL); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.hp).toBe(hpLost - PREDAMAGE); expect(leadPokemon.getStatStage(Stat.ATK)).toBe(0); diff --git a/test/moves/crafty_shield.test.ts b/test/moves/crafty_shield.test.ts index 12a607a2a1b..edf0292aa3b 100644 --- a/test/moves/crafty_shield.test.ts +++ b/test/moves/crafty_shield.test.ts @@ -6,8 +6,6 @@ import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { Stat } from "#enums/stat"; import { BattlerTagType } from "#app/enums/battler-tag-type"; -import { BerryPhase } from "#app/phases/berry-phase"; -import { CommandPhase } from "#app/phases/command-phase"; describe("Moves - Crafty Shield", () => { let phaserGame: Phaser.Game; @@ -43,11 +41,11 @@ describe("Moves - Crafty Shield", () => { game.move.select(MoveId.CRAFTY_SHIELD); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); leadPokemon.forEach(p => expect(p.getStatStage(Stat.ATK)).toBe(0)); }); @@ -61,11 +59,11 @@ describe("Moves - Crafty Shield", () => { game.move.select(MoveId.CRAFTY_SHIELD); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(leadPokemon.some(p => p.hp < p.getMaxHp())).toBeTruthy(); }); @@ -79,11 +77,11 @@ describe("Moves - Crafty Shield", () => { game.move.select(MoveId.CRAFTY_SHIELD); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); leadPokemon.forEach(p => expect(p.getTag(BattlerTagType.CURSED)).toBeUndefined()); }); @@ -95,11 +93,11 @@ describe("Moves - Crafty Shield", () => { game.move.select(MoveId.CRAFTY_SHIELD); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SWORDS_DANCE, 1); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(leadPokemon[0].getStatStage(Stat.ATK)).toBe(0); expect(leadPokemon[1].getStatStage(Stat.ATK)).toBe(2); diff --git a/test/moves/double_team.test.ts b/test/moves/double_team.test.ts index d1f6c5be3e4..5ac94f25400 100644 --- a/test/moves/double_team.test.ts +++ b/test/moves/double_team.test.ts @@ -1,6 +1,5 @@ import { Stat } from "#enums/stat"; import { AbilityId } from "#enums/ability-id"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import GameManager from "#test/testUtils/gameManager"; @@ -43,7 +42,7 @@ describe("Moves - Double Team", () => { expect(ally.getStatStage(Stat.EVA)).toBe(0); game.move.select(MoveId.DOUBLE_TEAM); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); await game.toNextTurn(); expect(ally.getStatStage(Stat.EVA)).toBe(1); diff --git a/test/moves/dragon_rage.test.ts b/test/moves/dragon_rage.test.ts index c5bed3377fa..ca816b9b291 100644 --- a/test/moves/dragon_rage.test.ts +++ b/test/moves/dragon_rage.test.ts @@ -1,7 +1,6 @@ import { Stat } from "#enums/stat"; import { PokemonType } from "#enums/pokemon-type"; import type { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { AbilityId } from "#enums/ability-id"; import { BattlerTagType } from "#enums/battler-tag-type"; import { MoveId } from "#enums/move-id"; @@ -55,7 +54,7 @@ describe("Moves - Dragon Rage", () => { vi.spyOn(enemyPokemon, "getTypes").mockReturnValue([PokemonType.DRAGON]); game.move.select(MoveId.DRAGON_RAGE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(enemyPokemon.getInverseHp()).toBe(dragonRageDamage); }); @@ -65,7 +64,7 @@ describe("Moves - Dragon Rage", () => { vi.spyOn(enemyPokemon, "getTypes").mockReturnValue([PokemonType.STEEL]); game.move.select(MoveId.DRAGON_RAGE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(enemyPokemon.getInverseHp()).toBe(dragonRageDamage); }); @@ -75,7 +74,7 @@ describe("Moves - Dragon Rage", () => { partyPokemon.setStatStage(Stat.SPATK, 2); game.move.select(MoveId.DRAGON_RAGE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(enemyPokemon.getInverseHp()).toBe(dragonRageDamage); }); @@ -85,7 +84,7 @@ describe("Moves - Dragon Rage", () => { vi.spyOn(partyPokemon, "getTypes").mockReturnValue([PokemonType.DRAGON]); game.move.select(MoveId.DRAGON_RAGE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(enemyPokemon.getInverseHp()).toBe(dragonRageDamage); }); @@ -94,7 +93,7 @@ describe("Moves - Dragon Rage", () => { partyPokemon.addTag(BattlerTagType.ALWAYS_CRIT, 99); game.move.select(MoveId.DRAGON_RAGE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(enemyPokemon.getInverseHp()).toBe(dragonRageDamage); }); @@ -103,7 +102,7 @@ describe("Moves - Dragon Rage", () => { game.override.criticalHits(false).enemyAbility(AbilityId.ICE_SCALES); game.move.select(MoveId.DRAGON_RAGE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(enemyPokemon.getInverseHp()).toBe(dragonRageDamage); }); diff --git a/test/moves/dynamax_cannon.test.ts b/test/moves/dynamax_cannon.test.ts index 3febf918de8..f12cf9b745a 100644 --- a/test/moves/dynamax_cannon.test.ts +++ b/test/moves/dynamax_cannon.test.ts @@ -1,7 +1,6 @@ import { BattlerIndex } from "#enums/battler-index"; import { allMoves } from "#app/data/data-lists"; -import { DamageAnimPhase } from "#app/phases/damage-anim-phase"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase"; +import type { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { MoveId } from "#enums/move-id"; import type Move from "#app/data/moves/move"; import { SpeciesId } from "#enums/species-id"; @@ -47,9 +46,9 @@ describe("Moves - Dynamax Cannon", () => { game.move.select(dynamaxCannon.id); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(dynamaxCannon.id); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(100); }); @@ -59,9 +58,9 @@ describe("Moves - Dynamax Cannon", () => { game.move.select(dynamaxCannon.id); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(dynamaxCannon.id); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(100); }); @@ -71,12 +70,12 @@ describe("Moves - Dynamax Cannon", () => { game.move.select(dynamaxCannon.id); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); const phase = game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase; expect(phase.move.id).toBe(dynamaxCannon.id); // Force level cap to be 100 vi.spyOn(game.scene, "getMaxExpLevel").mockReturnValue(100); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(120); }); @@ -86,12 +85,12 @@ describe("Moves - Dynamax Cannon", () => { game.move.select(dynamaxCannon.id); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); const phase = game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase; expect(phase.move.id).toBe(dynamaxCannon.id); // Force level cap to be 100 vi.spyOn(game.scene, "getMaxExpLevel").mockReturnValue(100); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(140); }); @@ -101,12 +100,12 @@ describe("Moves - Dynamax Cannon", () => { game.move.select(dynamaxCannon.id); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); const phase = game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase; expect(phase.move.id).toBe(dynamaxCannon.id); // Force level cap to be 100 vi.spyOn(game.scene, "getMaxExpLevel").mockReturnValue(100); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(160); }); @@ -116,12 +115,12 @@ describe("Moves - Dynamax Cannon", () => { game.move.select(dynamaxCannon.id); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); const phase = game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase; expect(phase.move.id).toBe(dynamaxCannon.id); // Force level cap to be 100 vi.spyOn(game.scene, "getMaxExpLevel").mockReturnValue(100); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(180); }); @@ -131,12 +130,12 @@ describe("Moves - Dynamax Cannon", () => { game.move.select(dynamaxCannon.id); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); const phase = game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase; expect(phase.move.id).toBe(dynamaxCannon.id); // Force level cap to be 100 vi.spyOn(game.scene, "getMaxExpLevel").mockReturnValue(100); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(200); }); @@ -147,9 +146,9 @@ describe("Moves - Dynamax Cannon", () => { game.move.select(dynamaxCannon.id); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); expect((game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase).move.id).toBe(dynamaxCannon.id); - await game.phaseInterceptor.to(DamageAnimPhase, false); + await game.phaseInterceptor.to("DamageAnimPhase", false); expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(200); }); }); diff --git a/test/moves/fillet_away.test.ts b/test/moves/fillet_away.test.ts index 1e00f2ee02d..9223075266f 100644 --- a/test/moves/fillet_away.test.ts +++ b/test/moves/fillet_away.test.ts @@ -1,4 +1,3 @@ -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { toDmgValue } from "#app/utils/common"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -46,7 +45,7 @@ describe("Moves - FILLET AWAY", () => { const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); game.move.select(MoveId.FILLET_AWAY); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); expect(leadPokemon.getStatStage(Stat.ATK)).toBe(2); @@ -65,7 +64,7 @@ describe("Moves - FILLET AWAY", () => { leadPokemon.setStatStage(Stat.SPATK, 3); game.move.select(MoveId.FILLET_AWAY); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); expect(leadPokemon.getStatStage(Stat.ATK)).toBe(6); @@ -83,7 +82,7 @@ describe("Moves - FILLET AWAY", () => { leadPokemon.setStatStage(Stat.SPD, 6); game.move.select(MoveId.FILLET_AWAY); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); expect(leadPokemon.getStatStage(Stat.ATK)).toBe(6); @@ -99,7 +98,7 @@ describe("Moves - FILLET AWAY", () => { leadPokemon.hp = hpLost - PREDAMAGE; game.move.select(MoveId.FILLET_AWAY); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.hp).toBe(hpLost - PREDAMAGE); expect(leadPokemon.getStatStage(Stat.ATK)).toBe(0); diff --git a/test/moves/fissure.test.ts b/test/moves/fissure.test.ts index 27031a7736d..0b52733cf8f 100644 --- a/test/moves/fissure.test.ts +++ b/test/moves/fissure.test.ts @@ -1,7 +1,5 @@ import { Stat } from "#enums/stat"; import type { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon"; -import { DamageAnimPhase } from "#app/phases/damage-anim-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import GameManager from "#test/testUtils/gameManager"; @@ -50,7 +48,7 @@ describe("Moves - Fissure", () => { game.override.ability(AbilityId.NO_GUARD).enemyAbility(AbilityId.FUR_COAT); game.move.select(MoveId.FISSURE); - await game.phaseInterceptor.to(DamageAnimPhase, true); + await game.phaseInterceptor.to("DamageAnimPhase", true); expect(enemyPokemon.isFainted()).toBe(true); }); @@ -63,7 +61,7 @@ describe("Moves - Fissure", () => { game.move.select(MoveId.FISSURE); // wait for TurnEndPhase instead of DamagePhase as fissure might not actually inflict damage - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(partyPokemon.getAccuracyMultiplier).toHaveReturnedWith(1); }); @@ -76,7 +74,7 @@ describe("Moves - Fissure", () => { game.move.select(MoveId.FISSURE); // wait for TurnEndPhase instead of DamagePhase as fissure might not actually inflict damage - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(partyPokemon.getAccuracyMultiplier).toHaveReturnedWith(1); }); diff --git a/test/moves/flame_burst.test.ts b/test/moves/flame_burst.test.ts index 0a378df1077..6565d61730a 100644 --- a/test/moves/flame_burst.test.ts +++ b/test/moves/flame_burst.test.ts @@ -1,7 +1,6 @@ import { allAbilities } from "#app/data/data-lists"; import { AbilityId } from "#enums/ability-id"; import type Pokemon from "#app/field/pokemon"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import GameManager from "#test/testUtils/gameManager"; @@ -52,7 +51,7 @@ describe("Moves - Flame Burst", () => { game.move.select(MoveId.FLAME_BURST, 0, leftEnemy.getBattlerIndex()); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leftEnemy.hp).toBeLessThan(leftEnemy.getMaxHp()); expect(rightEnemy.hp).toBe(rightEnemy.getMaxHp() - getEffectDamage(rightEnemy)); @@ -66,7 +65,7 @@ describe("Moves - Flame Burst", () => { game.move.select(MoveId.FLAME_BURST, 0, leftEnemy.getBattlerIndex()); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leftEnemy.hp).toBe(leftEnemy.getMaxHp()); expect(rightEnemy.hp).toBe(rightEnemy.getMaxHp()); @@ -80,7 +79,7 @@ describe("Moves - Flame Burst", () => { game.move.select(MoveId.FLAME_BURST, 0, leftEnemy.getBattlerIndex()); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leftEnemy.hp).toBeLessThan(leftEnemy.getMaxHp()); expect(rightEnemy.hp).toBe(rightEnemy.getMaxHp() - getEffectDamage(rightEnemy)); @@ -94,7 +93,7 @@ describe("Moves - Flame Burst", () => { game.move.select(MoveId.FLAME_BURST, 0, leftEnemy.getBattlerIndex()); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leftEnemy.hp).toBeLessThan(leftEnemy.getMaxHp()); expect(rightEnemy.hp).toBe(rightEnemy.getMaxHp()); diff --git a/test/moves/flower_shield.test.ts b/test/moves/flower_shield.test.ts index c3c5e5cf870..c09cb0c924a 100644 --- a/test/moves/flower_shield.test.ts +++ b/test/moves/flower_shield.test.ts @@ -2,7 +2,6 @@ import { Stat } from "#enums/stat"; import { SemiInvulnerableTag } from "#app/data/battler-tags"; import { PokemonType } from "#enums/pokemon-type"; import { BiomeId } from "#enums/biome-id"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -45,7 +44,7 @@ describe("Moves - Flower Shield", () => { expect(cherrim.getStatStage(Stat.DEF)).toBe(0); game.move.select(MoveId.FLOWER_SHIELD); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(magikarp.getStatStage(Stat.DEF)).toBe(0); expect(cherrim.getStatStage(Stat.DEF)).toBe(1); @@ -65,7 +64,7 @@ describe("Moves - Flower Shield", () => { game.move.select(MoveId.FLOWER_SHIELD); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); grassPokemons.forEach(p => expect(p.getStatStage(Stat.DEF)).toBe(1)); nonGrassPokemons.forEach(p => expect(p.getStatStage(Stat.DEF)).toBe(0)); @@ -86,7 +85,7 @@ describe("Moves - Flower Shield", () => { expect(paras.getTag(SemiInvulnerableTag)).toBeUndefined; game.move.select(MoveId.FLOWER_SHIELD); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(paras.getTag(SemiInvulnerableTag)).toBeDefined(); expect(paras.getStatStage(Stat.DEF)).toBe(0); @@ -104,7 +103,7 @@ describe("Moves - Flower Shield", () => { expect(ally.getStatStage(Stat.DEF)).toBe(0); game.move.select(MoveId.FLOWER_SHIELD); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(enemy.getStatStage(Stat.DEF)).toBe(0); expect(ally.getStatStage(Stat.DEF)).toBe(0); diff --git a/test/moves/focus_punch.test.ts b/test/moves/focus_punch.test.ts index 38b57b201c0..a24560edba6 100644 --- a/test/moves/focus_punch.test.ts +++ b/test/moves/focus_punch.test.ts @@ -1,8 +1,5 @@ -import { BerryPhase } from "#app/phases/berry-phase"; -import { MessagePhase } from "#app/phases/message-phase"; import { MoveHeaderPhase } from "#app/phases/move-header-phase"; import { SwitchSummonPhase } from "#app/phases/switch-summon-phase"; -import { TurnStartPhase } from "#app/phases/turn-start-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -48,12 +45,12 @@ describe("Moves - Focus Punch", () => { game.move.select(MoveId.FOCUS_PUNCH); - await game.phaseInterceptor.to(MessagePhase); + await game.phaseInterceptor.to("MessagePhase"); expect(enemyPokemon.hp).toBe(enemyStartingHp); expect(leadPokemon.getMoveHistory().length).toBe(0); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp); expect(leadPokemon.getMoveHistory().length).toBe(1); @@ -72,12 +69,12 @@ describe("Moves - Focus Punch", () => { game.move.select(MoveId.FOCUS_PUNCH); - await game.phaseInterceptor.to(MessagePhase); + await game.phaseInterceptor.to("MessagePhase"); expect(enemyPokemon.hp).toBe(enemyStartingHp); expect(leadPokemon.getMoveHistory().length).toBe(0); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.hp).toBe(enemyStartingHp); expect(leadPokemon.getMoveHistory().length).toBe(1); @@ -94,11 +91,11 @@ describe("Moves - Focus Punch", () => { game.move.select(MoveId.FOCUS_PUNCH); - await game.phaseInterceptor.to(MessagePhase); // Header message + await game.phaseInterceptor.to("MessagePhase"); // Header message expect(leadPokemon.getMoveHistory().length).toBe(0); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(leadPokemon.getMoveHistory().length).toBe(1); expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); @@ -113,7 +110,7 @@ describe("Moves - Focus Punch", () => { game.forceEnemyToSwitch(); game.move.select(MoveId.FOCUS_PUNCH); - await game.phaseInterceptor.to(TurnStartPhase); + await game.phaseInterceptor.to("TurnStartPhase"); expect(game.scene.phaseManager.getCurrentPhase() instanceof SwitchSummonPhase).toBeTruthy(); expect(game.scene.phaseManager.phaseQueue.find(phase => phase instanceof MoveHeaderPhase)).toBeDefined(); diff --git a/test/moves/follow_me.test.ts b/test/moves/follow_me.test.ts index a99ac0b6c00..e5e6d0a888d 100644 --- a/test/moves/follow_me.test.ts +++ b/test/moves/follow_me.test.ts @@ -1,7 +1,6 @@ import { Stat } from "#enums/stat"; import { BattlerIndex } from "#enums/battler-index"; import { AbilityId } from "#enums/ability-id"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import GameManager from "#test/testUtils/gameManager"; @@ -47,7 +46,7 @@ describe("Moves - Follow Me", () => { await game.move.selectEnemyMove(MoveId.TACKLE, BattlerIndex.PLAYER_2); await game.move.selectEnemyMove(MoveId.TACKLE, BattlerIndex.PLAYER_2); - await game.phaseInterceptor.to(TurnEndPhase, false); + await game.phaseInterceptor.to("TurnEndPhase", false); expect(playerPokemon[0].hp).toBeLessThan(playerPokemon[0].getMaxHp()); expect(playerPokemon[1].hp).toBe(playerPokemon[1].getMaxHp()); @@ -65,7 +64,7 @@ describe("Moves - Follow Me", () => { await game.move.selectEnemyMove(MoveId.TACKLE, BattlerIndex.PLAYER); await game.move.selectEnemyMove(MoveId.TACKLE, BattlerIndex.PLAYER_2); - await game.phaseInterceptor.to(TurnEndPhase, false); + await game.phaseInterceptor.to("TurnEndPhase", false); playerPokemon.sort((a, b) => a.getEffectiveStat(Stat.SPD) - b.getEffectiveStat(Stat.SPD)); @@ -87,7 +86,7 @@ describe("Moves - Follow Me", () => { await game.move.selectEnemyMove(MoveId.FOLLOW_ME); await game.move.selectEnemyMove(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase, false); + await game.phaseInterceptor.to("TurnEndPhase", false); // If redirection was bypassed, both enemies should be damaged expect(enemyPokemon[0].hp).toBeLessThan(enemyPokemon[0].getMaxHp()); @@ -107,7 +106,7 @@ describe("Moves - Follow Me", () => { await game.move.selectEnemyMove(MoveId.FOLLOW_ME); await game.move.selectEnemyMove(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase, false); + await game.phaseInterceptor.to("TurnEndPhase", false); // If redirection was bypassed, both enemies should be damaged expect(enemyPokemon[0].hp).toBeLessThan(enemyPokemon[0].getMaxHp()); diff --git a/test/moves/foresight.test.ts b/test/moves/foresight.test.ts index 96a341582f9..4e381b2b640 100644 --- a/test/moves/foresight.test.ts +++ b/test/moves/foresight.test.ts @@ -1,6 +1,5 @@ import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; @@ -48,7 +47,7 @@ describe("Moves - Foresight", () => { enemy.hp = enemy.getMaxHp(); game.move.select(MoveId.MACH_PUNCH); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(enemy.hp).toBeLessThan(enemy.getMaxHp()); }); @@ -63,7 +62,7 @@ describe("Moves - Foresight", () => { game.move.select(MoveId.FORESIGHT); await game.toNextTurn(); game.move.select(MoveId.QUICK_ATTACK); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(pokemon.getAccuracyMultiplier).toHaveReturnedWith(1); }); diff --git a/test/moves/freezy_frost.test.ts b/test/moves/freezy_frost.test.ts index 55f67de085f..c96014c6ec2 100644 --- a/test/moves/freezy_frost.test.ts +++ b/test/moves/freezy_frost.test.ts @@ -6,7 +6,6 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { allMoves } from "#app/data/data-lists"; -import { CommandPhase } from "#app/phases/command-phase"; describe("Moves - Freezy Frost", () => { let phaserGame: Phaser.Game; @@ -77,7 +76,7 @@ describe("Moves - Freezy Frost", () => { const [leftOpp, rightOpp] = game.scene.getEnemyField(); game.move.select(MoveId.HOWL, 0); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SPLASH, 1); await game.toNextTurn(); @@ -87,7 +86,7 @@ describe("Moves - Freezy Frost", () => { expect(rightOpp.getStatStage(Stat.ATK)).toBe(2); game.move.select(MoveId.FREEZY_FROST, 0, leftOpp.getBattlerIndex()); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SPLASH, 1); await game.toNextTurn(); diff --git a/test/moves/fusion_flare.test.ts b/test/moves/fusion_flare.test.ts index c0df347fcce..b468b0b56ec 100644 --- a/test/moves/fusion_flare.test.ts +++ b/test/moves/fusion_flare.test.ts @@ -1,4 +1,3 @@ -import { TurnStartPhase } from "#app/phases/turn-start-phase"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import { StatusEffect } from "#enums/status-effect"; @@ -41,7 +40,7 @@ describe("Moves - Fusion Flare", () => { game.move.select(fusionFlare); - await game.phaseInterceptor.to(TurnStartPhase, false); + await game.phaseInterceptor.to("TurnStartPhase", false); // Inflict freeze quietly and check if it was properly inflicted partyMember.trySetStatus(StatusEffect.FREEZE, false); diff --git a/test/moves/fusion_flare_bolt.test.ts b/test/moves/fusion_flare_bolt.test.ts index 1967e9f12d1..716eba9fd4e 100644 --- a/test/moves/fusion_flare_bolt.test.ts +++ b/test/moves/fusion_flare_bolt.test.ts @@ -2,10 +2,7 @@ import { Stat } from "#enums/stat"; import { BattlerIndex } from "#enums/battler-index"; import { allMoves } from "#app/data/data-lists"; import type Move from "#app/data/moves/move"; -import { DamageAnimPhase } from "#app/phases/damage-anim-phase"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase"; -import { MoveEndPhase } from "#app/phases/move-end-phase"; -import { MovePhase } from "#app/phases/move-phase"; +import type { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import GameManager from "#test/testUtils/gameManager"; @@ -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 6eec30be49f..0a5386b885c 100644 --- a/test/moves/growth.test.ts +++ b/test/moves/growth.test.ts @@ -5,8 +5,6 @@ import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { EnemyCommandPhase } from "#app/phases/enemy-command-phase"; -import { TurnInitPhase } from "#app/phases/turn-init-phase"; describe("Moves - Growth", () => { let phaserGame: Phaser.Game; @@ -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/guard_split.test.ts b/test/moves/guard_split.test.ts index 878bb80f251..df08a642278 100644 --- a/test/moves/guard_split.test.ts +++ b/test/moves/guard_split.test.ts @@ -2,7 +2,6 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import Phaser from "phaser"; import GameManager from "#test/testUtils/gameManager"; import { SpeciesId } from "#enums/species-id"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { MoveId } from "#enums/move-id"; import { Stat } from "#enums/stat"; import { AbilityId } from "#enums/ability-id"; @@ -43,7 +42,7 @@ describe("Moves - Guard Split", () => { const avgSpDef = Math.floor((player.getStat(Stat.SPDEF, false) + enemy.getStat(Stat.SPDEF, false)) / 2); game.move.select(MoveId.GUARD_SPLIT); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(player.getStat(Stat.DEF, false)).toBe(avgDef); expect(enemy.getStat(Stat.DEF, false)).toBe(avgDef); @@ -63,10 +62,10 @@ describe("Moves - Guard Split", () => { const avgSpDef = Math.floor((player.getStat(Stat.SPDEF, false) + enemy.getStat(Stat.SPDEF, false)) / 2); game.move.select(MoveId.GUARD_SPLIT); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); game.move.select(MoveId.GUARD_SPLIT); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(player.getStat(Stat.DEF, false)).toBe(avgDef); expect(enemy.getStat(Stat.DEF, false)).toBe(avgDef); diff --git a/test/moves/guard_swap.test.ts b/test/moves/guard_swap.test.ts index d2c33e45df0..8441e3c8a12 100644 --- a/test/moves/guard_swap.test.ts +++ b/test/moves/guard_swap.test.ts @@ -2,11 +2,9 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vite import Phaser from "phaser"; import GameManager from "#test/testUtils/gameManager"; import { SpeciesId } from "#enums/species-id"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { MoveId } from "#enums/move-id"; import { Stat, BATTLE_STATS } from "#enums/stat"; import { AbilityId } from "#enums/ability-id"; -import { MoveEndPhase } from "#app/phases/move-end-phase"; describe("Moves - Guard Swap", () => { let phaserGame: Phaser.Game; @@ -43,14 +41,14 @@ describe("Moves - Guard Swap", () => { game.move.select(MoveId.GUARD_SWAP); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); for (const s of BATTLE_STATS) { expect(player.getStatStage(s)).toBe(0); expect(enemy.getStatStage(s)).toBe(1); } - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); for (const s of BATTLE_STATS) { if (s === Stat.DEF || s === Stat.SPDEF) { diff --git a/test/moves/hard_press.test.ts b/test/moves/hard_press.test.ts index e57c9af981f..e89a81d414c 100644 --- a/test/moves/hard_press.test.ts +++ b/test/moves/hard_press.test.ts @@ -1,5 +1,4 @@ import { allMoves } from "#app/data/data-lists"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -41,7 +40,7 @@ describe("Moves - Hard Press", () => { await game.classicMode.startBattle([SpeciesId.PIKACHU]); game.move.select(MoveId.HARD_PRESS); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(100); }); @@ -54,7 +53,7 @@ describe("Moves - Hard Press", () => { vi.spyOn(enemy, "getHpRatio").mockReturnValue(targetHpRatio); game.move.select(MoveId.HARD_PRESS); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(50); }); @@ -67,7 +66,7 @@ describe("Moves - Hard Press", () => { vi.spyOn(enemy, "getHpRatio").mockReturnValue(targetHpRatio); game.move.select(MoveId.HARD_PRESS); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(1); }); @@ -80,7 +79,7 @@ describe("Moves - Hard Press", () => { vi.spyOn(enemy, "getHpRatio").mockReturnValue(targetHpRatio); game.move.select(MoveId.HARD_PRESS); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(1); }); diff --git a/test/moves/haze.test.ts b/test/moves/haze.test.ts index f3e3dafae0a..18b48792c41 100644 --- a/test/moves/haze.test.ts +++ b/test/moves/haze.test.ts @@ -5,7 +5,6 @@ import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { TurnInitPhase } from "#app/phases/turn-init-phase"; describe("Moves - Haze", () => { describe("integration tests", () => { @@ -43,16 +42,16 @@ describe("Moves - Haze", () => { expect(enemy.getStatStage(Stat.ATK)).toBe(0); game.move.select(MoveId.SWORDS_DANCE); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); game.move.select(MoveId.CHARM); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); expect(user.getStatStage(Stat.ATK)).toBe(2); expect(enemy.getStatStage(Stat.ATK)).toBe(-2); game.move.select(MoveId.HAZE); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); expect(user.getStatStage(Stat.ATK)).toBe(0); expect(enemy.getStatStage(Stat.ATK)).toBe(0); diff --git a/test/moves/heal_bell.test.ts b/test/moves/heal_bell.test.ts index 914307b4795..c23baa15366 100644 --- a/test/moves/heal_bell.test.ts +++ b/test/moves/heal_bell.test.ts @@ -1,5 +1,4 @@ import { StatusEffect } from "#app/enums/status-effect"; -import { CommandPhase } from "#app/phases/command-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -40,7 +39,7 @@ describe("Moves - Heal Bell", () => { vi.spyOn(partyPokemon, "resetStatus"); game.move.select(MoveId.HEAL_BELL, 0); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SPLASH, 1); await game.toNextTurn(); @@ -62,7 +61,7 @@ describe("Moves - Heal Bell", () => { vi.spyOn(rightOpp, "resetStatus"); game.move.select(MoveId.HEAL_BELL, 0); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SPLASH, 1); await game.toNextTurn(); @@ -86,7 +85,7 @@ describe("Moves - Heal Bell", () => { vi.spyOn(partyPokemon, "resetStatus"); game.move.select(MoveId.HEAL_BELL, 0); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SPLASH, 1); await game.toNextTurn(); diff --git a/test/moves/heart_swap.test.ts b/test/moves/heart_swap.test.ts index e9e407b6b30..dedc069fefb 100644 --- a/test/moves/heart_swap.test.ts +++ b/test/moves/heart_swap.test.ts @@ -2,11 +2,9 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vite import Phaser from "phaser"; import GameManager from "#test/testUtils/gameManager"; import { SpeciesId } from "#enums/species-id"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { MoveId } from "#enums/move-id"; import { BATTLE_STATS } from "#enums/stat"; import { AbilityId } from "#enums/ability-id"; -import { MoveEndPhase } from "#app/phases/move-end-phase"; describe("Moves - Heart Swap", () => { let phaserGame: Phaser.Game; @@ -43,14 +41,14 @@ describe("Moves - Heart Swap", () => { game.move.select(MoveId.HEART_SWAP); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); for (const s of BATTLE_STATS) { expect(player.getStatStage(s)).toBe(0); expect(enemy.getStatStage(s)).toBe(1); } - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); for (const s of BATTLE_STATS) { expect(enemy.getStatStage(s)).toBe(0); diff --git a/test/moves/hyper_beam.test.ts b/test/moves/hyper_beam.test.ts index bca7cba4e9a..0a7c900f7cd 100644 --- a/test/moves/hyper_beam.test.ts +++ b/test/moves/hyper_beam.test.ts @@ -3,8 +3,6 @@ import { AbilityId } from "#enums/ability-id"; import { BattlerTagType } from "#app/enums/battler-tag-type"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; -import { BerryPhase } from "#app/phases/berry-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; @@ -45,7 +43,7 @@ describe("Moves - Hyper Beam", () => { game.move.select(MoveId.HYPER_BEAM); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); expect(leadPokemon.getTag(BattlerTagType.RECHARGING)).toBeDefined(); @@ -53,14 +51,14 @@ describe("Moves - Hyper Beam", () => { const enemyPostAttackHp = enemyPokemon.hp; /** Game should progress without a new command from the player */ - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(enemyPokemon.hp).toBe(enemyPostAttackHp); expect(leadPokemon.getTag(BattlerTagType.RECHARGING)).toBeUndefined(); game.move.select(MoveId.TACKLE); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.hp).toBeLessThan(enemyPostAttackHp); }); diff --git a/test/moves/jaw_lock.test.ts b/test/moves/jaw_lock.test.ts index 4e103c14f98..041075c01f2 100644 --- a/test/moves/jaw_lock.test.ts +++ b/test/moves/jaw_lock.test.ts @@ -1,10 +1,6 @@ import { BattlerIndex } from "#enums/battler-index"; import { AbilityId } from "#enums/ability-id"; import { BattlerTagType } from "#app/enums/battler-tag-type"; -import { BerryPhase } from "#app/phases/berry-phase"; -import { FaintPhase } from "#app/phases/faint-phase"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import GameManager from "#test/testUtils/gameManager"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -48,12 +44,12 @@ describe("Moves - Jaw Lock", () => { game.move.select(MoveId.JAW_LOCK); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeDefined(); expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeDefined(); @@ -69,17 +65,17 @@ describe("Moves - Jaw Lock", () => { game.move.select(MoveId.JAW_LOCK); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); - await game.phaseInterceptor.to(FaintPhase); + await game.phaseInterceptor.to("FaintPhase"); expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); @@ -94,12 +90,12 @@ describe("Moves - Jaw Lock", () => { game.move.select(MoveId.JAW_LOCK); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(leadPokemon.getTag(BattlerTagType.TRAPPED)).toBeDefined(); expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeDefined(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); await game.doKillOpponents(); @@ -118,7 +114,7 @@ describe("Moves - Jaw Lock", () => { game.move.select(MoveId.SPLASH, 1); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(playerPokemon[0].getTag(BattlerTagType.TRAPPED)).toBeDefined(); expect(enemyPokemon[0].getTag(BattlerTagType.TRAPPED)).toBeDefined(); @@ -128,7 +124,7 @@ describe("Moves - Jaw Lock", () => { game.move.select(MoveId.JAW_LOCK, 0, BattlerIndex.ENEMY_2); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(enemyPokemon[1].getTag(BattlerTagType.TRAPPED)).toBeUndefined(); expect(playerPokemon[0].getTag(BattlerTagType.TRAPPED)).toBeDefined(); @@ -145,7 +141,7 @@ describe("Moves - Jaw Lock", () => { game.move.select(MoveId.JAW_LOCK); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(playerPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined(); diff --git a/test/moves/last_respects.test.ts b/test/moves/last_respects.test.ts index 14aa5ad3309..0722961f355 100644 --- a/test/moves/last_respects.test.ts +++ b/test/moves/last_respects.test.ts @@ -5,7 +5,6 @@ import { AbilityId } from "#enums/ability-id"; import GameManager from "#test/testUtils/gameManager"; import { allMoves } from "#app/data/data-lists"; import type Move from "#app/data/moves/move"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; @@ -65,7 +64,7 @@ describe("Moves - Last Respects", () => { game.move.select(MoveId.LAST_RESPECTS); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(move.calculateBattlePower).toHaveReturnedWith(basePower + 2 * 50); }); @@ -100,7 +99,7 @@ describe("Moves - Last Respects", () => { game.move.select(MoveId.LAST_RESPECTS); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(move.calculateBattlePower).toHaveReturnedWith(basePower + 3 * 50); }); diff --git a/test/moves/light_screen.test.ts b/test/moves/light_screen.test.ts index 8c436aacf6a..9b64c1721d9 100644 --- a/test/moves/light_screen.test.ts +++ b/test/moves/light_screen.test.ts @@ -5,7 +5,6 @@ import { allMoves } from "#app/data/data-lists"; import { AbilityId } from "#enums/ability-id"; import { ArenaTagType } from "#app/enums/arena-tag-type"; import type Pokemon from "#app/field/pokemon"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { NumberHolder } from "#app/utils/common"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -50,7 +49,7 @@ describe("Moves - Light Screen", () => { game.move.select(moveToUse); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const mockedDmg = getMockedMoveDamage( game.scene.getEnemyPokemon()!, @@ -70,7 +69,7 @@ describe("Moves - Light Screen", () => { game.move.select(moveToUse); game.move.select(moveToUse, 1); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const mockedDmg = getMockedMoveDamage( game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, @@ -86,7 +85,7 @@ describe("Moves - Light Screen", () => { game.move.select(moveToUse); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const mockedDmg = getMockedMoveDamage( game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, @@ -103,7 +102,7 @@ describe("Moves - Light Screen", () => { await game.classicMode.startBattle([SpeciesId.SHUCKLE]); game.move.select(moveToUse); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const mockedDmg = getMockedMoveDamage( game.scene.getEnemyPokemon()!, diff --git a/test/moves/lunar_blessing.test.ts b/test/moves/lunar_blessing.test.ts index 2709ccbacf3..fd8fb2ddc5d 100644 --- a/test/moves/lunar_blessing.test.ts +++ b/test/moves/lunar_blessing.test.ts @@ -1,5 +1,4 @@ import { StatusEffect } from "#app/enums/status-effect"; -import { CommandPhase } from "#app/phases/command-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -47,7 +46,7 @@ describe("Moves - Lunar Blessing", () => { vi.spyOn(rightPlayer, "heal"); game.move.select(MoveId.LUNAR_BLESSING, 0); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SPLASH, 1); await game.toNextTurn(); @@ -67,7 +66,7 @@ describe("Moves - Lunar Blessing", () => { vi.spyOn(rightPlayer, "resetStatus"); game.move.select(MoveId.LUNAR_BLESSING, 0); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SPLASH, 1); await game.toNextTurn(); diff --git a/test/moves/lunar_dance.test.ts b/test/moves/lunar_dance.test.ts index aea1e31b616..9fe1464ddb7 100644 --- a/test/moves/lunar_dance.test.ts +++ b/test/moves/lunar_dance.test.ts @@ -1,5 +1,4 @@ import { StatusEffect } from "#app/enums/status-effect"; -import { CommandPhase } from "#app/phases/command-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -40,7 +39,7 @@ describe("Moves - Lunar Dance", () => { game.move.select(MoveId.SPLASH, 0); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); await game.toNextTurn(); // Bulbasaur should still be burned and have used a PP for splash and not at max hp @@ -51,7 +50,7 @@ describe("Moves - Lunar Dance", () => { // Switch out Bulbasaur for Rattata so we can swtich bulbasaur back in with lunar dance game.doSwitchPokemon(2); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); await game.toNextTurn(); game.move.select(MoveId.SPLASH, 0); @@ -67,7 +66,7 @@ describe("Moves - Lunar Dance", () => { game.move.select(MoveId.SPLASH, 0); game.move.select(MoveId.LUNAR_DANCE); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); await game.toNextTurn(); // Using Lunar dance again should fail because nothing in party and rattata should be alive diff --git a/test/moves/magnet_rise.test.ts b/test/moves/magnet_rise.test.ts index d8fc6a74225..959296f9f39 100644 --- a/test/moves/magnet_rise.test.ts +++ b/test/moves/magnet_rise.test.ts @@ -1,5 +1,3 @@ -import { CommandPhase } from "#app/phases/command-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import GameManager from "#test/testUtils/gameManager"; @@ -38,7 +36,7 @@ describe("Moves - Magnet Rise", () => { const startingHp = game.scene.getPlayerParty()[0].hp; game.move.select(moveToUse); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const finalHp = game.scene.getPlayerParty()[0].hp; const hpLost = finalHp - startingHp; expect(hpLost).toBe(0); @@ -49,12 +47,12 @@ describe("Moves - Magnet Rise", () => { const startingHp = game.scene.getPlayerParty()[0].hp; game.move.select(moveToUse); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); let finalHp = game.scene.getPlayerParty()[0].hp; let hpLost = finalHp - startingHp; expect(hpLost).toBe(0); game.move.select(MoveId.GRAVITY); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); finalHp = game.scene.getPlayerParty()[0].hp; hpLost = finalHp - startingHp; expect(hpLost).not.toBe(0); diff --git a/test/moves/make_it_rain.test.ts b/test/moves/make_it_rain.test.ts index 13b8e8f1853..94791255927 100644 --- a/test/moves/make_it_rain.test.ts +++ b/test/moves/make_it_rain.test.ts @@ -5,8 +5,6 @@ import { SpeciesId } from "#enums/species-id"; import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { MoveEndPhase } from "#app/phases/move-end-phase"; -import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase"; describe("Moves - Make It Rain", () => { let phaserGame: Phaser.Game; @@ -42,7 +40,7 @@ describe("Moves - Make It Rain", () => { game.move.select(MoveId.MAKE_IT_RAIN); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); expect(playerPokemon.getStatStage(Stat.SPATK)).toBe(-1); }); @@ -59,7 +57,7 @@ describe("Moves - Make It Rain", () => { game.move.select(MoveId.MAKE_IT_RAIN); - await game.phaseInterceptor.to(StatStageChangePhase); + await game.phaseInterceptor.to("StatStageChangePhase"); expect(enemyPokemon.isFainted()).toBe(true); expect(playerPokemon.getStatStage(Stat.SPATK)).toBe(-1); @@ -76,7 +74,7 @@ describe("Moves - Make It Rain", () => { game.move.select(MoveId.MAKE_IT_RAIN); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(StatStageChangePhase); + await game.phaseInterceptor.to("StatStageChangePhase"); enemyPokemon.forEach(p => expect(p.isFainted()).toBe(true)); expect(playerPokemon.getStatStage(Stat.SPATK)).toBe(-1); @@ -93,7 +91,7 @@ describe("Moves - Make It Rain", () => { // Make Make It Rain miss the first target await game.move.forceMiss(true); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); expect(playerPokemon.getStatStage(Stat.SPATK)).toBe(-1); }); diff --git a/test/moves/mat_block.test.ts b/test/moves/mat_block.test.ts index d77f538a973..52752ef9cea 100644 --- a/test/moves/mat_block.test.ts +++ b/test/moves/mat_block.test.ts @@ -5,9 +5,6 @@ import { SpeciesId } from "#enums/species-id"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { Stat } from "#enums/stat"; -import { BerryPhase } from "#app/phases/berry-phase"; -import { CommandPhase } from "#app/phases/command-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; describe("Moves - Mat Block", () => { let phaserGame: Phaser.Game; @@ -43,11 +40,11 @@ describe("Moves - Mat Block", () => { game.move.select(MoveId.MAT_BLOCK); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); leadPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp())); }); @@ -61,11 +58,11 @@ describe("Moves - Mat Block", () => { game.move.select(MoveId.MAT_BLOCK); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); leadPokemon.forEach(p => expect(p.getStatStage(Stat.ATK)).toBe(-2)); }); @@ -76,19 +73,19 @@ describe("Moves - Mat Block", () => { const leadPokemon = game.scene.getPlayerField(); game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const leadStartingHp = leadPokemon.map(p => p.hp); - await game.phaseInterceptor.to(CommandPhase, false); + await game.phaseInterceptor.to("CommandPhase", false); game.move.select(MoveId.MAT_BLOCK); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.MAT_BLOCK, 1); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(leadPokemon.some((p, i) => p.hp < leadStartingHp[i])).toBeTruthy(); }); diff --git a/test/moves/metronome.test.ts b/test/moves/metronome.test.ts index 670f7bb9b88..fd9e1eee350 100644 --- a/test/moves/metronome.test.ts +++ b/test/moves/metronome.test.ts @@ -5,7 +5,6 @@ import { allMoves } from "#app/data/data-lists"; import { AbilityId } from "#enums/ability-id"; import { Stat } from "#app/enums/stat"; import { MoveResult } from "#enums/move-result"; -import { CommandPhase } from "#app/phases/command-phase"; import { BattlerTagType } from "#enums/battler-tag-type"; import { MoveUseMode } from "#enums/move-use-mode"; import { MoveId } from "#enums/move-id"; @@ -125,7 +124,7 @@ describe("Moves - Metronome", () => { vi.spyOn(randomMoveAttr, "getMoveOverride").mockReturnValue(MoveId.AROMATIC_MIST); game.move.select(MoveId.METRONOME, 0); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SPLASH, 1); await game.toNextTurn(); diff --git a/test/moves/miracle_eye.test.ts b/test/moves/miracle_eye.test.ts index 9281931621f..48e5224318c 100644 --- a/test/moves/miracle_eye.test.ts +++ b/test/moves/miracle_eye.test.ts @@ -1,7 +1,6 @@ import { BattlerIndex } from "#enums/battler-index"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; @@ -44,7 +43,7 @@ describe("Moves - Miracle Eye", () => { await game.toNextTurn(); game.move.select(MoveId.CONFUSION); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(enemy.hp).toBeLessThan(enemy.getMaxHp()); }); diff --git a/test/moves/parting_shot.test.ts b/test/moves/parting_shot.test.ts index fdeab6bfc7c..aa10d04ab2d 100644 --- a/test/moves/parting_shot.test.ts +++ b/test/moves/parting_shot.test.ts @@ -5,10 +5,6 @@ import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, test } from "vitest"; import GameManager from "#test/testUtils/gameManager"; import { Stat } from "#enums/stat"; -import { BerryPhase } from "#app/phases/berry-phase"; -import { FaintPhase } from "#app/phases/faint-phase"; -import { MessagePhase } from "#app/phases/message-phase"; -import { TurnInitPhase } from "#app/phases/turn-init-phase"; describe("Moves - Parting Shot", () => { let phaserGame: Phaser.Game; @@ -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/powder.test.ts b/test/moves/powder.test.ts index 8f47f2ff428..fc044a10b98 100644 --- a/test/moves/powder.test.ts +++ b/test/moves/powder.test.ts @@ -1,6 +1,5 @@ import { BattlerIndex } from "#enums/battler-index"; import { MoveResult } from "#enums/move-result"; -import { BerryPhase } from "#app/phases/berry-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -46,7 +45,7 @@ describe("Moves - Powder", () => { game.move.select(MoveId.POWDER); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); expect(enemyPokemon.hp).toBe(Math.ceil((3 * enemyPokemon.getMaxHp()) / 4)); expect(enemyPokemon.moveset[0].ppUsed).toBe(1); @@ -55,7 +54,7 @@ describe("Moves - Powder", () => { game.move.select(MoveId.SPLASH); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); expect(enemyPokemon.hp).toBe(Math.ceil((3 * enemyPokemon.getMaxHp()) / 4)); expect(enemyPokemon.moveset[0].ppUsed).toBe(2); @@ -70,7 +69,7 @@ describe("Moves - Powder", () => { game.move.select(MoveId.POWDER); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); }); @@ -84,7 +83,7 @@ describe("Moves - Powder", () => { game.move.select(MoveId.POWDER); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); }); @@ -98,7 +97,7 @@ describe("Moves - Powder", () => { game.move.select(MoveId.POWDER); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); }); @@ -112,7 +111,7 @@ describe("Moves - Powder", () => { game.move.select(MoveId.POWDER); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); }); @@ -126,7 +125,7 @@ describe("Moves - Powder", () => { game.move.select(MoveId.POWDER); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.status?.effect).not.toBe(StatusEffect.FREEZE); expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); expect(enemyPokemon.hp).toBe(Math.ceil((3 * enemyPokemon.getMaxHp()) / 4)); @@ -141,7 +140,7 @@ describe("Moves - Powder", () => { game.move.select(MoveId.POWDER); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); expect(enemyPokemon.summonData.types).not.toBe(PokemonType.FIRE); @@ -189,7 +188,7 @@ describe("Moves - Powder", () => { game.move.select(MoveId.POWDER); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); expect(enemyPokemon.hp).toBe(Math.ceil((3 * enemyPokemon.getMaxHp()) / 4)); expect(playerPokemon.getLastXMoves()[0].move).toBe(MoveId.POWDER); @@ -204,7 +203,7 @@ describe("Moves - Powder", () => { game.move.select(MoveId.POWDER); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); expect(enemyPokemon.hp).toBe(Math.ceil((3 * enemyPokemon.getMaxHp()) / 4)); }); @@ -218,7 +217,7 @@ describe("Moves - Powder", () => { game.move.select(MoveId.POWDER); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); expect(enemyPokemon.hp).toBe(Math.ceil((3 * enemyPokemon.getMaxHp()) / 4)); }); @@ -235,7 +234,7 @@ describe("Moves - Powder", () => { await game.move.selectEnemyMove(MoveId.FIRE_PLEDGE, BattlerIndex.PLAYER); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY_2, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); expect(enemyPokemon.hp).toBe(Math.ceil((3 * enemyPokemon.getMaxHp()) / 4)); }); @@ -252,7 +251,7 @@ describe("Moves - Powder", () => { await game.move.selectEnemyMove(MoveId.WATER_PLEDGE, BattlerIndex.PLAYER); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); expect(enemyPokemon.hp).toBe(Math.ceil((3 * enemyPokemon.getMaxHp()) / 4)); }); @@ -269,7 +268,7 @@ describe("Moves - Powder", () => { await game.move.selectEnemyMove(MoveId.WATER_PLEDGE, BattlerIndex.PLAYER); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY_2, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); }); diff --git a/test/moves/power_split.test.ts b/test/moves/power_split.test.ts index c0fcd317182..460547f9771 100644 --- a/test/moves/power_split.test.ts +++ b/test/moves/power_split.test.ts @@ -2,7 +2,6 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import Phaser from "phaser"; import GameManager from "#test/testUtils/gameManager"; import { SpeciesId } from "#enums/species-id"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { MoveId } from "#enums/move-id"; import { Stat } from "#enums/stat"; import { AbilityId } from "#enums/ability-id"; @@ -43,7 +42,7 @@ describe("Moves - Power Split", () => { const avgSpAtk = Math.floor((player.getStat(Stat.SPATK, false) + enemy.getStat(Stat.SPATK, false)) / 2); game.move.select(MoveId.POWER_SPLIT); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(player.getStat(Stat.ATK, false)).toBe(avgAtk); expect(enemy.getStat(Stat.ATK, false)).toBe(avgAtk); @@ -63,10 +62,10 @@ describe("Moves - Power Split", () => { const avgSpAtk = Math.floor((player.getStat(Stat.SPATK, false) + enemy.getStat(Stat.SPATK, false)) / 2); game.move.select(MoveId.POWER_SPLIT); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); game.move.select(MoveId.POWER_SPLIT); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(player.getStat(Stat.ATK, false)).toBe(avgAtk); expect(enemy.getStat(Stat.ATK, false)).toBe(avgAtk); diff --git a/test/moves/power_swap.test.ts b/test/moves/power_swap.test.ts index 82662850c77..10cb5c8e9d3 100644 --- a/test/moves/power_swap.test.ts +++ b/test/moves/power_swap.test.ts @@ -2,11 +2,9 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vite import Phaser from "phaser"; import GameManager from "#test/testUtils/gameManager"; import { SpeciesId } from "#enums/species-id"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { MoveId } from "#enums/move-id"; import { Stat, BATTLE_STATS } from "#enums/stat"; import { AbilityId } from "#enums/ability-id"; -import { MoveEndPhase } from "#app/phases/move-end-phase"; describe("Moves - Power Swap", () => { let phaserGame: Phaser.Game; @@ -43,14 +41,14 @@ describe("Moves - Power Swap", () => { game.move.select(MoveId.POWER_SWAP); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); for (const s of BATTLE_STATS) { expect(player.getStatStage(s)).toBe(0); expect(enemy.getStatStage(s)).toBe(1); } - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); for (const s of BATTLE_STATS) { if (s === Stat.ATK || s === Stat.SPATK) { diff --git a/test/moves/power_trick.test.ts b/test/moves/power_trick.test.ts index af90525d263..3e48b3597d8 100644 --- a/test/moves/power_trick.test.ts +++ b/test/moves/power_trick.test.ts @@ -4,7 +4,6 @@ import GameManager from "#test/testUtils/gameManager"; import { MoveId } from "#enums/move-id"; import { Stat } from "#enums/stat"; import { SpeciesId } from "#enums/species-id"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { AbilityId } from "#enums/ability-id"; import { BattlerTagType } from "#enums/battler-tag-type"; @@ -43,7 +42,7 @@ describe("Moves - Power Trick", () => { game.move.select(MoveId.POWER_TRICK); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(player.getStat(Stat.ATK, false)).toBe(baseDEF); expect(player.getStat(Stat.DEF, false)).toBe(baseATK); @@ -59,11 +58,11 @@ describe("Moves - Power Trick", () => { game.move.select(MoveId.POWER_TRICK); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); game.move.select(MoveId.POWER_TRICK); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(player.getStat(Stat.ATK, false)).toBe(baseATK); expect(player.getStat(Stat.DEF, false)).toBe(baseDEF); @@ -80,7 +79,7 @@ describe("Moves - Power Trick", () => { game.move.select(MoveId.BATON_PASS); game.doSelectPartyPokemon(1); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const switchedPlayer = game.scene.getPlayerPokemon()!; const baseATK = switchedPlayer.getStat(Stat.ATK); @@ -100,7 +99,7 @@ describe("Moves - Power Trick", () => { game.move.select(MoveId.TRANSFORM); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const enemy = game.scene.getEnemyPokemon()!; const baseATK = enemy.getStat(Stat.ATK); diff --git a/test/moves/purify.test.ts b/test/moves/purify.test.ts index 2e8e312f23c..2a6479e63b3 100644 --- a/test/moves/purify.test.ts +++ b/test/moves/purify.test.ts @@ -1,7 +1,6 @@ import { BattlerIndex } from "#enums/battler-index"; import { Status } from "#app/data/status-effect"; import type { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon"; -import { MoveEndPhase } from "#app/phases/move-end-phase"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import { StatusEffect } from "#enums/status-effect"; @@ -46,7 +45,7 @@ describe("Moves - Purify", () => { game.move.select(MoveId.PURIFY); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); expect(enemyPokemon.status).toBeNull(); expect(playerPokemon.isFullHp()).toBe(true); @@ -62,7 +61,7 @@ describe("Moves - Purify", () => { game.move.select(MoveId.PURIFY); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); expect(playerPokemon.hp).toBe(playerInitialHp); }); diff --git a/test/moves/reflect.test.ts b/test/moves/reflect.test.ts index ef8c80070bf..a6f87f4e55f 100644 --- a/test/moves/reflect.test.ts +++ b/test/moves/reflect.test.ts @@ -5,7 +5,6 @@ import { allMoves } from "#app/data/data-lists"; import { AbilityId } from "#enums/ability-id"; import { ArenaTagType } from "#app/enums/arena-tag-type"; import type Pokemon from "#app/field/pokemon"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { NumberHolder } from "#app/utils/common"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -50,7 +49,7 @@ describe("Moves - Reflect", () => { game.move.select(moveToUse); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const mockedDmg = getMockedMoveDamage( game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, @@ -69,7 +68,7 @@ describe("Moves - Reflect", () => { game.move.select(moveToUse); game.move.select(moveToUse, 1); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const mockedDmg = getMockedMoveDamage( game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, @@ -85,7 +84,7 @@ describe("Moves - Reflect", () => { game.move.select(moveToUse); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const mockedDmg = getMockedMoveDamage( game.scene.getEnemyPokemon()!, @@ -102,7 +101,7 @@ describe("Moves - Reflect", () => { await game.classicMode.startBattle([SpeciesId.SHUCKLE]); game.move.select(moveToUse); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const mockedDmg = getMockedMoveDamage( game.scene.getEnemyPokemon()!, @@ -119,7 +118,7 @@ describe("Moves - Reflect", () => { await game.classicMode.startBattle([SpeciesId.SHUCKLE]); game.move.select(moveToUse); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const mockedDmg = getMockedMoveDamage( game.scene.getEnemyPokemon()!, diff --git a/test/moves/rollout.test.ts b/test/moves/rollout.test.ts index 9639a2e5408..a92a6ca9d88 100644 --- a/test/moves/rollout.test.ts +++ b/test/moves/rollout.test.ts @@ -1,5 +1,4 @@ import { allMoves } from "#app/data/data-lists"; -import { CommandPhase } from "#app/phases/command-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -57,7 +56,7 @@ describe("Moves - Rollout", () => { for (let i = 0; i < turns; i++) { game.move.select(MoveId.ROLLOUT); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); dmgHistory.push(previousHp - enemyPkm.hp); previousHp = enemyPkm.hp; diff --git a/test/moves/roost.test.ts b/test/moves/roost.test.ts index 3707e0ead45..7691b7ece0c 100644 --- a/test/moves/roost.test.ts +++ b/test/moves/roost.test.ts @@ -3,8 +3,6 @@ import { PokemonType } from "#enums/pokemon-type"; import { BattlerTagType } from "#app/enums/battler-tag-type"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; @@ -53,7 +51,7 @@ describe("Moves - Roost", () => { const playerPokemonStartingHP = playerPokemon.hp; game.move.select(MoveId.ROOST); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); // Should only be normal type, and NOT flying type let playerPokemonTypes = playerPokemon.getTypes(); @@ -61,7 +59,7 @@ describe("Moves - Roost", () => { expect(playerPokemonTypes.length === 1).toBeTruthy(); expect(playerPokemon.isGrounded()).toBeTruthy(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); // Lose HP, still normal type playerPokemonTypes = playerPokemon.getTypes(); @@ -77,7 +75,7 @@ describe("Moves - Roost", () => { const playerPokemonStartingHP = playerPokemon.hp; game.move.select(MoveId.ROOST); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); // Should only be normal type, and NOT flying type let playerPokemonTypes = playerPokemon.getTypes(); @@ -85,7 +83,7 @@ describe("Moves - Roost", () => { expect(playerPokemonTypes[0] === PokemonType.FLYING).toBeFalsy(); expect(playerPokemon.isGrounded()).toBeTruthy(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); // Should have lost HP and is now back to being pure flying playerPokemonTypes = playerPokemon.getTypes(); @@ -101,7 +99,7 @@ describe("Moves - Roost", () => { const playerPokemonStartingHP = playerPokemon.hp; game.move.select(MoveId.ROOST); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); // Should only be pure fighting type and grounded let playerPokemonTypes = playerPokemon.getTypes(); @@ -109,7 +107,7 @@ describe("Moves - Roost", () => { expect(playerPokemonTypes.length === 1).toBeTruthy(); expect(playerPokemon.isGrounded()).toBeTruthy(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); // Should have lost HP and is now back to being fighting/flying playerPokemonTypes = playerPokemon.getTypes(); @@ -126,7 +124,7 @@ describe("Moves - Roost", () => { const playerPokemonStartingHP = playerPokemon.hp; game.move.select(MoveId.ROOST); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); // Should only be pure eletric type and grounded let playerPokemonTypes = playerPokemon.getTypes(); @@ -134,7 +132,7 @@ describe("Moves - Roost", () => { expect(playerPokemonTypes.length === 1).toBeTruthy(); expect(playerPokemon.isGrounded()).toBeFalsy(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); // Should have lost HP and is now back to being electric/flying playerPokemonTypes = playerPokemon.getTypes(); @@ -150,17 +148,17 @@ describe("Moves - Roost", () => { const playerPokemonStartingHP = playerPokemon.hp; game.move.select(MoveId.BURN_UP); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); // Should only be pure flying type after burn up let playerPokemonTypes = playerPokemon.getTypes(); expect(playerPokemonTypes[0] === PokemonType.FLYING).toBeTruthy(); expect(playerPokemonTypes.length === 1).toBeTruthy(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); game.move.select(MoveId.ROOST); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); // Should only be typeless type after roost and is grounded playerPokemonTypes = playerPokemon.getTypes(); @@ -169,7 +167,7 @@ describe("Moves - Roost", () => { expect(playerPokemonTypes.length === 1).toBeTruthy(); expect(playerPokemon.isGrounded()).toBeTruthy(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); // Should go back to being pure flying and have taken damage from earthquake, and is ungrounded again playerPokemonTypes = playerPokemon.getTypes(); @@ -186,17 +184,17 @@ describe("Moves - Roost", () => { const playerPokemonStartingHP = playerPokemon.hp; game.move.select(MoveId.DOUBLE_SHOCK); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); // Should only be pure flying type after burn up let playerPokemonTypes = playerPokemon.getTypes(); expect(playerPokemonTypes[0] === PokemonType.FLYING).toBeTruthy(); expect(playerPokemonTypes.length === 1).toBeTruthy(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); game.move.select(MoveId.ROOST); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); // Should only be typeless type after roost and is grounded playerPokemonTypes = playerPokemon.getTypes(); @@ -205,7 +203,7 @@ describe("Moves - Roost", () => { expect(playerPokemonTypes.length === 1).toBeTruthy(); expect(playerPokemon.isGrounded()).toBeTruthy(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); // Should go back to being pure flying and have taken damage from earthquake, and is ungrounded again playerPokemonTypes = playerPokemon.getTypes(); @@ -225,14 +223,14 @@ describe("Moves - Roost", () => { await game.classicMode.startBattle([SpeciesId.MOLTRES]); const playerPokemon = game.scene.getPlayerPokemon()!; game.move.select(MoveId.ROOST); - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); let playerPokemonTypes = playerPokemon.getTypes(); expect(playerPokemonTypes[0] === PokemonType.FIRE).toBeTruthy(); expect(playerPokemonTypes.length === 1).toBeTruthy(); expect(playerPokemon.isGrounded()).toBeTruthy(); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); // Should be fire/flying/ghost playerPokemonTypes = playerPokemon.getTypes(); diff --git a/test/moves/scale_shot.test.ts b/test/moves/scale_shot.test.ts index e2c86091378..63aa75fdead 100644 --- a/test/moves/scale_shot.test.ts +++ b/test/moves/scale_shot.test.ts @@ -1,9 +1,5 @@ import { BattlerIndex } from "#enums/battler-index"; import { allMoves } from "#app/data/data-lists"; -import { DamageAnimPhase } from "#app/phases/damage-anim-phase"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase"; -import { MoveEndPhase } from "#app/phases/move-end-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -47,16 +43,16 @@ describe("Moves - Scale Shot", () => { await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); - await game.phaseInterceptor.to(MoveEffectPhase); - await game.phaseInterceptor.to(DamageAnimPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); + await game.phaseInterceptor.to("DamageAnimPhase"); //check that stats haven't changed after one or two hits have occurred - await game.phaseInterceptor.to(MoveEffectPhase); + await game.phaseInterceptor.to("MoveEffectPhase"); expect(minccino.getStatStage(Stat.DEF)).toBe(0); expect(minccino.getStatStage(Stat.SPD)).toBe(0); //check that stats changed on last hit - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); expect(minccino.getStatStage(Stat.DEF)).toBe(-1); expect(minccino.getStatStage(Stat.SPD)).toBe(1); }); @@ -73,7 +69,7 @@ describe("Moves - Scale Shot", () => { const minccino = game.scene.getPlayerPokemon()!; game.move.select(MoveId.SCALE_SHOT); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); //effect not nullified by sheer force expect(minccino.getStatStage(Stat.DEF)).toBe(-1); diff --git a/test/moves/shell_trap.test.ts b/test/moves/shell_trap.test.ts index a3f55cef10f..3287c447e1a 100644 --- a/test/moves/shell_trap.test.ts +++ b/test/moves/shell_trap.test.ts @@ -3,8 +3,6 @@ import { allMoves } from "#app/data/data-lists"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import { MoveResult } from "#enums/move-result"; -import { BerryPhase } from "#app/phases/berry-phase"; -import { MoveEndPhase } from "#app/phases/move-end-phase"; import { MovePhase } from "#app/phases/move-phase"; import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; @@ -48,13 +46,13 @@ describe("Moves - Shell Trap", () => { await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2]); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); const movePhase = game.scene.phaseManager.getCurrentPhase(); expect(movePhase instanceof MovePhase).toBeTruthy(); expect((movePhase as MovePhase).pokemon).toBe(playerPokemon[1]); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); enemyPokemon.forEach(p => expect(p.hp).toBeLessThan(p.getMaxHp())); }); @@ -71,13 +69,13 @@ describe("Moves - Shell Trap", () => { await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2]); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); const movePhase = game.scene.phaseManager.getCurrentPhase(); expect(movePhase instanceof MovePhase).toBeTruthy(); expect((movePhase as MovePhase).pokemon).not.toBe(playerPokemon[1]); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); enemyPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp())); }); @@ -94,13 +92,13 @@ describe("Moves - Shell Trap", () => { await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2]); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); const movePhase = game.scene.phaseManager.getCurrentPhase(); expect(movePhase instanceof MovePhase).toBeTruthy(); expect((movePhase as MovePhase).pokemon).not.toBe(playerPokemon[1]); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); enemyPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp())); }); @@ -115,7 +113,7 @@ describe("Moves - Shell Trap", () => { game.move.select(MoveId.SHELL_TRAP); game.move.select(MoveId.BULLDOZE, 1); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); const movePhase = game.scene.phaseManager.getCurrentPhase(); expect(movePhase instanceof MovePhase).toBeTruthy(); @@ -123,7 +121,7 @@ describe("Moves - Shell Trap", () => { const enemyStartingHp = enemyPokemon.map(p => p.hp); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); enemyPokemon.forEach((p, i) => expect(p.hp).toBe(enemyStartingHp[i])); }); @@ -138,7 +136,7 @@ describe("Moves - Shell Trap", () => { game.move.select(MoveId.SHELL_TRAP); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(playerPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp()); diff --git a/test/moves/sparkly_swirl.test.ts b/test/moves/sparkly_swirl.test.ts index d1cbdd70107..79810820238 100644 --- a/test/moves/sparkly_swirl.test.ts +++ b/test/moves/sparkly_swirl.test.ts @@ -1,6 +1,5 @@ import { allMoves } from "#app/data/data-lists"; import { StatusEffect } from "#app/enums/status-effect"; -import { CommandPhase } from "#app/phases/command-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -44,7 +43,7 @@ describe("Moves - Sparkly Swirl", () => { vi.spyOn(partyPokemon, "resetStatus"); game.move.select(MoveId.SPARKLY_SWIRL, 0, leftOpp.getBattlerIndex()); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SPLASH, 1); await game.toNextTurn(); @@ -66,7 +65,7 @@ describe("Moves - Sparkly Swirl", () => { vi.spyOn(rightOpp, "resetStatus"); game.move.select(MoveId.SPARKLY_SWIRL, 0, leftOpp.getBattlerIndex()); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SPLASH, 1); await game.toNextTurn(); diff --git a/test/moves/spectral_thief.test.ts b/test/moves/spectral_thief.test.ts index e7b19eda506..bea54e86416 100644 --- a/test/moves/spectral_thief.test.ts +++ b/test/moves/spectral_thief.test.ts @@ -4,7 +4,6 @@ import { Stat } from "#enums/stat"; import { allMoves } from "#app/data/data-lists"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; @@ -52,7 +51,7 @@ describe("Moves - Spectral Thief", () => { player.setStatStage(Stat.SPD, -2); game.move.select(MoveId.SPECTRAL_THIEF); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); /** * enemy has +6 ATK and player +4 => player only steals +2 @@ -79,7 +78,7 @@ describe("Moves - Spectral Thief", () => { player.setStatStage(Stat.ATK, 0); game.move.select(MoveId.SPECTRAL_THIEF); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(dmgBefore).toBeLessThan(enemy.getAttackDamage({ source: player, move: moveToCheck }).damage); }); @@ -96,7 +95,7 @@ describe("Moves - Spectral Thief", () => { player.setStatStage(Stat.ATK, 0); game.move.select(MoveId.SPECTRAL_THIEF); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(player.getStatStage(Stat.ATK)).toEqual(-6); expect(enemy.getStatStage(Stat.ATK)).toEqual(0); @@ -114,7 +113,7 @@ describe("Moves - Spectral Thief", () => { player.setStatStage(Stat.ATK, 0); game.move.select(MoveId.SPECTRAL_THIEF); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(player.getStatStage(Stat.ATK)).toEqual(6); expect(enemy.getStatStage(Stat.ATK)).toEqual(0); @@ -132,7 +131,7 @@ describe("Moves - Spectral Thief", () => { player.setStatStage(Stat.ATK, 0); game.move.select(MoveId.SPECTRAL_THIEF); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(player.getStatStage(Stat.ATK)).toEqual(3); expect(enemy.getStatStage(Stat.ATK)).toEqual(0); @@ -150,7 +149,7 @@ describe("Moves - Spectral Thief", () => { player.setStatStage(Stat.ATK, 0); game.move.select(MoveId.SPECTRAL_THIEF); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(player.getStatStage(Stat.ATK)).toEqual(3); expect(enemy.getStatStage(Stat.ATK)).toEqual(0); @@ -168,7 +167,7 @@ describe("Moves - Spectral Thief", () => { player.setStatStage(Stat.ATK, 0); game.move.select(MoveId.SPECTRAL_THIEF); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(player.getStatStage(Stat.ATK)).toEqual(3); expect(enemy.getStatStage(Stat.ATK)).toEqual(0); @@ -187,7 +186,7 @@ describe("Moves - Spectral Thief", () => { game.move.select(MoveId.SPECTRAL_THIEF); await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(player.getStatStage(Stat.ATK)).toEqual(3); expect(enemy.getStatStage(Stat.ATK)).toEqual(0); @@ -206,7 +205,7 @@ describe("Moves - Spectral Thief", () => { player.setStatStage(Stat.ATK, 0); game.move.select(MoveId.SPECTRAL_THIEF); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(player.getStatStage(Stat.ATK)).toEqual(0); expect(enemy.getStatStage(Stat.ATK)).toEqual(3); diff --git a/test/moves/speed_swap.test.ts b/test/moves/speed_swap.test.ts index 3723e7db740..a4383acc843 100644 --- a/test/moves/speed_swap.test.ts +++ b/test/moves/speed_swap.test.ts @@ -2,7 +2,6 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import Phaser from "phaser"; import GameManager from "#test/testUtils/gameManager"; import { SpeciesId } from "#enums/species-id"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { MoveId } from "#enums/move-id"; import { Stat } from "#enums/stat"; import { AbilityId } from "#enums/ability-id"; @@ -43,7 +42,7 @@ describe("Moves - Speed Swap", () => { const enemySpd = enemy.getStat(Stat.SPD, false); game.move.select(MoveId.SPEED_SWAP); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(player.getStat(Stat.SPD, false)).toBe(enemySpd); expect(enemy.getStat(Stat.SPD, false)).toBe(playerSpd); diff --git a/test/moves/spit_up.test.ts b/test/moves/spit_up.test.ts index 00cbe2fd0ad..bd8ec1b43f0 100644 --- a/test/moves/spit_up.test.ts +++ b/test/moves/spit_up.test.ts @@ -10,8 +10,6 @@ import type Move from "#app/data/moves/move"; import { SpeciesId } from "#enums/species-id"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -import { MovePhase } from "#app/phases/move-phase"; -import { TurnInitPhase } from "#app/phases/turn-init-phase"; describe("Moves - Spit Up", () => { let phaserGame: Phaser.Game; @@ -58,7 +56,7 @@ describe("Moves - Spit Up", () => { expect(stockpilingTag.stockpiledCount).toBe(stacksToSetup); game.move.select(MoveId.SPIT_UP); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); expect(spitUp.calculateBattlePower).toHaveBeenCalledOnce(); expect(spitUp.calculateBattlePower).toHaveReturnedWith(expectedPower); @@ -81,7 +79,7 @@ describe("Moves - Spit Up", () => { expect(stockpilingTag.stockpiledCount).toBe(stacksToSetup); game.move.select(MoveId.SPIT_UP); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); expect(spitUp.calculateBattlePower).toHaveBeenCalledOnce(); expect(spitUp.calculateBattlePower).toHaveReturnedWith(expectedPower); @@ -105,7 +103,7 @@ describe("Moves - Spit Up", () => { expect(stockpilingTag.stockpiledCount).toBe(stacksToSetup); game.move.select(MoveId.SPIT_UP); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); expect(spitUp.calculateBattlePower).toHaveBeenCalledOnce(); expect(spitUp.calculateBattlePower).toHaveReturnedWith(expectedPower); @@ -123,7 +121,7 @@ describe("Moves - Spit Up", () => { expect(stockpilingTag).toBeUndefined(); game.move.select(MoveId.SPIT_UP); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: MoveId.SPIT_UP, @@ -145,12 +143,12 @@ describe("Moves - Spit Up", () => { expect(stockpilingTag).toBeDefined(); game.move.select(MoveId.SPIT_UP); - await game.phaseInterceptor.to(MovePhase); + await game.phaseInterceptor.to("MovePhase"); expect(pokemon.getStatStage(Stat.DEF)).toBe(1); expect(pokemon.getStatStage(Stat.SPDEF)).toBe(1); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: MoveId.SPIT_UP, @@ -182,7 +180,7 @@ describe("Moves - Spit Up", () => { }; game.move.select(MoveId.SPIT_UP); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: MoveId.SPIT_UP, diff --git a/test/moves/spotlight.test.ts b/test/moves/spotlight.test.ts index a9e8cd7e2b6..6f9d6148bc2 100644 --- a/test/moves/spotlight.test.ts +++ b/test/moves/spotlight.test.ts @@ -1,5 +1,4 @@ import { BattlerIndex } from "#enums/battler-index"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import GameManager from "#test/testUtils/gameManager"; @@ -43,7 +42,7 @@ describe("Moves - Spotlight", () => { await game.move.selectEnemyMove(MoveId.SPLASH); await game.move.selectEnemyMove(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase, false); + await game.phaseInterceptor.to("TurnEndPhase", false); expect(enemyPokemon[0].hp).toBeLessThan(enemyPokemon[0].getMaxHp()); expect(enemyPokemon[1].hp).toBe(enemyPokemon[1].getMaxHp()); diff --git a/test/moves/stockpile.test.ts b/test/moves/stockpile.test.ts index 3ad47d8d85e..3eeb9fb729d 100644 --- a/test/moves/stockpile.test.ts +++ b/test/moves/stockpile.test.ts @@ -1,8 +1,6 @@ import { Stat } from "#enums/stat"; import { StockpilingTag } from "#app/data/battler-tags"; import { MoveResult } from "#enums/move-result"; -import { CommandPhase } from "#app/phases/command-phase"; -import { TurnInitPhase } from "#app/phases/turn-init-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -51,11 +49,11 @@ describe("Moves - Stockpile", () => { // use Stockpile four times for (let i = 0; i < 4; i++) { if (i !== 0) { - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); } game.move.select(MoveId.STOCKPILE); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); const stockpilingTag = user.getTag(StockpilingTag)!; @@ -93,7 +91,7 @@ describe("Moves - Stockpile", () => { expect(user.getStatStage(Stat.SPDEF)).toBe(6); game.move.select(MoveId.STOCKPILE); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); const stockpilingTag = user.getTag(StockpilingTag)!; expect(stockpilingTag).toBeDefined(); @@ -102,10 +100,10 @@ describe("Moves - Stockpile", () => { expect(user.getStatStage(Stat.SPDEF)).toBe(6); // do it again, just for good measure - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.STOCKPILE); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); const stockpilingTagAgain = user.getTag(StockpilingTag)!; expect(stockpilingTagAgain).toBeDefined(); diff --git a/test/moves/swallow.test.ts b/test/moves/swallow.test.ts index c511682011f..763accbf6c5 100644 --- a/test/moves/swallow.test.ts +++ b/test/moves/swallow.test.ts @@ -2,8 +2,6 @@ import { Stat } from "#enums/stat"; import { StockpilingTag } from "#app/data/battler-tags"; import { BattlerTagType } from "#app/enums/battler-tag-type"; import { MoveResult } from "#enums/move-result"; -import { MovePhase } from "#app/phases/move-phase"; -import { TurnInitPhase } from "#app/phases/turn-init-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; @@ -56,7 +54,7 @@ describe("Moves - Swallow", () => { vi.spyOn(pokemon, "heal"); game.move.select(MoveId.SWALLOW); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); expect(pokemon.heal).toHaveBeenCalledOnce(); expect(pokemon.heal).toHaveReturnedWith(expectedHeal); @@ -84,7 +82,7 @@ describe("Moves - Swallow", () => { vi.spyOn(pokemon, "heal"); game.move.select(MoveId.SWALLOW); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); expect(pokemon.heal).toHaveBeenCalledOnce(); expect(pokemon.heal).toHaveReturnedWith(expectedHeal); @@ -113,7 +111,7 @@ describe("Moves - Swallow", () => { vi.spyOn(pokemon, "heal"); game.move.select(MoveId.SWALLOW); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); expect(pokemon.heal).toHaveBeenCalledOnce(); expect(pokemon.heal).toHaveReturnedWith(expect.closeTo(expectedHeal)); @@ -131,7 +129,7 @@ describe("Moves - Swallow", () => { expect(stockpilingTag).toBeUndefined(); game.move.select(MoveId.SWALLOW); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: MoveId.SWALLOW, @@ -151,12 +149,12 @@ describe("Moves - Swallow", () => { expect(stockpilingTag).toBeDefined(); game.move.select(MoveId.SWALLOW); - await game.phaseInterceptor.to(MovePhase); + await game.phaseInterceptor.to("MovePhase"); expect(pokemon.getStatStage(Stat.DEF)).toBe(1); expect(pokemon.getStatStage(Stat.SPDEF)).toBe(1); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: MoveId.SWALLOW, @@ -187,7 +185,7 @@ describe("Moves - Swallow", () => { game.move.select(MoveId.SWALLOW); - await game.phaseInterceptor.to(TurnInitPhase); + await game.phaseInterceptor.to("TurnInitPhase"); expect(pokemon.getMoveHistory().at(-1)).toMatchObject({ move: MoveId.SWALLOW, diff --git a/test/moves/tackle.test.ts b/test/moves/tackle.test.ts index f3c0db85a39..3f4cfb34937 100644 --- a/test/moves/tackle.test.ts +++ b/test/moves/tackle.test.ts @@ -1,6 +1,4 @@ import { Stat } from "#enums/stat"; -import { EnemyCommandPhase } from "#app/phases/enemy-command-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import GameManager from "#test/testUtils/gameManager"; @@ -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 e98194b52dd..e6a530cd5f1 100644 --- a/test/moves/tail_whip.test.ts +++ b/test/moves/tail_whip.test.ts @@ -5,8 +5,6 @@ import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; -import { EnemyCommandPhase } from "#app/phases/enemy-command-phase"; -import { TurnInitPhase } from "#app/phases/turn-init-phase"; describe("Moves - Tail whip", () => { let phaserGame: Phaser.Game; @@ -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/moves/thousand_arrows.test.ts b/test/moves/thousand_arrows.test.ts index 9ecdd94a94f..41d09d5d7b4 100644 --- a/test/moves/thousand_arrows.test.ts +++ b/test/moves/thousand_arrows.test.ts @@ -1,7 +1,5 @@ import { AbilityId } from "#enums/ability-id"; import { BattlerTagType } from "#app/enums/battler-tag-type"; -import { BerryPhase } from "#app/phases/berry-phase"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import GameManager from "#test/testUtils/gameManager"; @@ -40,11 +38,11 @@ describe("Moves - Thousand Arrows", () => { game.move.select(MoveId.THOUSAND_ARROWS); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); // Enemy should not be grounded before move effect is applied expect(enemyPokemon.getTag(BattlerTagType.IGNORE_FLYING)).toBeUndefined(); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.getTag(BattlerTagType.IGNORE_FLYING)).toBeDefined(); expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); @@ -59,11 +57,11 @@ describe("Moves - Thousand Arrows", () => { game.move.select(MoveId.THOUSAND_ARROWS); - await game.phaseInterceptor.to(MoveEffectPhase, false); + await game.phaseInterceptor.to("MoveEffectPhase", false); // Enemy should not be grounded before move effect is applied expect(enemyPokemon.getTag(BattlerTagType.IGNORE_FLYING)).toBeUndefined(); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.getTag(BattlerTagType.IGNORE_FLYING)).toBeDefined(); expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp()); @@ -80,7 +78,7 @@ describe("Moves - Thousand Arrows", () => { game.move.select(MoveId.THOUSAND_ARROWS); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(enemyPokemon.getTag(BattlerTagType.FLOATING)).toBeUndefined(); expect(enemyPokemon.getTag(BattlerTagType.IGNORE_FLYING)).toBeDefined(); diff --git a/test/moves/tidy_up.test.ts b/test/moves/tidy_up.test.ts index 69c9df42b36..f20f8e94946 100644 --- a/test/moves/tidy_up.test.ts +++ b/test/moves/tidy_up.test.ts @@ -1,7 +1,5 @@ import { Stat } from "#enums/stat"; import { ArenaTagType } from "#app/enums/arena-tag-type"; -import { MoveEndPhase } from "#app/phases/move-end-phase"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import GameManager from "#test/testUtils/gameManager"; @@ -42,9 +40,9 @@ describe("Moves - Tidy Up", () => { await game.classicMode.startBattle(); game.move.select(MoveId.SPIKES); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); game.move.select(MoveId.TIDY_UP); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); expect(game.scene.arena.getTag(ArenaTagType.SPIKES)).toBeUndefined(); }); @@ -53,9 +51,9 @@ describe("Moves - Tidy Up", () => { await game.classicMode.startBattle(); game.move.select(MoveId.STEALTH_ROCK); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); game.move.select(MoveId.TIDY_UP); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); expect(game.scene.arena.getTag(ArenaTagType.STEALTH_ROCK)).toBeUndefined(); }); @@ -64,9 +62,9 @@ describe("Moves - Tidy Up", () => { await game.classicMode.startBattle(); game.move.select(MoveId.TOXIC_SPIKES); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); game.move.select(MoveId.TIDY_UP); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); expect(game.scene.arena.getTag(ArenaTagType.TOXIC_SPIKES)).toBeUndefined(); }); @@ -76,9 +74,9 @@ describe("Moves - Tidy Up", () => { await game.classicMode.startBattle(); game.move.select(MoveId.STICKY_WEB); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); game.move.select(MoveId.TIDY_UP); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); expect(game.scene.arena.getTag(ArenaTagType.STICKY_WEB)).toBeUndefined(); }); @@ -88,9 +86,9 @@ describe("Moves - Tidy Up", () => { await game.classicMode.startBattle(); game.move.select(MoveId.SUBSTITUTE); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); game.move.select(MoveId.TIDY_UP); - await game.phaseInterceptor.to(MoveEndPhase); + await game.phaseInterceptor.to("MoveEndPhase"); const pokemon = [game.scene.getPlayerPokemon()!, game.scene.getEnemyPokemon()!]; pokemon.forEach(p => { @@ -108,7 +106,7 @@ describe("Moves - Tidy Up", () => { expect(playerPokemon.getStatStage(Stat.SPD)).toBe(0); game.move.select(MoveId.TIDY_UP); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(playerPokemon.getStatStage(Stat.ATK)).toBe(1); expect(playerPokemon.getStatStage(Stat.SPD)).toBe(1); diff --git a/test/moves/torment.test.ts b/test/moves/torment.test.ts index e4d926d9601..f24a51dd6f8 100644 --- a/test/moves/torment.test.ts +++ b/test/moves/torment.test.ts @@ -6,7 +6,6 @@ import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { MoveResult } from "#enums/move-result"; import { BattlerTagType } from "#enums/battler-tag-type"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; describe("Moves - Torment", () => { let phaserGame: Phaser.Game; @@ -57,7 +56,7 @@ describe("Moves - Torment", () => { // Third turn, Tackle can be used. game.move.select(MoveId.TACKLE); await game.move.selectEnemyMove(MoveId.SPLASH); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const move3 = playerPokemon.getLastXMoves(1)[0]!; expect(move3.move).toBe(MoveId.TACKLE); }); diff --git a/test/moves/transform.test.ts b/test/moves/transform.test.ts index 4fbaf0136ab..c85b97b4a85 100644 --- a/test/moves/transform.test.ts +++ b/test/moves/transform.test.ts @@ -2,7 +2,6 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import Phaser from "phaser"; import GameManager from "#test/testUtils/gameManager"; import { SpeciesId } from "#enums/species-id"; -import { TurnEndPhase } from "#app/phases/turn-end-phase"; import { MoveId } from "#enums/move-id"; import { Stat, EFFECTIVE_STATS } from "#enums/stat"; import { AbilityId } from "#enums/ability-id"; @@ -40,7 +39,7 @@ describe("Moves - Transform", () => { await game.classicMode.startBattle([SpeciesId.DITTO]); game.move.select(MoveId.TRANSFORM); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); const player = game.scene.getPlayerPokemon()!; const enemy = game.scene.getEnemyPokemon()!; @@ -75,7 +74,7 @@ describe("Moves - Transform", () => { const avgSpAtk = Math.floor((player.getStat(Stat.SPATK, false) + enemy.getStat(Stat.SPATK, false)) / 2); game.move.select(MoveId.TRANSFORM); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); expect(player.getStat(Stat.ATK, false)).toBe(avgAtk); expect(enemy.getStat(Stat.ATK, false)).toBe(avgAtk); @@ -91,7 +90,7 @@ describe("Moves - Transform", () => { const player = game.scene.getPlayerPokemon()!; game.move.select(MoveId.TRANSFORM); - await game.phaseInterceptor.to(TurnEndPhase); + await game.phaseInterceptor.to("TurnEndPhase"); player.getMoveset().forEach(move => { // Should set correct maximum PP without touching `ppUp` diff --git a/test/moves/wide_guard.test.ts b/test/moves/wide_guard.test.ts index 07c02158e94..85b8792e6d2 100644 --- a/test/moves/wide_guard.test.ts +++ b/test/moves/wide_guard.test.ts @@ -5,8 +5,6 @@ import { SpeciesId } from "#enums/species-id"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import { Stat } from "#enums/stat"; -import { BerryPhase } from "#app/phases/berry-phase"; -import { CommandPhase } from "#app/phases/command-phase"; describe("Moves - Wide Guard", () => { let phaserGame: Phaser.Game; @@ -42,11 +40,11 @@ describe("Moves - Wide Guard", () => { game.move.select(MoveId.WIDE_GUARD); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); leadPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp())); }); @@ -60,11 +58,11 @@ describe("Moves - Wide Guard", () => { game.move.select(MoveId.WIDE_GUARD); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); leadPokemon.forEach(p => expect(p.getStatStage(Stat.ATK)).toBe(0)); }); @@ -78,11 +76,11 @@ describe("Moves - Wide Guard", () => { game.move.select(MoveId.WIDE_GUARD); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SPLASH, 1); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(leadPokemon.some(p => p.hp < p.getMaxHp())).toBeTruthy(); }); @@ -97,11 +95,11 @@ describe("Moves - Wide Guard", () => { game.move.select(MoveId.WIDE_GUARD); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); game.move.select(MoveId.SURF, 1); - await game.phaseInterceptor.to(BerryPhase, false); + await game.phaseInterceptor.to("BerryPhase", false); expect(leadPokemon[0].hp).toBe(leadPokemon[0].getMaxHp()); enemyPokemon.forEach(p => expect(p.hp).toBeLessThan(p.getMaxHp())); diff --git a/test/mystery-encounter/encounter-test-utils.ts b/test/mystery-encounter/encounter-test-utils.ts index 6954d6212cc..e86f760b450 100644 --- a/test/mystery-encounter/encounter-test-utils.ts +++ b/test/mystery-encounter/encounter-test-utils.ts @@ -6,7 +6,6 @@ import { MessagePhase } from "#app/phases/message-phase"; import { MysteryEncounterBattlePhase, MysteryEncounterOptionSelectedPhase, - MysteryEncounterPhase, MysteryEncounterRewardsPhase, } from "#app/phases/mystery-encounter-phases"; import { VictoryPhase } from "#app/phases/victory-phase"; @@ -89,9 +88,9 @@ export async function runMysteryEncounterToEnd( uiHandler.processInput(Button.ACTION); }); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); } 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(); @@ -207,5 +206,5 @@ export async function skipBattleRunMysteryEncounterRewardsPhase(game: GameManage game.scene.phaseManager.pushPhase(new VictoryPhase(0)); game.phaseInterceptor.superEndPhase(); game.setMode(UiMode.MESSAGE); - await game.phaseInterceptor.to(MysteryEncounterRewardsPhase, runRewardsPhase); + await game.phaseInterceptor.to("MysteryEncounterRewardsPhase", runRewardsPhase); } diff --git a/test/mystery-encounter/encounters/a-trainers-test-encounter.test.ts b/test/mystery-encounter/encounters/a-trainers-test-encounter.test.ts index 82cac197fe9..9093dfc0749 100644 --- a/test/mystery-encounter/encounters/a-trainers-test-encounter.test.ts +++ b/test/mystery-encounter/encounters/a-trainers-test-encounter.test.ts @@ -130,7 +130,7 @@ describe("A Trainer's Test - 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; @@ -178,7 +178,7 @@ describe("A Trainer's Test - Mystery Encounter", () => { const eggsBeforeLength = eggsBefore.length; 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); const eggsAfter = scene.gameData.eggs; diff --git a/test/mystery-encounter/encounters/absolute-avarice-encounter.test.ts b/test/mystery-encounter/encounters/absolute-avarice-encounter.test.ts index b6c4e4d85fb..29e600cb127 100644 --- a/test/mystery-encounter/encounters/absolute-avarice-encounter.test.ts +++ b/test/mystery-encounter/encounters/absolute-avarice-encounter.test.ts @@ -147,7 +147,7 @@ describe("Absolute Avarice - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.ABSOLUTE_AVARICE, 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); for (const partyPokemon of scene.getPlayerParty()) { diff --git a/test/mystery-encounter/encounters/an-offer-you-cant-refuse-encounter.test.ts b/test/mystery-encounter/encounters/an-offer-you-cant-refuse-encounter.test.ts index 4f986f58b88..1d2bd489435 100644 --- a/test/mystery-encounter/encounters/an-offer-you-cant-refuse-encounter.test.ts +++ b/test/mystery-encounter/encounters/an-offer-you-cant-refuse-encounter.test.ts @@ -16,7 +16,6 @@ import { initSceneWithoutEncounterPhase } from "#test/testUtils/gameManagerUtils import { getPokemonSpecies } from "#app/utils/pokemon-utils"; import { MoveId } from "#enums/move-id"; import { ShinyRateBoosterModifier } from "#app/modifier/modifier"; -import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; import i18next from "i18next"; import { AbilityId } from "#enums/ability-id"; @@ -197,7 +196,7 @@ describe("An Offer You Can't Refuse - Mystery Encounter", () => { const expBefore = gyarados.exp; await runMysteryEncounterToEnd(game, 2); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); expect(gyarados.exp).toBe( expBefore + Math.floor((getPokemonSpecies(SpeciesId.LIEPARD).baseExp * defaultWave) / 5 + 1), @@ -213,7 +212,7 @@ describe("An Offer You Can't Refuse - Mystery Encounter", () => { const expBefore = abra.exp; await runMysteryEncounterToEnd(game, 2); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); expect(abra.exp).toBe( expBefore + Math.floor((getPokemonSpecies(SpeciesId.LIEPARD).baseExp * defaultWave) / 5 + 1), diff --git a/test/mystery-encounter/encounters/berries-abound-encounter.test.ts b/test/mystery-encounter/encounters/berries-abound-encounter.test.ts index 8c2c6c608cd..f061115ccd3 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 4da8ff7f643..8decb1531cc 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 85193d1ec72..5cb253b8caa 100644 --- a/test/mystery-encounter/encounters/clowning-around-encounter.test.ts +++ b/test/mystery-encounter/encounters/clowning-around-encounter.test.ts @@ -36,7 +36,6 @@ import { PokemonType } from "#enums/pokemon-type"; import { CommandPhase } from "#app/phases/command-phase"; import { MovePhase } from "#app/phases/move-phase"; import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; -import { NewBattlePhase } from "#app/phases/new-battle-phase"; const namespace = "mysteryEncounters/clowningAround"; const defaultParty = [SpeciesId.LAPRAS, SpeciesId.GENGAR, SpeciesId.ABRA]; @@ -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 e47c7cc1a42..61ac07f2f37 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/delibirdy-encounter.test.ts b/test/mystery-encounter/encounters/delibirdy-encounter.test.ts index 3ef8431cc2c..f6a8731f8f1 100644 --- a/test/mystery-encounter/encounters/delibirdy-encounter.test.ts +++ b/test/mystery-encounter/encounters/delibirdy-encounter.test.ts @@ -150,7 +150,7 @@ describe("Delibird-y - Mystery Encounter", () => { it("should be disabled if player does not have enough money", async () => { scene.money = 0; await game.runToMysteryEncounter(MysteryEncounterType.DELIBIRDY, 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); @@ -305,7 +305,7 @@ describe("Delibird-y - Mystery Encounter", () => { scene.addModifier(modifier, true, false, false, true); await scene.updateModifiers(true); - await game.phaseInterceptor.to(MysteryEncounterPhase, false); + await game.phaseInterceptor.to("MysteryEncounterPhase", false); const encounterPhase = scene.phaseManager.getCurrentPhase(); expect(encounterPhase?.constructor.name).toBe(MysteryEncounterPhase.name); @@ -438,7 +438,7 @@ describe("Delibird-y - Mystery Encounter", () => { scene.addModifier(modifier, true, false, false, true); await scene.updateModifiers(true); - 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 a82734d0c03..17cf3a2d012 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/field-trip-encounter.test.ts b/test/mystery-encounter/encounters/field-trip-encounter.test.ts index f4b3c52eb65..d6d4e9f2b73 100644 --- a/test/mystery-encounter/encounters/field-trip-encounter.test.ts +++ b/test/mystery-encounter/encounters/field-trip-encounter.test.ts @@ -11,7 +11,6 @@ import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import * as MysteryEncounters from "#app/data/mystery-encounters/mystery-encounters"; import { FieldTripEncounter } from "#app/data/mystery-encounters/encounters/field-trip-encounter"; import { MoveId } from "#enums/move-id"; -import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; import { UiMode } from "#enums/ui-mode"; import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; import i18next from "i18next"; @@ -85,7 +84,7 @@ describe("Field Trip - Mystery Encounter", () => { it("Should give no reward on incorrect option", async () => { await game.runToMysteryEncounter(MysteryEncounterType.FIELD_TRIP, defaultParty); await runMysteryEncounterToEnd(game, 1, { pokemonNo: 1, optionNo: 2 }); - await game.phaseInterceptor.to(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( @@ -97,7 +96,7 @@ describe("Field Trip - Mystery Encounter", () => { it("Should give proper rewards on correct Physical move option", async () => { await game.runToMysteryEncounter(MysteryEncounterType.FIELD_TRIP, defaultParty); await runMysteryEncounterToEnd(game, 1, { pokemonNo: 1, optionNo: 1 }); - await game.phaseInterceptor.to(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( @@ -146,7 +145,7 @@ describe("Field Trip - Mystery Encounter", () => { it("Should give no reward on incorrect option", async () => { await game.runToMysteryEncounter(MysteryEncounterType.FIELD_TRIP, defaultParty); await runMysteryEncounterToEnd(game, 2, { pokemonNo: 1, optionNo: 1 }); - await game.phaseInterceptor.to(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( @@ -158,7 +157,7 @@ describe("Field Trip - Mystery Encounter", () => { it("Should give proper rewards on correct Special move option", async () => { await game.runToMysteryEncounter(MysteryEncounterType.FIELD_TRIP, defaultParty); await runMysteryEncounterToEnd(game, 2, { pokemonNo: 1, optionNo: 2 }); - await game.phaseInterceptor.to(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( @@ -207,7 +206,7 @@ describe("Field Trip - Mystery Encounter", () => { it("Should give no reward on incorrect option", async () => { await game.runToMysteryEncounter(MysteryEncounterType.FIELD_TRIP, defaultParty); await runMysteryEncounterToEnd(game, 3, { pokemonNo: 1, optionNo: 1 }); - await game.phaseInterceptor.to(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); const modifierSelectHandler = scene.ui.handlers.find( @@ -220,7 +219,7 @@ describe("Field Trip - Mystery Encounter", () => { vi.spyOn(i18next, "t"); await game.runToMysteryEncounter(MysteryEncounterType.FIELD_TRIP, defaultParty); await runMysteryEncounterToEnd(game, 3, { pokemonNo: 1, optionNo: 3 }); - await game.phaseInterceptor.to(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/fiery-fallout-encounter.test.ts b/test/mystery-encounter/encounters/fiery-fallout-encounter.test.ts index 16adc47ff11..10e385e33bc 100644 --- a/test/mystery-encounter/encounters/fiery-fallout-encounter.test.ts +++ b/test/mystery-encounter/encounters/fiery-fallout-encounter.test.ts @@ -176,7 +176,7 @@ describe("Fiery Fallout - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.FIERY_FALLOUT, 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); const leadPokemonId = scene.getPlayerParty()?.[0].id; @@ -265,7 +265,7 @@ describe("Fiery Fallout - Mystery Encounter", () => { it("should give attack type boosting item to lead pokemon", async () => { await game.runToMysteryEncounter(MysteryEncounterType.FIERY_FALLOUT, defaultParty); await runMysteryEncounterToEnd(game, 3); - await game.phaseInterceptor.to(SelectModifierPhase, false); + await game.phaseInterceptor.to("SelectModifierPhase", false); expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name); const leadPokemonItems = scene.getPlayerParty()?.[0].getHeldItems() as PokemonHeldItemModifier[]; @@ -284,7 +284,7 @@ describe("Fiery Fallout - Mystery Encounter", () => { it("should be disabled if not enough FIRE types are in party", async () => { await game.runToMysteryEncounter(MysteryEncounterType.FIERY_FALLOUT, [SpeciesId.MAGIKARP]); - 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/fight-or-flight-encounter.test.ts b/test/mystery-encounter/encounters/fight-or-flight-encounter.test.ts index 28db869004c..b7c33d37913 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 ae7e269ea00..e3bb84c6cee 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); @@ -154,15 +154,15 @@ describe("Fun And Games! - Mystery Encounter", () => { // Turn 1 (game.scene.phaseManager.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, 0, MoveUseMode.NORMAL); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); // Turn 2 (game.scene.phaseManager.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, 0, MoveUseMode.NORMAL); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); // 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 bb598f4ae6e..14db34c6a8e 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/lost-at-sea-encounter.test.ts b/test/mystery-encounter/encounters/lost-at-sea-encounter.test.ts index a55806e5f48..0eb57462fa7 100644 --- a/test/mystery-encounter/encounters/lost-at-sea-encounter.test.ts +++ b/test/mystery-encounter/encounters/lost-at-sea-encounter.test.ts @@ -13,7 +13,6 @@ import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { initSceneWithoutEncounterPhase } from "#test/testUtils/gameManagerUtils"; import type BattleScene from "#app/battle-scene"; import { MysteryEncounterPhase } from "#app/phases/mystery-encounter-phases"; -import { PartyExpPhase } from "#app/phases/party-exp-phase"; import i18next from "i18next"; const namespace = "mysteryEncounters/lostAtSea"; @@ -116,7 +115,7 @@ describe("Lost at Sea - Mystery Encounter", () => { const expBefore = blastoise!.exp; await runMysteryEncounterToEnd(game, 1); - await game.phaseInterceptor.to(PartyExpPhase); + await game.phaseInterceptor.to("PartyExpPhase"); expect(blastoise?.exp).toBe(expBefore + Math.floor((laprasSpecies.baseExp * defaultWave) / 5 + 1)); }); @@ -133,7 +132,7 @@ describe("Lost at Sea - Mystery Encounter", () => { it("should be disabled if no surfable PKM is in party", async () => { await game.runToMysteryEncounter(MysteryEncounterType.LOST_AT_SEA, [SpeciesId.ARCANINE]); - await game.phaseInterceptor.to(MysteryEncounterPhase, false); + await game.phaseInterceptor.to("MysteryEncounterPhase", false); const encounterPhase = scene.phaseManager.getCurrentPhase(); expect(encounterPhase?.constructor.name).toBe(MysteryEncounterPhase.name); @@ -181,7 +180,7 @@ describe("Lost at Sea - Mystery Encounter", () => { const expBefore = pidgeot!.exp; await runMysteryEncounterToEnd(game, 2); - await game.phaseInterceptor.to(PartyExpPhase); + await game.phaseInterceptor.to("PartyExpPhase"); expect(pidgeot!.exp).toBe(expBefore + Math.floor((laprasBaseExp * defaultWave) / 5 + 1)); }); @@ -198,7 +197,7 @@ describe("Lost at Sea - Mystery Encounter", () => { it("should be disabled if no flyable PKM is in party", async () => { await game.runToMysteryEncounter(MysteryEncounterType.LOST_AT_SEA, [SpeciesId.ARCANINE]); - 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/mysterious-challengers-encounter.test.ts b/test/mystery-encounter/encounters/mysterious-challengers-encounter.test.ts index 478648d88a7..03653842796 100644 --- a/test/mystery-encounter/encounters/mysterious-challengers-encounter.test.ts +++ b/test/mystery-encounter/encounters/mysterious-challengers-encounter.test.ts @@ -162,9 +162,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( @@ -206,9 +206,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( @@ -263,9 +263,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/part-timer-encounter.test.ts b/test/mystery-encounter/encounters/part-timer-encounter.test.ts index d36b387cae1..cb747d66593 100644 --- a/test/mystery-encounter/encounters/part-timer-encounter.test.ts +++ b/test/mystery-encounter/encounters/part-timer-encounter.test.ts @@ -234,7 +234,7 @@ describe("Part-Timer - Mystery Encounter", () => { await game.runToMysteryEncounter(MysteryEncounterType.PART_TIMER, defaultParty); // Mock movesets 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/safari-zone.test.ts b/test/mystery-encounter/encounters/safari-zone.test.ts index 7ac26f48e59..b6234832742 100644 --- a/test/mystery-encounter/encounters/safari-zone.test.ts +++ b/test/mystery-encounter/encounters/safari-zone.test.ts @@ -111,7 +111,7 @@ describe("Safari Zone - Mystery Encounter", () => { it("should NOT be selectable if the player doesn't have enough money", async () => { game.scene.money = 0; await game.runToMysteryEncounter(MysteryEncounterType.SAFARI_ZONE, 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); diff --git a/test/mystery-encounter/encounters/teleporting-hijinks-encounter.test.ts b/test/mystery-encounter/encounters/teleporting-hijinks-encounter.test.ts index 2138298ee2b..70775c99410 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 c9d6f540191..7463fefcc80 100644 --- a/test/mystery-encounter/encounters/the-expert-breeder-encounter.test.ts +++ b/test/mystery-encounter/encounters/the-expert-breeder-encounter.test.ts @@ -20,7 +20,6 @@ import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; import { TheExpertPokemonBreederEncounter } from "#app/data/mystery-encounters/encounters/the-expert-pokemon-breeder-encounter"; import { TrainerType } from "#enums/trainer-type"; import { EggTier } from "#enums/egg-type"; -import { PostMysteryEncounterPhase } from "#app/phases/mystery-encounter-phases"; import { FRIENDSHIP_GAIN_FROM_BATTLE } from "#app/data/balance/starters"; const namespace = "mysteryEncounters/theExpertPokemonBreeder"; @@ -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; @@ -188,7 +187,7 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => { expect(eggsAfter.filter(egg => egg.tier === EggTier.RARE).length).toBe(rareEggs); game.phaseInterceptor.superEndPhase(); - await game.phaseInterceptor.to(PostMysteryEncounterPhase); + 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; @@ -273,7 +272,7 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => { expect(eggsAfter.filter(egg => egg.tier === EggTier.RARE).length).toBe(rareEggs); game.phaseInterceptor.superEndPhase(); - await game.phaseInterceptor.to(PostMysteryEncounterPhase); + 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; @@ -355,7 +354,7 @@ describe("The Expert Pokémon Breeder - Mystery Encounter", () => { expect(eggsAfter.filter(egg => egg.tier === EggTier.RARE).length).toBe(rareEggs); game.phaseInterceptor.superEndPhase(); - await game.phaseInterceptor.to(PostMysteryEncounterPhase); + 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-pokemon-salesman-encounter.test.ts b/test/mystery-encounter/encounters/the-pokemon-salesman-encounter.test.ts index 990e39014e2..a083794ffba 100644 --- a/test/mystery-encounter/encounters/the-pokemon-salesman-encounter.test.ts +++ b/test/mystery-encounter/encounters/the-pokemon-salesman-encounter.test.ts @@ -171,7 +171,7 @@ describe("The Pokemon Salesman - Mystery Encounter", () => { it("should be disabled if player does not have enough money", async () => { scene.money = 0; await game.runToMysteryEncounter(MysteryEncounterType.THE_POKEMON_SALESMAN, 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); 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 96060e4114c..ab70413034e 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 012b88bcd73..ff2642a98fc 100644 --- a/test/mystery-encounter/encounters/the-winstrate-challenge-encounter.test.ts +++ b/test/mystery-encounter/encounters/the-winstrate-challenge-encounter.test.ts @@ -20,7 +20,6 @@ import { MoveId } from "#enums/move-id"; import { getPokemonSpecies } from "#app/utils/pokemon-utils"; import { TheWinstrateChallengeEncounter } from "#app/data/mystery-encounters/encounters/the-winstrate-challenge-encounter"; import { Status } from "#app/data/status-effect"; -import { MysteryEncounterRewardsPhase } from "#app/phases/mystery-encounter-phases"; import { CommandPhase } from "#app/phases/command-phase"; import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; import { PartyHealPhase } from "#app/phases/party-heal-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( @@ -370,8 +369,8 @@ async function skipBattleToNextBattle(game: GameManager, isFinalBattle = false) game.scene.phaseManager.pushPhase(new VictoryPhase(0)); game.phaseInterceptor.superEndPhase(); if (isFinalBattle) { - await game.phaseInterceptor.to(MysteryEncounterRewardsPhase); + await game.phaseInterceptor.to("MysteryEncounterRewardsPhase"); } else { - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); } } 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 9ab5f16d1b9..e9cd6f96f6a 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/uncommon-breed-encounter.test.ts b/test/mystery-encounter/encounters/uncommon-breed-encounter.test.ts index ec64a17d291..6e465be0797 100644 --- a/test/mystery-encounter/encounters/uncommon-breed-encounter.test.ts +++ b/test/mystery-encounter/encounters/uncommon-breed-encounter.test.ts @@ -189,7 +189,7 @@ describe("Uncommon Breed - Mystery Encounter", () => { scene.removeModifier(mod); }); await scene.updateModifiers(true); - await game.phaseInterceptor.to(MysteryEncounterPhase, false); + await game.phaseInterceptor.to("MysteryEncounterPhase", false); const encounterPhase = scene.phaseManager.getCurrentPhase(); expect(encounterPhase?.constructor.name).toBe(MysteryEncounterPhase.name); @@ -249,7 +249,7 @@ describe("Uncommon Breed - Mystery Encounter", () => { it("should NOT be selectable if the player doesn't have an Attracting move", async () => { await game.runToMysteryEncounter(MysteryEncounterType.UNCOMMON_BREED, 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); diff --git a/test/mystery-encounter/encounters/weird-dream-encounter.test.ts b/test/mystery-encounter/encounters/weird-dream-encounter.test.ts index 475d5cc3c6e..8bf9c86896a 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/mystery-encounter/mystery-encounter.test.ts b/test/mystery-encounter/mystery-encounter.test.ts index be1f153f8b1..ce675f65236 100644 --- a/test/mystery-encounter/mystery-encounter.test.ts +++ b/test/mystery-encounter/mystery-encounter.test.ts @@ -33,7 +33,7 @@ describe("Mystery Encounters", () => { SpeciesId.VOLCARONA, ]); - await game.phaseInterceptor.to(MysteryEncounterPhase, false); + await game.phaseInterceptor.to("MysteryEncounterPhase", false); expect(game.scene.phaseManager.getCurrentPhase()!.constructor.name).toBe(MysteryEncounterPhase.name); }); diff --git a/test/phases/learn-move-phase.test.ts b/test/phases/learn-move-phase.test.ts index 88b8187069b..87eb8498d73 100644 --- a/test/phases/learn-move-phase.test.ts +++ b/test/phases/learn-move-phase.test.ts @@ -3,7 +3,6 @@ import Phaser from "phaser"; import GameManager from "#test/testUtils/gameManager"; import { SpeciesId } from "#enums/species-id"; import { MoveId } from "#enums/move-id"; -import { LearnMovePhase } from "#app/phases/learn-move-phase"; import { UiMode } from "#enums/ui-mode"; import { Button } from "#app/enums/buttons"; @@ -33,7 +32,7 @@ describe("Learn Move Phase", () => { const newMovePos = pokemon?.getMoveset().length; game.move.select(MoveId.SPLASH); await game.doKillOpponents(); - await game.phaseInterceptor.to(LearnMovePhase); + await game.phaseInterceptor.to("LearnMovePhase"); const levelMove = pokemon.getLevelMoves(5)[0]; const levelReq = levelMove[0]; const levelMoveId = levelMove[1]; @@ -59,7 +58,7 @@ describe("Learn Move Phase", () => { game.scene.ui.setCursor(moveSlotNum); game.scene.ui.processInput(Button.ACTION); }); - await game.phaseInterceptor.to(LearnMovePhase); + await game.phaseInterceptor.to("LearnMovePhase"); const levelMove = bulbasaur.getLevelMoves(5)[0]; const levelReq = levelMove[0]; @@ -92,7 +91,7 @@ describe("Learn Move Phase", () => { game.onNextPrompt("LearnMovePhase", UiMode.CONFIRM, () => { game.scene.ui.processInput(Button.ACTION); }); - await game.phaseInterceptor.to(LearnMovePhase); + await game.phaseInterceptor.to("LearnMovePhase"); const levelReq = bulbasaur.getLevelMoves(5)[0][0]; expect(bulbasaur.level).toBeGreaterThanOrEqual(levelReq); diff --git a/test/phases/mystery-encounter-phase.test.ts b/test/phases/mystery-encounter-phase.test.ts index b17682d6c74..98c7aa929c7 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.phaseInterceptor.shiftPhase(); }); - 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/phases/phases.test.ts b/test/phases/phases.test.ts index 9d1c1804615..e881125dca7 100644 --- a/test/phases/phases.test.ts +++ b/test/phases/phases.test.ts @@ -31,7 +31,7 @@ describe("Phases", () => { it("should start the login phase", async () => { const loginPhase = new LoginPhase(); scene.phaseManager.unshiftPhase(loginPhase); - await game.phaseInterceptor.to(LoginPhase); + await game.phaseInterceptor.to("LoginPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MESSAGE); }); }); @@ -40,7 +40,7 @@ describe("Phases", () => { it("should start the title phase", async () => { const titlePhase = new TitlePhase(); scene.phaseManager.unshiftPhase(titlePhase); - await game.phaseInterceptor.to(TitlePhase); + await game.phaseInterceptor.to("TitlePhase"); expect(scene.ui.getMode()).to.equal(UiMode.TITLE); }); }); @@ -49,7 +49,7 @@ describe("Phases", () => { it("should start the unavailable phase", async () => { const unavailablePhase = new UnavailablePhase(); scene.phaseManager.unshiftPhase(unavailablePhase); - await game.phaseInterceptor.to(UnavailablePhase); + await game.phaseInterceptor.to("UnavailablePhase"); expect(scene.ui.getMode()).to.equal(UiMode.UNAVAILABLE); }); }); diff --git a/test/phases/select-modifier-phase.test.ts b/test/phases/select-modifier-phase.test.ts index b6c3089e236..17d74b41767 100644 --- a/test/phases/select-modifier-phase.test.ts +++ b/test/phases/select-modifier-phase.test.ts @@ -48,7 +48,7 @@ describe("SelectModifierPhase", () => { initSceneWithoutEncounterPhase(scene, [SpeciesId.ABRA, SpeciesId.VOLCARONA]); const selectModifierPhase = new SelectModifierPhase(); scene.phaseManager.unshiftPhase(selectModifierPhase); - await game.phaseInterceptor.to(SelectModifierPhase); + await game.phaseInterceptor.to("SelectModifierPhase"); expect(scene.ui.getMode()).to.equal(UiMode.MODIFIER_SELECT); }); @@ -241,7 +241,7 @@ describe("SelectModifierPhase", () => { const selectModifierPhase = new SelectModifierPhase(0, undefined, customModifiers); scene.phaseManager.unshiftPhase(selectModifierPhase); game.move.select(MoveId.SPLASH); - 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( @@ -265,7 +265,7 @@ describe("SelectModifierPhase", () => { const selectModifierPhase = new SelectModifierPhase(0, undefined, customModifiers); scene.phaseManager.unshiftPhase(selectModifierPhase); game.move.select(MoveId.SPLASH); - 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/testUtils/gameManager.ts b/test/testUtils/gameManager.ts index f18ff6e98f7..7c38533178f 100644 --- a/test/testUtils/gameManager.ts +++ b/test/testUtils/gameManager.ts @@ -55,6 +55,7 @@ import TextInterceptor from "#test/testUtils/TextInterceptor"; import { AES, enc } from "crypto-js"; import fs from "node:fs"; import { expect, vi } from "vitest"; +import type { PhaseString } from "#app/@types/phase-types"; /** * Class to manage the game state and transitions between phases. @@ -168,10 +169,10 @@ export default class GameManager { * @param expireFn - Optional function to determine if the prompt has expired. */ onNextPrompt( - phaseTarget: string, + phaseTarget: PhaseString, mode: UiMode, callback: () => void, - expireFn?: () => void, + expireFn?: () => boolean, awaitingActionInput = false, ) { this.phaseInterceptor.addToNextPrompt(phaseTarget, mode, callback, expireFn, awaitingActionInput); @@ -225,7 +226,7 @@ export default class GameManager { this.removeEnemyHeldItems(); } - await this.phaseInterceptor.to(EncounterPhase); + await this.phaseInterceptor.to("EncounterPhase"); console.log("===finished run to final boss encounter==="); } @@ -461,7 +462,7 @@ export default class GameManager { return new Promise(async (resolve, reject) => { pokemon.hp = 0; this.scene.phaseManager.pushPhase(new FaintPhase(pokemon.getBattlerIndex(), true)); - await this.phaseInterceptor.to(FaintPhase).catch(e => reject(e)); + await this.phaseInterceptor.to("FaintPhase").catch(e => reject(e)); resolve(); }); } @@ -538,7 +539,7 @@ export default 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/testUtils/helpers/challengeModeHelper.ts b/test/testUtils/helpers/challengeModeHelper.ts index f0b4b151d22..60ce75ed814 100644 --- a/test/testUtils/helpers/challengeModeHelper.ts +++ b/test/testUtils/helpers/challengeModeHelper.ts @@ -85,7 +85,7 @@ export class ChallengeModeHelper extends GameManagerHelper { ); } - await this.game.phaseInterceptor.to(CommandPhase); + await this.game.phaseInterceptor.to("CommandPhase"); console.log("==================[New Turn]=================="); } } diff --git a/test/testUtils/helpers/classicModeHelper.ts b/test/testUtils/helpers/classicModeHelper.ts index eff97483777..feb62b543cc 100644 --- a/test/testUtils/helpers/classicModeHelper.ts +++ b/test/testUtils/helpers/classicModeHelper.ts @@ -45,7 +45,7 @@ export class ClassicModeHelper extends GameManagerHelper { selectStarterPhase.initBattle(starters); }); - await this.game.phaseInterceptor.to(EncounterPhase); + await this.game.phaseInterceptor.to("EncounterPhase"); if (overrides.OPP_HELD_ITEMS_OVERRIDE.length === 0 && this.game.override.removeEnemyStartingItems) { this.game.removeEnemyHeldItems(); } @@ -90,7 +90,7 @@ export class ClassicModeHelper extends GameManagerHelper { ); } - await this.game.phaseInterceptor.to(CommandPhase); + await this.game.phaseInterceptor.to("CommandPhase"); console.log("==================[New Turn]=================="); } } diff --git a/test/testUtils/helpers/dailyModeHelper.ts b/test/testUtils/helpers/dailyModeHelper.ts index 4672d4dc787..ae30e257ecf 100644 --- a/test/testUtils/helpers/dailyModeHelper.ts +++ b/test/testUtils/helpers/dailyModeHelper.ts @@ -2,7 +2,6 @@ import { BattleStyle } from "#app/enums/battle-style"; import { Button } from "#app/enums/buttons"; import overrides from "#app/overrides"; import { CommandPhase } from "#app/phases/command-phase"; -import { EncounterPhase } from "#app/phases/encounter-phase"; import { TitlePhase } from "#app/phases/title-phase"; import { TurnInitPhase } from "#app/phases/turn-init-phase"; import type SaveSlotSelectUiHandler from "#app/ui/save-slot-select-ui-handler"; @@ -35,7 +34,7 @@ export class DailyModeHelper extends GameManagerHelper { uihandler.processInput(Button.ACTION); // select first slot. that's fine }); - await this.game.phaseInterceptor.to(EncounterPhase); + await this.game.phaseInterceptor.to("EncounterPhase"); if (overrides.OPP_HELD_ITEMS_OVERRIDE.length === 0 && this.game.override.removeEnemyStartingItems) { this.game.removeEnemyHeldItems(); @@ -71,7 +70,7 @@ export class DailyModeHelper extends GameManagerHelper { ); } - await this.game.phaseInterceptor.to(CommandPhase); + await this.game.phaseInterceptor.to("CommandPhase"); console.log("==================[New Turn]=================="); } } diff --git a/test/testUtils/helpers/moveHelper.ts b/test/testUtils/helpers/moveHelper.ts index ed1441a6a2f..be51162cec3 100644 --- a/test/testUtils/helpers/moveHelper.ts +++ b/test/testUtils/helpers/moveHelper.ts @@ -5,7 +5,7 @@ import { PokemonMove } from "#app/data/moves/pokemon-move"; import Overrides from "#app/overrides"; import type { CommandPhase } from "#app/phases/command-phase"; import type { EnemyCommandPhase } from "#app/phases/enemy-command-phase"; -import { MoveEffectPhase } from "#app/phases/move-effect-phase"; +import type { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { Command } from "#enums/command"; import { MoveId } from "#enums/move-id"; import { UiMode } from "#enums/ui-mode"; @@ -25,7 +25,7 @@ export class MoveHelper extends GameManagerHelper { * @returns A promise that resolves once the next MoveEffectPhase has been reached (not run). */ public async forceHit(): Promise { - await this.game.phaseInterceptor.to(MoveEffectPhase, false); + await this.game.phaseInterceptor.to("MoveEffectPhase", false); const moveEffectPhase = this.game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase; vi.spyOn(moveEffectPhase.move, "calculateBattleAccuracy").mockReturnValue(-1); } @@ -37,7 +37,7 @@ export class MoveHelper extends GameManagerHelper { * @returns A promise that resolves once the next MoveEffectPhase has been reached (not run). */ public async forceMiss(firstTargetOnly = false): Promise { - await this.game.phaseInterceptor.to(MoveEffectPhase, false); + await this.game.phaseInterceptor.to("MoveEffectPhase", false); const moveEffectPhase = this.game.scene.phaseManager.getCurrentPhase() as MoveEffectPhase; const accuracy = vi.spyOn(moveEffectPhase.move, "calculateBattleAccuracy"); diff --git a/test/testUtils/helpers/reloadHelper.ts b/test/testUtils/helpers/reloadHelper.ts index 5a10b0a7235..feedf75acb7 100644 --- a/test/testUtils/helpers/reloadHelper.ts +++ b/test/testUtils/helpers/reloadHelper.ts @@ -82,7 +82,7 @@ export class ReloadHelper extends GameManagerHelper { ); } - await this.game.phaseInterceptor.to(CommandPhase); + await this.game.phaseInterceptor.to("CommandPhase"); console.log("==================[New Turn (Reloaded)]=================="); } } diff --git a/test/ui/battle_info.test.ts b/test/ui/battle_info.test.ts index 3049424e3d2..e8432322816 100644 --- a/test/ui/battle_info.test.ts +++ b/test/ui/battle_info.test.ts @@ -1,6 +1,5 @@ import { ExpGainsSpeed } from "#app/enums/exp-gains-speed"; import { SpeciesId } from "#enums/species-id"; -import { ExpPhase } from "#app/phases/exp-phase"; import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import GameManager from "#test/testUtils/gameManager"; @@ -48,7 +47,7 @@ describe("UI - Battle Info", () => { game.move.select(MoveId.SPLASH); await game.doKillOpponents(); - await game.phaseInterceptor.to(ExpPhase, true); + await game.phaseInterceptor.to("ExpPhase", true); expect(Math.pow).not.toHaveBeenCalledWith(2, expGainsSpeed); }, diff --git a/test/ui/starter-select.test.ts b/test/ui/starter-select.test.ts index 8167ab17957..d008a6d87dc 100644 --- a/test/ui/starter-select.test.ts +++ b/test/ui/starter-select.test.ts @@ -3,7 +3,6 @@ import { Nature } from "#enums/nature"; import { allSpecies } from "#app/data/data-lists"; import { GameModes } from "#enums/game-modes"; import { EncounterPhase } from "#app/phases/encounter-phase"; -import { SelectStarterPhase } from "#app/phases/select-starter-phase"; import type { TitlePhase } from "#app/phases/title-phase"; import type { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler"; import type SaveSlotSelectUiHandler from "#app/ui/save-slot-select-ui-handler"; @@ -54,9 +53,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 => { @@ -115,9 +113,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 +146,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 +176,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 => { @@ -242,9 +238,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 => { @@ -303,9 +298,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 => { @@ -365,9 +359,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 => { @@ -426,9 +419,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 => { @@ -486,9 +478,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 => { @@ -551,9 +542,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 => { diff --git a/test/ui/type-hints.test.ts b/test/ui/type-hints.test.ts index 6b0bc6e5ea5..25ea0ac5460 100644 --- a/test/ui/type-hints.test.ts +++ b/test/ui/type-hints.test.ts @@ -1,7 +1,6 @@ import { Button } from "#app/enums/buttons"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; -import { CommandPhase } from "#app/phases/command-phase"; import FightUiHandler from "#app/ui/fight-ui-handler"; import { UiMode } from "#enums/ui-mode"; import GameManager from "#test/testUtils/gameManager"; @@ -59,7 +58,7 @@ describe("UI - Type Hints", () => { expect.soft(dragonClawText.color).toBe("#929292"); ui.getHandler().processInput(Button.ACTION); }); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); }); it("check status move color", async () => { @@ -84,7 +83,7 @@ describe("UI - Type Hints", () => { expect.soft(growlText.color).toBe(undefined); ui.getHandler().processInput(Button.ACTION); }); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); }); it("should show the proper hint for a move in doubles after one of the enemy pokemon flees", async () => { @@ -121,6 +120,6 @@ describe("UI - Type Hints", () => { expect.soft(shadowBallText.color).toBe(undefined); ui.getHandler().processInput(Button.ACTION); }); - await game.phaseInterceptor.to(CommandPhase); + await game.phaseInterceptor.to("CommandPhase"); }); }); From 105f39088ece7b8604a5376bc489862a7f1e7d0b Mon Sep 17 00:00:00 2001 From: Bertie690 Date: Wed, 18 Jun 2025 19:27:55 -0400 Subject: [PATCH 4/9] Fixed remaining old methods --- test/mystery-encounter/encounter-test-utils.ts | 2 +- .../the-expert-breeder-encounter.test.ts | 6 +++--- .../the-winstrate-challenge-encounter.test.ts | 3 +-- test/testUtils/gameManager.ts | 6 ++---- test/testUtils/helpers/challengeModeHelper.ts | 2 +- test/testUtils/phaseInterceptor.ts | 4 +++- test/ui/pokedex.test.ts | 4 ++-- test/ui/starter-select.test.ts | 17 ++++++++--------- test/ui/transfer-item.test.ts | 4 ---- test/ui/type-hints.test.ts | 3 --- 10 files changed, 21 insertions(+), 30 deletions(-) diff --git a/test/mystery-encounter/encounter-test-utils.ts b/test/mystery-encounter/encounter-test-utils.ts index e86f760b450..de46be5b1fe 100644 --- a/test/mystery-encounter/encounter-test-utils.ts +++ b/test/mystery-encounter/encounter-test-utils.ts @@ -204,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); } 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 7463fefcc80..8c3c2c2aa0e 100644 --- a/test/mystery-encounter/encounters/the-expert-breeder-encounter.test.ts +++ b/test/mystery-encounter/encounters/the-expert-breeder-encounter.test.ts @@ -186,7 +186,7 @@ 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(); + game.phaseInterceptor.shiftPhase(); await game.phaseInterceptor.to("PostMysteryEncounterPhase"); const friendshipAfter = scene.currentBattle.mysteryEncounter!.misc.pokemon1.friendship; @@ -271,7 +271,7 @@ 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(); + game.phaseInterceptor.shiftPhase(); await game.phaseInterceptor.to("PostMysteryEncounterPhase"); const friendshipAfter = scene.currentBattle.mysteryEncounter!.misc.pokemon2.friendship; @@ -353,7 +353,7 @@ 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(); + game.phaseInterceptor.shiftPhase(); await game.phaseInterceptor.to("PostMysteryEncounterPhase"); const friendshipAfter = scene.currentBattle.mysteryEncounter!.misc.pokemon3.friendship; 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 ff2642a98fc..441becca763 100644 --- a/test/mystery-encounter/encounters/the-winstrate-challenge-encounter.test.ts +++ b/test/mystery-encounter/encounters/the-winstrate-challenge-encounter.test.ts @@ -365,9 +365,8 @@ 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.phaseInterceptor.shiftPhase(); if (isFinalBattle) { await game.phaseInterceptor.to("MysteryEncounterRewardsPhase"); } else { diff --git a/test/testUtils/gameManager.ts b/test/testUtils/gameManager.ts index 7c38533178f..73d06219902 100644 --- a/test/testUtils/gameManager.ts +++ b/test/testUtils/gameManager.ts @@ -36,7 +36,6 @@ import type { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { PlayerGender } from "#enums/player-gender"; import type { SpeciesId } from "#enums/species-id"; import { UiMode } from "#enums/ui-mode"; -import ErrorInterceptor from "#test/testUtils/errorInterceptor"; import { generateStarter, waitUntil } from "#test/testUtils/gameManagerUtils"; import GameWrapper from "#test/testUtils/gameWrapper"; import { ChallengeModeHelper } from "#test/testUtils/helpers/challengeModeHelper"; @@ -83,7 +82,6 @@ export default class GameManager { */ constructor(phaserGame: Phaser.Game, bypassLogin = true) { localStorage.clear(); - ErrorInterceptor.getInstance().clear(); BattleScene.prototype.randBattleSeedInt = (range, min = 0) => min + range - 1; // This simulates a max roll this.gameWrapper = new GameWrapper(phaserGame, bypassLogin); @@ -268,7 +266,7 @@ export default class GameManager { true, ); - await this.phaseInterceptor.run(EncounterPhase); + await this.phaseInterceptor.to("EncounterPhase"); if (!isNullOrUndefined(encounterType)) { expect(this.scene.currentBattle?.mysteryEncounter?.encounterType).toBe(encounterType); } @@ -500,7 +498,7 @@ export default class GameManager { * @param inPhase - Which phase to expect the selection to occur in. Defaults to `SwitchPhase` * (which is where the majority of non-command switch operations occur). */ - doSelectPartyPokemon(slot: number, inPhase = "SwitchPhase") { + doSelectPartyPokemon(slot: number, inPhase: PhaseString = "SwitchPhase") { this.onNextPrompt(inPhase, UiMode.PARTY, () => { const partyHandler = this.scene.ui.getHandler() as PartyUiHandler; diff --git a/test/testUtils/helpers/challengeModeHelper.ts b/test/testUtils/helpers/challengeModeHelper.ts index 60ce75ed814..b38f36d543c 100644 --- a/test/testUtils/helpers/challengeModeHelper.ts +++ b/test/testUtils/helpers/challengeModeHelper.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/testUtils/phaseInterceptor.ts b/test/testUtils/phaseInterceptor.ts index b14b943db8e..6602dc969a6 100644 --- a/test/testUtils/phaseInterceptor.ts +++ b/test/testUtils/phaseInterceptor.ts @@ -64,7 +64,9 @@ export default class PhaseInterceptor { // Mock the private startCurrentPhase method to do nothing to let us // handle starting phases manually in the `run` method. - vi.fn(this.scene.phaseManager["startCurrentPhase"]).mockImplementation(() => {}); + vi.fn(this.scene.phaseManager["startCurrentPhase"]).mockImplementation(() => { + console.log("Did nothing!!!!"); + }); } /** diff --git a/test/ui/pokedex.test.ts b/test/ui/pokedex.test.ts index 13f595e0c60..1e80d0db094 100644 --- a/test/ui/pokedex.test.ts +++ b/test/ui/pokedex.test.ts @@ -71,7 +71,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(); @@ -91,7 +91,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 d008a6d87dc..3c7e20c1369 100644 --- a/test/ui/starter-select.test.ts +++ b/test/ui/starter-select.test.ts @@ -2,7 +2,6 @@ import { Gender } from "#app/data/gender"; import { Nature } from "#enums/nature"; import { allSpecies } from "#app/data/data-lists"; import { GameModes } from "#enums/game-modes"; -import { EncounterPhase } from "#app/phases/encounter-phase"; import type { TitlePhase } from "#app/phases/title-phase"; import type { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler"; import type SaveSlotSelectUiHandler from "#app/ui/save-slot-select-ui-handler"; @@ -86,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); @@ -209,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); @@ -271,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); @@ -331,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); @@ -392,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); @@ -452,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); @@ -518,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); }); @@ -583,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 572d56c5903..9664287be21 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 25ea0ac5460..0c8cc4cb836 100644 --- a/test/ui/type-hints.test.ts +++ b/test/ui/type-hints.test.ts @@ -45,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, () => { @@ -70,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, () => { @@ -106,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, () => { From 1bcad94568b2b1f5ccb293069df00e48d6d9ce03 Mon Sep 17 00:00:00 2001 From: Bertie690 Date: Thu, 19 Jun 2025 13:14:41 -0400 Subject: [PATCH 5/9] Made interceptor use a while loop instead of timeouts --- src/phase-manager.ts | 7 ++ test/misc.test.ts | 11 +- test/testUtils/gameManager.ts | 12 +- test/testUtils/gameManagerUtils.ts | 12 +- test/testUtils/phaseInterceptor.ts | 170 +++++++++++++---------------- 5 files changed, 108 insertions(+), 104 deletions(-) diff --git a/src/phase-manager.ts b/src/phase-manager.ts index c59bd42eea6..e6e0b247405 100644 --- a/src/phase-manager.ts +++ b/src/phase-manager.ts @@ -391,6 +391,13 @@ export class PhaseManager { this.startCurrentPhase(); } + /** + * Helper method to start and log the current phase. + * + * @remarks + * This is disabled during tests by `phase-interceptor.ts` to allow for pausing execution at specific phases. + * As such, **do not remove or split this method** as it will break integration tests. + */ private startCurrentPhase(): void { if (!this.currentPhase) { return; diff --git a/test/misc.test.ts b/test/misc.test.ts index 12ed165d9d9..05aa7a3d070 100644 --- a/test/misc.test.ts +++ b/test/misc.test.ts @@ -64,16 +64,13 @@ describe("Test misc", () => { expect(data).toBeDefined(); }); - it("testing wait phase queue", async () => { - const fakeScene = { - phaseQueue: [1, 2, 3], // Initially not empty - }; + it("testing waitUntil", async () => { + let a = 1; setTimeout(() => { - fakeScene.phaseQueue = []; + a = 0; }, 500); const spy = vi.fn(); - await waitUntil(() => fakeScene.phaseQueue.length === 0).then(result => { - expect(result).toBe(true); + await waitUntil(() => a === 0).then(() => { spy(); // Call the spy function }); expect(spy).toHaveBeenCalled(); diff --git a/test/testUtils/gameManager.ts b/test/testUtils/gameManager.ts index 73d06219902..d308668e13b 100644 --- a/test/testUtils/gameManager.ts +++ b/test/testUtils/gameManager.ts @@ -54,7 +54,7 @@ import TextInterceptor from "#test/testUtils/TextInterceptor"; import { AES, enc } from "crypto-js"; import fs from "node:fs"; import { expect, vi } from "vitest"; -import type { PhaseString } from "#app/@types/phase-types"; +import type { PhaseClass, PhaseString } from "#app/@types/phase-types"; /** * Class to manage the game state and transitions between phases. @@ -405,7 +405,15 @@ export default class GameManager { * @param phaseTarget - The target phase. * @returns Whether the current phase matches the target phase */ - isCurrentPhase(phaseTarget) { + isCurrentPhase(phaseTarget: PhaseString | PhaseClass); + /** + * Checks if the current phase matches the target phase. + * @param phaseTarget - The target phase. + * @returns Whether the current phase matches the target phase + * @deprecated - use PhaseString + */ + isCurrentPhase(phaseTarget: PhaseClass); + isCurrentPhase(phaseTarget: PhaseString | PhaseClass) { const targetName = typeof phaseTarget === "string" ? phaseTarget : phaseTarget.name; return this.scene.phaseManager.getCurrentPhase()?.constructor.name === targetName; } diff --git a/test/testUtils/gameManagerUtils.ts b/test/testUtils/gameManagerUtils.ts index 57fd9b91d26..e652963e774 100644 --- a/test/testUtils/gameManagerUtils.ts +++ b/test/testUtils/gameManagerUtils.ts @@ -87,14 +87,20 @@ function getTestRunStarters(seed: string, species?: SpeciesId[]): Starter[] { return starters; } -export function waitUntil(truth): Promise { +/** + * Wait until a given function returns a truthy value. + * @param truth - A function to check against, called once per `timeout` interval. + * @param timeout - The time in milliseconds to wait before giving up; default `1000`. + * @returns A Promise that resolve once `truth` returns a truthy value. + */ +export function waitUntil(truth: () => boolean, timeout = 1000): Promise { return new Promise(resolve => { const interval = setInterval(() => { if (truth()) { clearInterval(interval); - resolve(true); + resolve(); } - }, 1000); + }, timeout); }); } diff --git a/test/testUtils/phaseInterceptor.ts b/test/testUtils/phaseInterceptor.ts index 6602dc969a6..c196a74451a 100644 --- a/test/testUtils/phaseInterceptor.ts +++ b/test/testUtils/phaseInterceptor.ts @@ -4,25 +4,16 @@ import { UiMode } from "#enums/ui-mode"; import UI from "#app/ui/ui"; import type { PhaseString } from "#app/@types/phase-types"; import { vi } from "vitest"; +import { format } from "util"; interface PromptHandler { - phaseTarget?: PhaseString; - mode?: UiMode; - callback?: () => void; + phaseTarget: PhaseString; + mode: UiMode; + callback: () => void; expireFn?: () => boolean; - awaitingActionInput?: boolean; + awaitingActionInput: boolean; } -/** Array of phases which end via player input. */ -const endBySetMode: Set = new Set([ - "TitlePhase", - "SelectGenderPhase", - "CommandPhase", - "SelectModifierPhase", - "MysteryEncounterPhase", - "PostMysteryEncounterPhase", -]); - /** * The PhaseInterceptor is a wrapper around the `BattleScene`'s {@linkcode PhaseManager}. * It allows tests to exert finer control over the phase system, providing logging, @@ -31,9 +22,6 @@ export default class PhaseInterceptor { private scene: BattleScene; /** A log of phases having been executed. */ public log: PhaseString[] = []; - private promptInterval: NodeJS.Timeout; - private intervalRun: NodeJS.Timeout; - // TODO: Move prompts to a separate class private prompts: PromptHandler[] = []; /** @@ -43,7 +31,6 @@ export default class PhaseInterceptor { constructor(scene: BattleScene) { this.scene = scene; this.initMocks(); - this.startPromptHandler(); } /** @@ -63,39 +50,10 @@ export default class PhaseInterceptor { ); // Mock the private startCurrentPhase method to do nothing to let us - // handle starting phases manually in the `run` method. - vi.fn(this.scene.phaseManager["startCurrentPhase"]).mockImplementation(() => { - console.log("Did nothing!!!!"); - }); - } - - /** - * Method to start the prompt handler. - */ - private startPromptHandler() { - this.promptInterval = setInterval(() => { - const actionForNextPrompt = this.prompts[0] as PromptHandler | undefined; - if (!actionForNextPrompt) { - return; - } - const expireFn = actionForNextPrompt.expireFn?.(); - const currentMode = this.scene.ui.getMode(); - const currentPhase = this.scene.phaseManager.getCurrentPhase()?.phaseName; - const currentHandler = this.scene.ui.getHandler(); - if (expireFn) { - this.prompts.shift(); - } else if ( - currentMode === actionForNextPrompt.mode && - currentPhase === actionForNextPrompt.phaseTarget && - currentHandler.active && - (!actionForNextPrompt.awaitingActionInput || currentHandler["awaitingActionInput"]) - ) { - const prompt = this.prompts.shift(); - if (prompt?.callback) { - prompt.callback(); - } - } - }); + // start them manually ourselves. + this.scene.phaseManager["startCurrentPhase"] satisfies () => void; // typecheck in case function is renamed/removed + // @ts-expect-error - startCurrentPhase is private + vi.spyOn(this.scene.phaseManager, "startCurrentPhase").mockImplementation(() => {}); } /** @@ -115,82 +73,110 @@ export default class PhaseInterceptor { * @returns A promise that resolves when the transition is complete. */ public async to(targetPhase: PhaseString, runTarget = true): Promise { - this.intervalRun = setInterval(async () => { - const currentPhase = this.scene.phaseManager.getCurrentPhase(); + let currentPhase = this.scene.phaseManager.getCurrentPhase(); + while (!currentPhase?.is(targetPhase)) { + currentPhase = this.scene.phaseManager.getCurrentPhase(); if (!currentPhase) { - console.log("No phases left to run; resolving."); + console.log("Reached end of phases without hitting target; resolving."); return; } - if (!currentPhase.is(targetPhase)) { - // Current phase is different; run and wait for it to finish - await this.run(currentPhase); - return; - } - - // target phase reached; run as applicable and resolve - clearInterval(this.intervalRun); - if (!runTarget) { - console.log(`PhaseInterceptor.to: Stopping on run of ${targetPhase}`); - this.scene.phaseManager.unshiftPhase(currentPhase); - return; - } + // Current phase is different; run and wait for it to finish await this.run(currentPhase); + } + + // We hit the target; run as applicable and wrap up. + if (!runTarget) { + console.log(`PhaseInterceptor.to: Stopping on run of ${targetPhase}`); return; - }); + } + + console.log(`PhaseInterceptor.to: Running target ${targetPhase}`); + await this.run(currentPhase); } /** - * Method to run a phase with an optional skip function. - * @param phaseTarget - The {@linkcode Phase} to run. + * Wrapper method to run a phase and start the next phase. + * @param currentPhase - The {@linkcode Phase} to run. * @returns A Promise that resolves when the phase is run. */ - private async run(phaseTarget: Phase): Promise { - const currentPhase = this.scene.phaseManager.getCurrentPhase(); - if (!currentPhase?.is(phaseTarget.phaseName)) { - throw new Error( - `Wrong phase passed to PhaseInterceptor.run;\nthis is ${currentPhase?.phaseName} and not ${phaseTarget.phaseName}`, - ); - } - + private async run(currentPhase: Phase): Promise { try { this.logPhase(currentPhase.phaseName); currentPhase.start(); } catch (error: unknown) { throw error instanceof Error ? error - : new Error(`Unknown error ${error} occurred while running phase ${currentPhase?.phaseName}!`); + : new Error( + `Unknown error occurred while running phase ${currentPhase.phaseName}!\nError: ${format("%O", error)}`, + ); } } - /** Alias for {@linkcode PhaseManager.shiftPhase()} */ + /** Alias for {@linkcode PhaseManager.shiftPhase()}. */ shiftPhase() { + console.log(`Skipping current phase ${this.scene.phaseManager.getCurrentPhase()?.phaseName}`); return this.scene.phaseManager.shiftPhase(); } /** - * Method to set mode. + * Method to override UI mode setting with custom prompt support. * @param originalSetMode - The original setMode method from the UI. * @param mode - The {@linkcode UiMode} to set. * @param args - Additional arguments to pass to the original method. */ - private async setMode(originalSetMode: typeof UI.prototype.setMode, mode: UiMode, ...args: unknown[]): Promise { - const currentPhase = this.scene.phaseManager.getCurrentPhase(); + private async setMode( + originalSetMode: typeof UI.prototype.setMode, + mode: UiMode, + ...args: unknown[] + ): ReturnType { console.log("setMode", `${UiMode[mode]} (=${mode})`, args); const ret = originalSetMode.apply(this.scene.ui, [mode, ...args]); - if (currentPhase && endBySetMode.has(currentPhase.phaseName)) { - await this.run(currentPhase); - } + this.doPromptCheck(mode); return ret; } /** - * Method to add an action to the next prompt. - * @param phaseTarget - The target phase for the prompt. - * @param mode - The mode of the UI. + * Method to start the prompt handler. + */ + private doPromptCheck(uiMode: UiMode) { + const actionForNextPrompt = this.prompts[0] as PromptHandler | undefined; + if (!actionForNextPrompt) { + return; + } + + // Check for prompt expiry, removing prompt if applicable. + if (actionForNextPrompt.expireFn?.()) { + this.prompts.shift(); + return; + } + + // Check if the current mode, phase, and handler match the expected values. + // If not, we just skip and wait. + // TODO: Should this check all prompts or only the first one? + const currentPhase = this.scene.phaseManager.getCurrentPhase()?.phaseName; + const currentHandler = this.scene.ui.getHandler(); + if ( + uiMode === actionForNextPrompt.mode || + currentPhase !== actionForNextPrompt.phaseTarget || + !currentHandler.active || + (actionForNextPrompt.awaitingActionInput && !currentHandler["awaitingActionInput"]) + ) { + return; + } + + // Prompt matches; perform callback as applicable and return + this.prompts.shift(); + actionForNextPrompt.callback(); + } + + /** + * Method to add a callback to the next prompt. + * @param phaseTarget - The {@linkcode PhaseString | name} of the Phase to execute the callback during. + * @param mode - The {@linkcode UIMode} to wait for. * @param callback - The callback function to execute. * @param expireFn - The function to determine if the prompt has expired. - * @param awaitingActionInput + * @param awaitingActionInput - If `true`, will only activate when the current UI handler is waiting for input; default `false` */ addToNextPrompt( phaseTarget: PhaseString, @@ -212,7 +198,7 @@ export default class PhaseInterceptor { * Restores the original state of phases and clears intervals. */ restoreOg() { - clearInterval(this.promptInterval); - clearInterval(this.intervalRun); + // clearInterval(this.promptInterval); + // clearInterval(this.intervalRun); } } From 3ed587de6d68db7e3e78085c63e5f23f20391748 Mon Sep 17 00:00:00 2001 From: Bertie690 Date: Thu, 19 Jun 2025 15:37:01 -0400 Subject: [PATCH 6/9] Added unit tests for phase interceptor --- src/phase-manager.ts | 1 + test/testUtils/phaseInterceptor.ts | 32 ++--- test/utils/phase-interceptor-prompts.test.ts | 106 ++++++++++++++++ test/utils/phase-interceptor.test.ts | 126 +++++++++++++++++++ 4 files changed, 251 insertions(+), 14 deletions(-) create mode 100644 test/utils/phase-interceptor-prompts.test.ts create mode 100644 test/utils/phase-interceptor.test.ts diff --git a/src/phase-manager.ts b/src/phase-manager.ts index e6e0b247405..3f465f7b5fb 100644 --- a/src/phase-manager.ts +++ b/src/phase-manager.ts @@ -400,6 +400,7 @@ export class PhaseManager { */ private startCurrentPhase(): void { if (!this.currentPhase) { + console.warn("trying to start null phase!"); return; } console.log(`%cStart Phase ${this.currentPhase.phaseName}`, "color:green;"); diff --git a/test/testUtils/phaseInterceptor.ts b/test/testUtils/phaseInterceptor.ts index c196a74451a..03914c39d42 100644 --- a/test/testUtils/phaseInterceptor.ts +++ b/test/testUtils/phaseInterceptor.ts @@ -3,7 +3,7 @@ import type { Phase } from "#app/phase"; import { UiMode } from "#enums/ui-mode"; import UI from "#app/ui/ui"; import type { PhaseString } from "#app/@types/phase-types"; -import { vi } from "vitest"; +import { vi, type MockInstance } from "vitest"; import { format } from "util"; interface PromptHandler { @@ -16,7 +16,7 @@ interface PromptHandler { /** * The PhaseInterceptor is a wrapper around the `BattleScene`'s {@linkcode PhaseManager}. - * It allows tests to exert finer control over the phase system, providing logging, + * It allows tests to exert finer control over the phase system, providing logging, manual advancing, etc etc. */ export default class PhaseInterceptor { private scene: BattleScene; @@ -44,16 +44,18 @@ export default class PhaseInterceptor { * Method to initialize various mocks for intercepting phases. */ initMocks() { - const originalSetMode = UI.prototype.setMode; - vi.spyOn(UI.prototype, "setMode").mockImplementation((mode, ...args) => - this.setMode(originalSetMode, mode, ...args), - ); + const originalSetMode = UI.prototype["setModeInternal"]; + // `any` assertion needed as we are mocking private property + const uiSpy = vi.spyOn(UI.prototype as any, "setModeInternal") as MockInstance< + (typeof UI.prototype)["setModeInternal"] + >; + uiSpy.mockImplementation(async (...args) => { + this.setMode(originalSetMode, args); + }); // Mock the private startCurrentPhase method to do nothing to let us // start them manually ourselves. - this.scene.phaseManager["startCurrentPhase"] satisfies () => void; // typecheck in case function is renamed/removed - // @ts-expect-error - startCurrentPhase is private - vi.spyOn(this.scene.phaseManager, "startCurrentPhase").mockImplementation(() => {}); + vi.spyOn(this.scene.phaseManager as any, "startCurrentPhase").mockImplementation(() => {}); } /** @@ -72,6 +74,7 @@ export default class PhaseInterceptor { * @param runTarget - Whether or not to run the target phase; default `true`. * @returns A promise that resolves when the transition is complete. */ + // TODO: Does this need to be asynchronous? public async to(targetPhase: PhaseString, runTarget = true): Promise { let currentPhase = this.scene.phaseManager.getCurrentPhase(); while (!currentPhase?.is(targetPhase)) { @@ -126,12 +129,13 @@ export default class PhaseInterceptor { * @param args - Additional arguments to pass to the original method. */ private async setMode( - originalSetMode: typeof UI.prototype.setMode, - mode: UiMode, - ...args: unknown[] - ): ReturnType { + originalSetMode: (typeof UI.prototype)["setModeInternal"], + args: Parameters<(typeof UI.prototype)["setModeInternal"]>, + ): ReturnType<(typeof UI.prototype)["setModeInternal"]> { + const mode = args[0]; + console.log("setMode", `${UiMode[mode]} (=${mode})`, args); - const ret = originalSetMode.apply(this.scene.ui, [mode, ...args]); + const ret = originalSetMode.apply(this.scene.ui, [args]); this.doPromptCheck(mode); return ret; } diff --git a/test/utils/phase-interceptor-prompts.test.ts b/test/utils/phase-interceptor-prompts.test.ts new file mode 100644 index 00000000000..b6397eb5200 --- /dev/null +++ b/test/utils/phase-interceptor-prompts.test.ts @@ -0,0 +1,106 @@ +import type { PhaseString } from "#app/@types/phase-types"; +import { globalScene } from "#app/global-scene"; +import { Phase } from "#app/phase"; +import type { Constructor } from "#app/utils/common"; +import { UiMode } from "#enums/ui-mode"; +import GameManager from "#test/testUtils/gameManager"; +import Phaser from "phaser"; +import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; + +abstract class mockPhase extends Phase { + public override readonly phaseName: any; + + override start() { + this.end(); + } +} + +class testDialogueUiPhase extends mockPhase { + public readonly phaseName = "testDialogueUiPhase"; + override start() { + void globalScene.ui.setMode(UiMode.TEST_DIALOGUE); + super.start(); + } +} + +class titleUiPhase extends mockPhase { + public readonly phaseName = "titleUiPhase"; + override start() { + void globalScene.ui.setMode(UiMode.TITLE); + super.start(); + } +} + +class dualUiPhase extends mockPhase { + public readonly phaseName = "dualUiPhase"; + override start() { + void globalScene.ui.setMode(UiMode.TEST_DIALOGUE); + void globalScene.ui.setMode(UiMode.TITLE); + super.start(); + } +} + +describe("Utils - Phase Interceptor Prompts", () => { + let phaserGame: Phaser.Game; + let game: GameManager; + + beforeAll(() => { + phaserGame = new Phaser.Game({ + type: Phaser.HEADLESS, + }); + }); + + beforeEach(() => { + game = new GameManager(phaserGame); + setPhases(testDialogueUiPhase, titleUiPhase, dualUiPhase); + }); + + function setPhases(...phases: Constructor[]) { + game.scene.phaseManager.clearAllPhases(); + game.scene.phaseManager.phaseQueue = phases.map(m => new m()); + game.scene.phaseManager.shiftPhase(); // start the thing going + } + + /** Wrapper function to make TS not complain about `PhaseString` stuff */ + function to(phaseName: string, runTarget = false) { + return game.phaseInterceptor.to(phaseName as unknown as PhaseString, runTarget); + } + + function onNextPrompt(target: string, mode: UiMode, callback: () => void, expireFn?: () => boolean) { + game.onNextPrompt(target as unknown as PhaseString, mode, callback, expireFn); + } + + it("should run the specified callback when the given ui mode is reached", async () => { + const callback = vi.fn(); + onNextPrompt("testDialogueUiPhase", UiMode.TEST_DIALOGUE, () => callback()); + + await to("testDialogueUiPhase"); + expect(callback).toHaveBeenCalled(); + }); + + it("should not run callback if wrong ui mode", async () => { + const callback = vi.fn(); + onNextPrompt("testDialogueUiPhase", UiMode.TITLE, () => callback()); + + await to("testDialogueUiPhase"); + expect(callback).not.toHaveBeenCalled(); + }); + + it("should not run callback if wrong phase", async () => { + const callback = vi.fn(); + onNextPrompt("titleUiPhase", UiMode.TITLE, () => callback()); + + await to("testDialogueUiPhase"); + expect(callback).not.toHaveBeenCalled(); + }); + + it("should work in succession", async () => { + const callback1 = vi.fn(); + const callback2 = vi.fn(); + onNextPrompt("dualUiPhase", UiMode.TEST_DIALOGUE, () => callback1()); + onNextPrompt("dualUiPhase", UiMode.TITLE, () => callback2()); + + await to("dualUiPhase"); + expect(callback1).not.toHaveBeenCalled(); + }); +}); diff --git a/test/utils/phase-interceptor.test.ts b/test/utils/phase-interceptor.test.ts new file mode 100644 index 00000000000..6e1422fa94a --- /dev/null +++ b/test/utils/phase-interceptor.test.ts @@ -0,0 +1,126 @@ +import type { PhaseString } from "#app/@types/phase-types"; +import { Phase } from "#app/phase"; +import type { Constructor } from "#app/utils/common"; +import GameManager from "#test/testUtils/gameManager"; +import Phaser from "phaser"; +import { beforeAll, beforeEach, describe, expect, it } from "vitest"; + +let phaserGame: Phaser.Game; +let game: GameManager; + +abstract class mockPhase extends Phase { + public override readonly phaseName: any; + + override start() { + console.log(this.phaseName); + this.end(); + } +} + +class normalPhase extends mockPhase { + public readonly phaseName = "normalPhase"; +} + +class applePhase extends mockPhase { + public readonly phaseName = "applePhase"; +} + +class oneSecTimerPhase extends mockPhase { + public readonly phaseName = "oneSecTimerPhase"; + override start() { + setInterval(() => { + super.start(); + }, 1000); + } +} + +class unshifterPhase extends mockPhase { + public readonly phaseName = "unshifterPhase"; + override start() { + game.scene.phaseManager.unshiftPhase(new normalPhase() as unknown as Phase); + game.scene.phaseManager.unshiftPhase(new applePhase() as unknown as Phase); + super.start(); + } +} + +// reduce timeout so failed tests don't hang as long +describe("Utils - Phase Interceptor", { timeout: 4000 }, () => { + beforeAll(() => { + phaserGame = new Phaser.Game({ + type: Phaser.HEADLESS, + }); + }); + + beforeEach(() => { + game = new GameManager(phaserGame); + setPhases(normalPhase, applePhase, oneSecTimerPhase, unshifterPhase, normalPhase); + }); + + function setPhases(...phases: Constructor[]) { + game.scene.phaseManager.clearAllPhases(); + game.scene.phaseManager.phaseQueue = phases.map(m => new m()); + game.scene.phaseManager.shiftPhase(); // start the thing going + } + + function getQueuedPhases(): string[] { + return game.scene.phaseManager["phaseQueuePrepend"] + .concat(game.scene.phaseManager.phaseQueue) + .map(p => p.phaseName); + } + + function getCurrentPhaseName(): string { + return game.scene.phaseManager.getCurrentPhase()?.phaseName ?? "null"; + } + + /** Wrapper function to make TS not complain about `PhaseString` stuff */ + function to(phaseName: string, runTarget = true) { + return game.phaseInterceptor.to(phaseName as unknown as PhaseString, runTarget); + } + + describe("to", () => { + it("should run the specified phase and halt after it ends", async () => { + await to("normalPhase"); + expect(getCurrentPhaseName()).toBe("applePhase"); + expect(getQueuedPhases()).toEqual(["oneSecTimerPhase", "unshifterPhase", "normalPhase"]); + expect(game.phaseInterceptor.log).toEqual(["normalPhase"]); + }); + + it("should run to the specified phase without starting/logging", async () => { + await to("normalPhase", false); + expect(getCurrentPhaseName()).toBe("normalPhase"); + expect(getQueuedPhases()).toEqual(["applePhase", "oneSecTimerPhase", "unshifterPhase", "normalPhase"]); + expect(game.phaseInterceptor.log).toHaveLength(0); + }); + + it("should start all phases between start and target", async () => { + await to("oneSecTimerPhase"); + expect(getQueuedPhases()).toEqual(["unshifterPhase", "normalPhase"]); + expect(game.phaseInterceptor.log).toEqual(["normalPhase", "applePhase", "oneSecTimerPhase"]); + }); + + it("should work on newly unshifted phases", async () => { + setPhases(unshifterPhase); // adds normalPhase and applePhase to queue + await to("applePhase"); + expect(game.phaseInterceptor.log).toEqual(["unshifterPhase", "normalPhase", "applePhase"]); + }); + + it("should wait until phase finishes before starting next", async () => { + setPhases(oneSecTimerPhase, applePhase); + setTimeout(() => expect(getCurrentPhaseName()).toBe("oneSecTimerPhase"), 500); + await to("applePhase"); + }); + }); + + describe("shift", () => { + it("should skip the next phase without starting", async () => { + expect(getCurrentPhaseName()).toBe("normalPhase"); + expect(getQueuedPhases()).toEqual(["applePhase", "oneSecTimerPhase", "unshifterPhase", "normalPhase"]); + + game.phaseInterceptor.shiftPhase(); + + expect(getCurrentPhaseName()).toBe("applePhase"); + expect(getQueuedPhases()).toEqual(["oneSecTimerPhase", "unshifterPhase", "normalPhase"]); + expect(game.phaseInterceptor.log).toEqual([]); + }); + }); +}); From 59152d0c6c071f0a19c466d009f2b9f5bb7535f1 Mon Sep 17 00:00:00 2001 From: Bertie690 Date: Thu, 19 Jun 2025 16:09:42 -0400 Subject: [PATCH 7/9] Fixed bugs (hopefully) --- test/testUtils/phaseInterceptor.ts | 9 ++++----- test/utils/phase-interceptor.test.ts | 1 - 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/test/testUtils/phaseInterceptor.ts b/test/testUtils/phaseInterceptor.ts index 03914c39d42..7b676ca2198 100644 --- a/test/testUtils/phaseInterceptor.ts +++ b/test/testUtils/phaseInterceptor.ts @@ -72,13 +72,12 @@ export default class PhaseInterceptor { * Method to transition to a target phase. * @param targetPhase - The name of the phase to transition to. * @param runTarget - Whether or not to run the target phase; default `true`. - * @returns A promise that resolves when the transition is complete. + * @returns A Promise that resolves when the target phase is reached. */ - // TODO: Does this need to be asynchronous? public async to(targetPhase: PhaseString, runTarget = true): Promise { - let currentPhase = this.scene.phaseManager.getCurrentPhase(); + const pm = this.scene.phaseManager; + let currentPhase = pm.getCurrentPhase(); while (!currentPhase?.is(targetPhase)) { - currentPhase = this.scene.phaseManager.getCurrentPhase(); if (!currentPhase) { console.log("Reached end of phases without hitting target; resolving."); return; @@ -86,6 +85,7 @@ export default class PhaseInterceptor { // Current phase is different; run and wait for it to finish await this.run(currentPhase); + currentPhase = pm.getCurrentPhase(); } // We hit the target; run as applicable and wrap up. @@ -94,7 +94,6 @@ export default class PhaseInterceptor { return; } - console.log(`PhaseInterceptor.to: Running target ${targetPhase}`); await this.run(currentPhase); } diff --git a/test/utils/phase-interceptor.test.ts b/test/utils/phase-interceptor.test.ts index 6e1422fa94a..052dda128cf 100644 --- a/test/utils/phase-interceptor.test.ts +++ b/test/utils/phase-interceptor.test.ts @@ -12,7 +12,6 @@ abstract class mockPhase extends Phase { public override readonly phaseName: any; override start() { - console.log(this.phaseName); this.end(); } } From c310df3a66a97edf21fbef0042409004e080d8e2 Mon Sep 17 00:00:00 2001 From: Bertie690 <136088738+Bertie690@users.noreply.github.com> Date: Thu, 19 Jun 2025 21:40:29 -0400 Subject: [PATCH 8/9] Comment fix --- src/phase-manager.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/phase-manager.ts b/src/phase-manager.ts index 3f465f7b5fb..d2caf27b66d 100644 --- a/src/phase-manager.ts +++ b/src/phase-manager.ts @@ -253,7 +253,9 @@ export class PhaseManager { constructor() { this.dynamicPhaseQueues = [new PostSummonPhasePriorityQueue()]; this.dynamicPhaseTypes = [PostSummonPhase]; - } /* Phase Functions */ + } + + /* Phase Functions */ /** * Getter function to return the currently-in-progess {@linkcode Phase}. From fa0da8438a796ad6ad0cb4e1e88ee03f7c9138d7 Mon Sep 17 00:00:00 2001 From: Bertie690 Date: Thu, 19 Jun 2025 23:27:33 -0400 Subject: [PATCH 9/9] Fixed bug with not resetting `phaseQueuePrepend`; added docs to phaseManager funcs --- scripts/create-test/test-boilerplate.ts | 6 +-- src/phase-manager.ts | 51 +++++++++++-------------- test/testUtils/phaseInterceptor.ts | 8 +--- test/utils/phase-interceptor.test.ts | 34 ++++++++--------- 4 files changed, 42 insertions(+), 57 deletions(-) diff --git a/scripts/create-test/test-boilerplate.ts b/scripts/create-test/test-boilerplate.ts index 1fbd3c8040a..e125c475518 100644 --- a/scripts/create-test/test-boilerplate.ts +++ b/scripts/create-test/test-boilerplate.ts @@ -3,7 +3,7 @@ import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; -import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; +import { beforeAll, beforeEach, describe, expect, it } from "vitest"; describe("{{description}}", () => { let phaserGame: Phaser.Game; @@ -15,10 +15,6 @@ describe("{{description}}", () => { }); }); - afterEach(() => { - game.phaseInterceptor.restoreOg(); - }); - beforeEach(() => { game = new GameManager(phaserGame); game.override diff --git a/src/phase-manager.ts b/src/phase-manager.ts index d2caf27b66d..5e4aaabb171 100644 --- a/src/phase-manager.ts +++ b/src/phase-manager.ts @@ -253,7 +253,7 @@ export class PhaseManager { constructor() { this.dynamicPhaseQueues = [new PostSummonPhasePriorityQueue()]; this.dynamicPhaseTypes = [PostSummonPhase]; - } + } /* Phase Functions */ @@ -360,10 +360,9 @@ export class PhaseManager { return; } - if (this.phaseQueuePrependSpliceIndex > -1) { - this.clearPhaseQueueSplice(); - } + this.clearPhaseQueueSplice(); this.phaseQueue.unshift(...this.phaseQueuePrepend); + this.phaseQueuePrepend = []; if (!this.phaseQueue.length) { this.populatePhaseQueue(); @@ -374,22 +373,17 @@ export class PhaseManager { this.currentPhase = this.phaseQueue.shift() ?? null; const unactivatedConditionalPhases: [() => boolean, Phase][] = []; - // Check if there are any conditional phases queued - while (this.conditionalQueue?.length) { - // Retrieve the first conditional phase from the queue - const conditionalPhase = this.conditionalQueue.shift(); - // Evaluate the condition associated with the phase - if (conditionalPhase?.[0]()) { - // If the condition is met, add the phase to the phase queue - this.pushPhase(conditionalPhase[1]); - } else if (conditionalPhase) { - // If the condition is not met, re-add the phase back to the front of the conditional queue - unactivatedConditionalPhases.push(conditionalPhase); + // Check each queued conditional phase, either adding it to the end of the queue (if met) + // or keeping it on (if not). + for (const [condition, phase] of this.conditionalQueue) { + if (condition()) { + this.pushPhase(phase); } else { - console.warn("condition phase is undefined/null!", conditionalPhase); + unactivatedConditionalPhases.push([condition, phase]); } } - this.conditionalQueue.push(...unactivatedConditionalPhases); + this.conditionalQueue = unactivatedConditionalPhases; + this.startCurrentPhase(); } @@ -409,6 +403,7 @@ export class PhaseManager { this.currentPhase.start(); } + // TODO: Review if we can remove this overridePhase(phase: Phase): boolean { if (this.standbyPhase) { return false; @@ -483,9 +478,9 @@ export class PhaseManager { /** * Tries to add the input phase(s) to index after target phase in the {@linkcode phaseQueue}, else simply calls {@linkcode unshiftPhase()} - * @param phase {@linkcode Phase} the phase(s) to be added - * @param targetPhase {@linkcode Phase} the type of phase to search for in {@linkcode phaseQueue} - * @param condition Condition the target phase must meet to be appended to + * @param phase - One or more {@linkcode Phase}s to be added + * @param targetPhase - The type of target {@linkcode Phase} phase to search for in {@linkcode phaseQueue} + * @param condition - If provided, will only consider target phases passing the condition. * @returns `true` if a `targetPhase` was found to append to */ appendToPhase(phase: Phase | Phase[], targetPhase: PhaseString, condition?: (p: Phase) => boolean): boolean { @@ -503,7 +498,7 @@ export class PhaseManager { /** * Checks a phase and returns the matching {@linkcode DynamicPhaseType}, or undefined if it does not match one - * @param phase The phase to check + * @param phase - The {@linkcode Phase} to check * @returns The corresponding {@linkcode DynamicPhaseType} or `undefined` */ public getDynamicPhaseType(phase: Phase | null): DynamicPhaseType | undefined { @@ -521,7 +516,7 @@ export class PhaseManager { * Pushes a phase onto its corresponding dynamic queue and marks the activation point in {@linkcode phaseQueue} * * The {@linkcode ActivatePriorityQueuePhase} will run the top phase in the dynamic queue (not necessarily {@linkcode phase}) - * @param phase The phase to push + * @param phase The {@linkcode Phase} to push */ public pushDynamicPhase(phase: Phase): void { const type = this.getDynamicPhaseType(phase); @@ -535,7 +530,7 @@ export class PhaseManager { /** * Unshifts the top phase from the corresponding dynamic queue onto {@linkcode phaseQueue} - * @param type {@linkcode DynamicPhaseType} The type of dynamic phase to start + * @param type - The {@linkcode DynamicPhaseType} corresponding to the dynamic phase being started. */ public startDynamicPhaseType(type: DynamicPhaseType): void { const phase = this.dynamicPhaseQueues[type].pop(); @@ -550,8 +545,7 @@ export class PhaseManager { * This is the same as {@linkcode pushDynamicPhase}, except the activation phase is unshifted * * {@linkcode phase} is not guaranteed to be the next phase from the queue to run (if the queue is not empty) - * @param phase The phase to add - * @returns + * @param phase - The {@linkcode Phase} to add */ public startDynamicPhase(phase: Phase): void { const type = this.getDynamicPhaseType(phase); @@ -573,7 +567,7 @@ export class PhaseManager { * * @see {@linkcode MessagePhase} for more details on the parameters */ - queueMessage( + public queueMessage( message: string, callbackDelay?: number | null, prompt?: boolean | null, @@ -598,7 +592,7 @@ export class PhaseManager { */ public queueAbilityDisplay(pokemon: Pokemon, passive: boolean, show: boolean): void { this.unshiftPhase(show ? new ShowAbilityPhase(pokemon.getBattlerIndex(), passive) : new HideAbilityPhase()); - this.clearPhaseQueueSplice(); + this.clearPhaseQueueSplice(); // TODO: Is this necessary? } /** @@ -611,7 +605,8 @@ export class PhaseManager { } /** - * Moves everything from nextCommandPhaseQueue to phaseQueue (keeping order) + * Moves everything from nextCommandPhaseQueue to phaseQueue (keeping order), + * then adds a new {@linkcode TurnInitPhase} to start a new turn. */ private populatePhaseQueue(): void { if (this.nextCommandPhaseQueue.length) { diff --git a/test/testUtils/phaseInterceptor.ts b/test/testUtils/phaseInterceptor.ts index 7b676ca2198..c2878750852 100644 --- a/test/testUtils/phaseInterceptor.ts +++ b/test/testUtils/phaseInterceptor.ts @@ -197,11 +197,5 @@ export default class PhaseInterceptor { }); } - /** - * Restores the original state of phases and clears intervals. - */ - restoreOg() { - // clearInterval(this.promptInterval); - // clearInterval(this.intervalRun); - } + restoreOg() {} } diff --git a/test/utils/phase-interceptor.test.ts b/test/utils/phase-interceptor.test.ts index 052dda128cf..9442c64acc9 100644 --- a/test/utils/phase-interceptor.test.ts +++ b/test/utils/phase-interceptor.test.ts @@ -16,8 +16,8 @@ abstract class mockPhase extends Phase { } } -class normalPhase extends mockPhase { - public readonly phaseName = "normalPhase"; +class bananaPhase extends mockPhase { + public readonly phaseName = "bananaPhase"; } class applePhase extends mockPhase { @@ -36,7 +36,7 @@ class oneSecTimerPhase extends mockPhase { class unshifterPhase extends mockPhase { public readonly phaseName = "unshifterPhase"; override start() { - game.scene.phaseManager.unshiftPhase(new normalPhase() as unknown as Phase); + game.scene.phaseManager.unshiftPhase(new bananaPhase() as unknown as Phase); game.scene.phaseManager.unshiftPhase(new applePhase() as unknown as Phase); super.start(); } @@ -52,7 +52,7 @@ describe("Utils - Phase Interceptor", { timeout: 4000 }, () => { beforeEach(() => { game = new GameManager(phaserGame); - setPhases(normalPhase, applePhase, oneSecTimerPhase, unshifterPhase, normalPhase); + setPhases(bananaPhase, applePhase, oneSecTimerPhase, unshifterPhase, bananaPhase); }); function setPhases(...phases: Constructor[]) { @@ -78,29 +78,29 @@ describe("Utils - Phase Interceptor", { timeout: 4000 }, () => { describe("to", () => { it("should run the specified phase and halt after it ends", async () => { - await to("normalPhase"); + await to("bananaPhase"); expect(getCurrentPhaseName()).toBe("applePhase"); - expect(getQueuedPhases()).toEqual(["oneSecTimerPhase", "unshifterPhase", "normalPhase"]); - expect(game.phaseInterceptor.log).toEqual(["normalPhase"]); + expect(getQueuedPhases()).toEqual(["oneSecTimerPhase", "unshifterPhase", "bananaPhase"]); + expect(game.phaseInterceptor.log).toEqual(["bananaPhase"]); }); it("should run to the specified phase without starting/logging", async () => { - await to("normalPhase", false); - expect(getCurrentPhaseName()).toBe("normalPhase"); - expect(getQueuedPhases()).toEqual(["applePhase", "oneSecTimerPhase", "unshifterPhase", "normalPhase"]); + await to("bananaPhase", false); + expect(getCurrentPhaseName()).toBe("bananaPhase"); + expect(getQueuedPhases()).toEqual(["applePhase", "oneSecTimerPhase", "unshifterPhase", "bananaPhase"]); expect(game.phaseInterceptor.log).toHaveLength(0); }); it("should start all phases between start and target", async () => { await to("oneSecTimerPhase"); - expect(getQueuedPhases()).toEqual(["unshifterPhase", "normalPhase"]); - expect(game.phaseInterceptor.log).toEqual(["normalPhase", "applePhase", "oneSecTimerPhase"]); + expect(getQueuedPhases()).toEqual(["unshifterPhase", "bananaPhase"]); + expect(game.phaseInterceptor.log).toEqual(["bananaPhase", "applePhase", "oneSecTimerPhase"]); }); it("should work on newly unshifted phases", async () => { - setPhases(unshifterPhase); // adds normalPhase and applePhase to queue + setPhases(unshifterPhase); // adds bananaPhase and applePhase to queue await to("applePhase"); - expect(game.phaseInterceptor.log).toEqual(["unshifterPhase", "normalPhase", "applePhase"]); + expect(game.phaseInterceptor.log).toEqual(["unshifterPhase", "bananaPhase", "applePhase"]); }); it("should wait until phase finishes before starting next", async () => { @@ -112,13 +112,13 @@ describe("Utils - Phase Interceptor", { timeout: 4000 }, () => { describe("shift", () => { it("should skip the next phase without starting", async () => { - expect(getCurrentPhaseName()).toBe("normalPhase"); - expect(getQueuedPhases()).toEqual(["applePhase", "oneSecTimerPhase", "unshifterPhase", "normalPhase"]); + expect(getCurrentPhaseName()).toBe("bananaPhase"); + expect(getQueuedPhases()).toEqual(["applePhase", "oneSecTimerPhase", "unshifterPhase", "bananaPhase"]); game.phaseInterceptor.shiftPhase(); expect(getCurrentPhaseName()).toBe("applePhase"); - expect(getQueuedPhases()).toEqual(["oneSecTimerPhase", "unshifterPhase", "normalPhase"]); + expect(getQueuedPhases()).toEqual(["oneSecTimerPhase", "unshifterPhase", "bananaPhase"]); expect(game.phaseInterceptor.log).toEqual([]); }); });