From 9ea26325ae50c4abab3c479324795f00e94e094a Mon Sep 17 00:00:00 2001 From: Dean Date: Sun, 16 Mar 2025 11:27:42 -0700 Subject: [PATCH] Ensure all PostSummonPhases from encounters are added at the same time --- src/battle-scene.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index af128519a76..743b09805af 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -2765,8 +2765,9 @@ export default class BattleScene extends SceneBase { this.currentPhase = this.phaseQueue.shift() ?? null; + const unactivatedConditionalPhases: [() => boolean, Phase][] = []; // Check if there are any conditional phases queued - if (this.conditionalQueue?.length) { + while (this.conditionalQueue?.length) { // Retrieve the first conditional phase from the queue const conditionalPhase = this.conditionalQueue.shift(); // Evaluate the condition associated with the phase @@ -2775,11 +2776,12 @@ export default class BattleScene extends SceneBase { this.pushPhase(conditionalPhase[1]); } else if (conditionalPhase) { // If the condition is not met, re-add the phase back to the front of the conditional queue - this.conditionalQueue.unshift(conditionalPhase); + unactivatedConditionalPhases.push(conditionalPhase); } else { console.warn("condition phase is undefined/null!", conditionalPhase); } } + this.conditionalQueue.push(...unactivatedConditionalPhases); if (this.currentPhase) { console.log(`%cStart Phase ${this.currentPhase.constructor.name}`, "color:green;");