diff --git a/src/battle.ts b/src/battle.ts index 245705f4801..ecb5aa98e24 100644 --- a/src/battle.ts +++ b/src/battle.ts @@ -94,6 +94,8 @@ export default class Battle { /** If the current battle is a Mystery Encounter, this will always be defined */ public mysteryEncounter?: MysteryEncounter; + public failedRunAway = false; + private rngCounter = 0; constructor(gameMode: GameMode, waveIndex: number, battleType: BattleType, trainer?: Trainer, double = false) { diff --git a/src/phases/attempt-run-phase.ts b/src/phases/attempt-run-phase.ts index 31b6bc61ff4..8900b46fe72 100644 --- a/src/phases/attempt-run-phase.ts +++ b/src/phases/attempt-run-phase.ts @@ -20,10 +20,10 @@ export class AttemptRunPhase extends PokemonPhase { start() { super.start(); + //Attempting to run is a TEAM not PLAYER based action, we should not be referercing individual pokemon, + //we should instead be referring to the team as a whole const activePlayerField = globalScene.getActivePlayerField(); const enemyField = globalScene.getEnemyField(); - //Attempting to run is a TEAM not PLAYER based action, we should not be referercing individual pokemon, - //we should instead be referring to the team as a whole and const escapeChance = new NumberHolder(0); const escapeRoll = this.getTeamRNG(100); @@ -67,11 +67,7 @@ export class AttemptRunPhase extends PokemonPhase { globalScene.phaseManager.pushNew("NewBattlePhase"); } else { - //there should be a general failed run away bool for the active team - activePlayerField.forEach(p => { - p.turnData.failedRunAway = true; - }); - + globalScene.currentBattle.failedRunAway = true; globalScene.phaseManager.queueMessage(i18next.t("battle:runAwayCannotEscape"), null, true, 500); } diff --git a/src/phases/battle-phase.ts b/src/phases/battle-phase.ts index 7cefd0369d9..32a0fca6de3 100644 --- a/src/phases/battle-phase.ts +++ b/src/phases/battle-phase.ts @@ -3,6 +3,17 @@ import { TrainerSlot } from "#enums/trainer-slot"; import { Phase } from "#app/phase"; export abstract class BattlePhase extends Phase { + start() { + if (globalScene.currentBattle.failedRunAway) { + const activePlayerField = globalScene.getActivePlayerField(); + + activePlayerField.forEach(p => { + p.turnData.failedRunAway = true; + }); + + globalScene.currentBattle.failedRunAway = false; + } + } showEnemyTrainer(trainerSlot: TrainerSlot = TrainerSlot.NONE): void { if (!globalScene.currentBattle.trainer) { console.warn("Enemy trainer is missing!");