From ae0cd86bc3538e89db3c2b778dd17004d69c8237 Mon Sep 17 00:00:00 2001 From: td76099 <85713900+td76099@users.noreply.github.com> Date: Sat, 25 May 2024 15:06:50 -0400 Subject: [PATCH] Adding clause so right Pokemon in double battle cannot target itself with a spread move when left one dies with no replacement (#1370) --- src/phases.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/phases.ts b/src/phases.ts index 44ec262d3e6..62d944e68e7 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -2646,8 +2646,14 @@ export class MoveEffectPhase extends PokemonPhase { constructor(scene: BattleScene, battlerIndex: BattlerIndex, targets: BattlerIndex[], move: PokemonMove) { super(scene, battlerIndex); - this.move = move; + // In double battles, if the right Pokemon selects a spread move and the left Pokemon dies + // with no party members available to switch in, then the right Pokemon takes the index + // of the left Pokemon and gets hit unless this is checked. + if (targets.includes(battlerIndex) && this.move.getMove().moveTarget === MoveTarget.ALL_NEAR_OTHERS) { + const i = targets.indexOf(battlerIndex); + targets.splice(i,i+1); + } this.targets = targets; }