From 739ed42673cac0002cab012611b438320de09b10 Mon Sep 17 00:00:00 2001 From: innerthunder Date: Fri, 9 Aug 2024 11:07:22 -0700 Subject: [PATCH] Fix baton pass test --- src/phases.ts | 6 +++--- src/test/moves/substitute.test.ts | 9 +++++++-- src/test/utils/gameManager.ts | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/phases.ts b/src/phases.ts index 81dc0184479..744a20d4840 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -1685,9 +1685,9 @@ export class SwitchSummonPhase extends SummonPhase { if (this.batonPass) { const substitute = this.lastPokemon.getTag(SubstituteTag); if (!!substitute) { - switchedPokemon.x += switchedPokemon.getSubstituteOffset()[0]; - switchedPokemon.y += switchedPokemon.getSubstituteOffset()[1]; - switchedPokemon.setAlpha(0.5); + switchedInPokemon.x += switchedPokemon.getSubstituteOffset()[0]; + switchedInPokemon.y += switchedPokemon.getSubstituteOffset()[1]; + switchedInPokemon.setAlpha(0.5); } } else { switchedInPokemon.resetBattleData(); diff --git a/src/test/moves/substitute.test.ts b/src/test/moves/substitute.test.ts index 51ad68274b7..8056834b6c6 100644 --- a/src/test/moves/substitute.test.ts +++ b/src/test/moves/substitute.test.ts @@ -5,7 +5,7 @@ import { Species } from "#app/enums/species"; import { Abilities } from "#app/enums/abilities"; import { Moves } from "#app/enums/moves"; import { getMovePosition } from "../utils/gameManagerUtils"; -import { BerryPhase, MoveEndPhase, MovePhase } from "#app/phases"; +import { BerryPhase, CommandPhase, MoveEndPhase, MovePhase } from "#app/phases"; import { BattlerTagType } from "#app/enums/battler-tag-type"; import { BattleStat } from "#app/data/battle-stat"; import { allMoves, StealHeldItemChanceAttr } from "#app/data/move"; @@ -13,6 +13,8 @@ import { SubstituteTag, TrappedTag } from "#app/data/battler-tags"; import { StatusEffect } from "#app/data/status-effect"; import { BerryType } from "#app/enums/berry-type"; import { SPLASH_ONLY } from "../utils/testUtils"; +import { Mode } from "#app/ui/ui.js"; +import { Command } from "#app/ui/command-ui-handler.js"; const TIMEOUT = 20 * 1000; // 20 sec timeout @@ -391,7 +393,10 @@ describe("Moves - Substitute", () => { leadPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, leadPokemon.id); - game.doSwitchPokemon(1, true); + // Simulate a Baton switch for the player this turn + game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { + (game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.POKEMON, 1, true); + }); await game.phaseInterceptor.to(MovePhase, false); diff --git a/src/test/utils/gameManager.ts b/src/test/utils/gameManager.ts index b0a2931b9f6..771ab1e7081 100644 --- a/src/test/utils/gameManager.ts +++ b/src/test/utils/gameManager.ts @@ -316,7 +316,7 @@ export default class GameManager { * Command an in-battle switch to another Pokemon via the main battle menu. * @param pokemonIndex the index of the pokemon in your party to switch to */ - doSwitchPokemon(pokemonIndex: number, batonPass: boolean = false) { + doSwitchPokemon(pokemonIndex: number) { this.onNextPrompt("CommandPhase", Mode.COMMAND, () => { (this.scene.ui.getHandler() as CommandUiHandler).setCursor(2); (this.scene.ui.getHandler() as CommandUiHandler).processInput(Button.ACTION);