From a862dabcd1f38dbda0f9e7cd132b0a84baf2d283 Mon Sep 17 00:00:00 2001 From: Felix Staud Date: Wed, 17 Jul 2024 10:10:40 -0700 Subject: [PATCH] optimize handleMysteryEncounterVictory --- src/data/mystery-encounters/utils/encounter-phase-utils.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/data/mystery-encounters/utils/encounter-phase-utils.ts b/src/data/mystery-encounters/utils/encounter-phase-utils.ts index 76f530cf0db..3f600a0f389 100644 --- a/src/data/mystery-encounters/utils/encounter-phase-utils.ts +++ b/src/data/mystery-encounters/utils/encounter-phase-utils.ts @@ -522,10 +522,14 @@ export function leaveEncounterWithoutBattle(scene: BattleScene, addHealPhase: bo export function handleMysteryEncounterVictory(scene: BattleScene, addHealPhase: boolean = false) { const allowedPkm = scene.getParty().filter((pkm) => pkm.isAllowedInBattle()); + if (allowedPkm.length === 0) { scene.clearPhaseQueue(); scene.unshiftPhase(new GameOverPhase(scene)); - } else if (scene.currentBattle.mysteryEncounter.encounterVariant === MysteryEncounterVariant.SAFARI_BATTLE) { + return; + } + + if (scene.currentBattle.mysteryEncounter.encounterVariant === MysteryEncounterVariant.SAFARI_BATTLE) { scene.pushPhase(new MysteryEncounterRewardsPhase(scene, addHealPhase)); } else if (scene.currentBattle.mysteryEncounter.encounterVariant === MysteryEncounterVariant.NO_BATTLE) { scene.pushPhase(new EggLapsePhase(scene));