From 00e8f260e5469157f6b6a01f7b9c49b4e9b2192d Mon Sep 17 00:00:00 2001 From: Smell of curry <75345244+smell-of-curry@users.noreply.github.com> Date: Sat, 6 Sep 2025 09:40:29 -0400 Subject: [PATCH] Refactor phazing logic to handle null pokemon Fixes: `TypeError: cannot read property 'forceSwitchFlag' of null` --- sim/battle.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sim/battle.ts b/sim/battle.ts index 8b787b026a..818dfabe42 100644 --- a/sim/battle.ts +++ b/sim/battle.ts @@ -2820,10 +2820,10 @@ export class Battle { // phazing (Roar, etc) for (const side of this.sides) { for (const pokemon of side.active) { - if (pokemon.forceSwitchFlag) { - if (pokemon.hp) this.actions.dragIn(pokemon.side, pokemon.position); - pokemon.forceSwitchFlag = false; - } + if (!pokemon) continue; + if (!pokemon.forceSwitchFlag) continue; + if (pokemon.hp) this.actions.dragIn(pokemon.side, pokemon.position); + pokemon.forceSwitchFlag = false; } }