From 8b65f9afab8bc502dfec8ce4f1ff2ca6cc97cbd9 Mon Sep 17 00:00:00 2001 From: Bertie690 Date: Mon, 4 Aug 2025 16:27:47 -0400 Subject: [PATCH 1/2] Added TODO test case + documentation for failing intim test --- test/abilities/intimidate.test.ts | 16 ++++++++++ .../test-utils/helpers/classic-mode-helper.ts | 30 +++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/test/abilities/intimidate.test.ts b/test/abilities/intimidate.test.ts index 3c283e0392b..23c276f9a5d 100644 --- a/test/abilities/intimidate.test.ts +++ b/test/abilities/intimidate.test.ts @@ -44,6 +44,22 @@ describe("Abilities - Intimidate", () => { expect(enemy.getStatStage(Stat.ATK)).toBe(-2); }); + // TODO: This fails due to a limitation in our switching logic - the animations and field entry occur concurrently + // inside `SummonPhase`, unshifting 2 `PostSummmonPhase`s and proccing intimidate twice + it.todo("should lower all opponents' ATK by 1 stage on initial switch prompt", async () => { + await game.classicMode.runToSummon([SpeciesId.MIGHTYENA, SpeciesId.POOCHYENA]); + await game.classicMode.startBattleWithSwitch(1); + + const [poochyena, mightyena] = game.scene.getPlayerField(); + expect(poochyena.species.speciesId).toBe(SpeciesId.POOCHYENA); + + const enemy = game.field.getEnemyPokemon(); + expect(enemy).toHaveStatStage(Stat.ATK, -1); + + expect(poochyena).toHaveAbilityApplied(AbilityId.INTIMIDATE); + expect(mightyena).not.toHaveAbilityApplied(AbilityId.INTIMIDATE); + }); + it("should lower ATK of all opponents in a double battle", async () => { game.override.battleStyle("double"); await game.classicMode.startBattle([SpeciesId.MIGHTYENA]); diff --git a/test/test-utils/helpers/classic-mode-helper.ts b/test/test-utils/helpers/classic-mode-helper.ts index 5d73dc07615..77da57b3c64 100644 --- a/test/test-utils/helpers/classic-mode-helper.ts +++ b/test/test-utils/helpers/classic-mode-helper.ts @@ -1,6 +1,7 @@ import { getGameMode } from "#app/game-mode"; import overrides from "#app/overrides"; import { BattleStyle } from "#enums/battle-style"; +import { Button } from "#enums/buttons"; import { GameModes } from "#enums/game-modes"; import { Nature } from "#enums/nature"; import type { SpeciesId } from "#enums/species-id"; @@ -100,4 +101,33 @@ export class ClassicModeHelper extends GameManagerHelper { await this.game.phaseInterceptor.to(CommandPhase); console.log("==================[New Turn]=================="); } + + /** + * Queue inputs to switch at the start of the next battle, and then start it. + * @param pokemonIndex - The 0-indexed position of the party pokemon to switch to. + * Should never be called with 0 as that will select the currently active pokemon and freeze + * @returns A Promise that resolves once the battle has been started and the switch prompt resolved + * @todo Make this work for double battles + * @example + * ```ts + * await game.classicMode.runToSummon([SpeciesId.MIGHTYENA, SpeciesId.POOCHYENA]) + * await game.queueStartOfBattleSwitch(1); + * ``` + */ + public async startBattleWithSwitch(pokemonIndex: number): Promise { + this.game.scene.battleStyle = BattleStyle.SWITCH; + this.game.onNextPrompt( + "CheckSwitchPhase", + UiMode.CONFIRM, + () => { + this.game.scene.ui.getHandler().setCursor(0); + this.game.scene.ui.getHandler().processInput(Button.ACTION); + }, + () => this.game.isCurrentPhase("CommandPhase") || this.game.isCurrentPhase("TurnInitPhase"), + ); + this.game.doSelectPartyPokemon(pokemonIndex); + + await this.game.phaseInterceptor.to("CommandPhase"); + console.log("==================[New Battle (Initial Switch)]=================="); + } } From 2d6267b668846d67ee012e104dd2c9a8e0099798 Mon Sep 17 00:00:00 2001 From: Bertie690 Date: Mon, 4 Aug 2025 17:08:28 -0400 Subject: [PATCH 2/2] Fixed comment --- test/test-utils/helpers/classic-mode-helper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-utils/helpers/classic-mode-helper.ts b/test/test-utils/helpers/classic-mode-helper.ts index 77da57b3c64..18c10ef6d1e 100644 --- a/test/test-utils/helpers/classic-mode-helper.ts +++ b/test/test-utils/helpers/classic-mode-helper.ts @@ -111,7 +111,7 @@ export class ClassicModeHelper extends GameManagerHelper { * @example * ```ts * await game.classicMode.runToSummon([SpeciesId.MIGHTYENA, SpeciesId.POOCHYENA]) - * await game.queueStartOfBattleSwitch(1); + * await game.startBattleWithSwitch(1); * ``` */ public async startBattleWithSwitch(pokemonIndex: number): Promise {