From 6154306f80479197dcb95a6505a6db291979d260 Mon Sep 17 00:00:00 2001 From: Michael Li Date: Fri, 10 Jan 2025 17:16:23 -0500 Subject: [PATCH] Fix issues with ending DamageAnimPhase during tests --- src/field/pokemon.ts | 4 ++++ test/mystery-encounter/encounter-test-utils.ts | 18 +++++++++--------- test/utils/gameWrapper.ts | 2 ++ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 1377f11187b..034953e7d68 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -2471,6 +2471,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.switchOutStatus = status; } + /** + * Updates the Pokemon's battle info UI. This is purely a visual update. + * @param instant Whether or not the update should be instant. + */ updateInfo(instant?: boolean): Promise { return this.battleInfo.updateInfo(this, instant); } diff --git a/test/mystery-encounter/encounter-test-utils.ts b/test/mystery-encounter/encounter-test-utils.ts index 69fa9b5465f..8b460c8089d 100644 --- a/test/mystery-encounter/encounter-test-utils.ts +++ b/test/mystery-encounter/encounter-test-utils.ts @@ -33,15 +33,15 @@ export async function runMysteryEncounterToEnd(game: GameManager, optionNo: numb }, () => game.isCurrentPhase(MysteryEncounterBattlePhase) || game.isCurrentPhase(MysteryEncounterRewardsPhase)); if (isBattle) { - game.onNextPrompt("DamageAnimPhase", Mode.MESSAGE, () => { - game.setMode(Mode.MESSAGE); - game.endPhase(); - }, () => game.isCurrentPhase(CommandPhase)); - - game.onNextPrompt("CheckSwitchPhase", Mode.CONFIRM, () => { - game.setMode(Mode.MESSAGE); - game.endPhase(); - }, () => game.isCurrentPhase(CommandPhase)); + game.onNextPrompt( + "CheckSwitchPhase", + Mode.CONFIRM, + () => { + game.setMode(Mode.MESSAGE); + game.endPhase(); + }, + () => game.isCurrentPhase(CommandPhase), + ); game.onNextPrompt("CheckSwitchPhase", Mode.MESSAGE, () => { game.setMode(Mode.MESSAGE); diff --git a/test/utils/gameWrapper.ts b/test/utils/gameWrapper.ts index 4d8268d2fa8..70a64050527 100644 --- a/test/utils/gameWrapper.ts +++ b/test/utils/gameWrapper.ts @@ -186,6 +186,8 @@ export class GameWrapper { this.scene.time = new MockClock(this.scene); this.scene.remove = vi.fn(); // TODO: this should be stubbed differently this.scene.eventManager = new MockTimedEventManager(); // Disable Timed Events + + Pokemon.prototype.updateInfo = async () => {}; } }