diff --git a/test/test-utils/game-manager.ts b/test/test-utils/game-manager.ts index 47b41f173fb..f14b3aa2050 100644 --- a/test/test-utils/game-manager.ts +++ b/test/test-utils/game-manager.ts @@ -178,9 +178,10 @@ export class GameManager { async runToTitle(): Promise { // Go to login phase and skip past it await this.phaseInterceptor.to("LoginPhase", false); - this.phaseInterceptor.shiftPhase(); + this.phaseInterceptor.shiftPhase(true); await this.phaseInterceptor.to("TitlePhase"); + // TODO: This should be moved to a separate initialization method this.scene.gameSpeed = 5; this.scene.moveAnimations = false; this.scene.showLevelUpStats = false; diff --git a/test/test-utils/phase-interceptor.ts b/test/test-utils/phase-interceptor.ts index 0eb85a24ecd..2e9ee6c5279 100644 --- a/test/test-utils/phase-interceptor.ts +++ b/test/test-utils/phase-interceptor.ts @@ -91,8 +91,13 @@ interface InProgressStub { export class PhaseInterceptor { public scene: BattleScene; - public phases: Record = {}; + // @ts-expect-error: initialized in `initPhases` + public phases: Record = {}; public log: PhaseString[]; + /** + * TODO: This should not be an array; + * Our linear phase system means only 1 phase is ever started at once (if any) + */ private onHold: PhaseClass[]; private interval: NodeJS.Timeout; private promptInterval: NodeJS.Timeout; @@ -225,11 +230,12 @@ export class PhaseInterceptor { this.intervalRun = setInterval(async () => { const currentPhase = this.onHold?.length && this.onHold[0]; if (!currentPhase) { - // No current phase = interrupted by prompt; wait for phase to finish + // No current phase means the manager either hasn't started yet + // or we were interrupted by prompt; wait for phase to finish return; } - // If current phase is different, do nothing. + // If current phase is different, run it and wait for it to finish. if (currentPhase.name !== targetName) { await this.run().catch(e => { clearInterval(this.intervalRun); @@ -319,13 +325,7 @@ export class PhaseInterceptor { */ startPhase(phase: PhaseClass) { this.log.push(phase.name as PhaseString); - const instance = this.scene.phaseManager.getCurrentPhase(); - this.onHold.push({ - name: phase.name, - call: () => { - this.phases[phase.name].start.apply(instance); - }, - }); + this.onHold.push(phase); } /**