From bb7af15c4a3c204c3e538077d366c688517c134d Mon Sep 17 00:00:00 2001 From: Adrian T <68144167+torranx@users.noreply.github.com> Date: Fri, 31 May 2024 22:23:28 +0800 Subject: [PATCH] [Move][Bug] Fix Enemy Fake Out and Force Switch Interaction (#1251) * fix force switch move * add check if switched out pokemon is not fainted with force switch move * improve code documentation * refactor if statement --- src/phases.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/phases.ts b/src/phases.ts index 7e3202e43b2..58bfb527e44 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -1548,11 +1548,16 @@ export class SwitchSummonPhase extends SummonPhase { super.onEnd(); const pokemon = this.getPokemon(); - const moveId = pokemon.scene.currentBattle.turnCommands[this.fieldIndex]?.move?.move; + + const moveId = this.lastPokemon?.scene.currentBattle.lastMove; const lastUsedMove = moveId ? allMoves[moveId] : undefined; + const currentCommand = pokemon.scene.currentBattle.turnCommands[this.fieldIndex]?.command; + const lastPokemonIsForceSwitchedAndNotFainted = !!lastUsedMove?.findAttr(attr => attr instanceof ForceSwitchOutAttr) && !this.lastPokemon.isFainted(); + // Compensate for turn spent summoning - if (pokemon.scene.currentBattle.turnCommands[this.fieldIndex]?.command === Command.POKEMON || !!lastUsedMove?.findAttr(attr => attr instanceof ForceSwitchOutAttr)) { //check if hard switch OR pivot move was used + // Or compensate for force switch move if switched out pokemon is not fainted + if (currentCommand === Command.POKEMON || lastPokemonIsForceSwitchedAndNotFainted) { pokemon.battleSummonData.turnCount--; }