mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-26 00:36:25 +00:00
[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
This commit is contained in:
parent
92afcdea8f
commit
bb7af15c4a
@ -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--;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user