Ensure all PostSummonPhases from encounters are added at the same time

This commit is contained in:
Dean 2025-03-16 11:27:42 -07:00
parent 349b4b0fdf
commit 9ea26325ae

View File

@ -2765,8 +2765,9 @@ export default class BattleScene extends SceneBase {
this.currentPhase = this.phaseQueue.shift() ?? null; this.currentPhase = this.phaseQueue.shift() ?? null;
const unactivatedConditionalPhases: [() => boolean, Phase][] = [];
// Check if there are any conditional phases queued // Check if there are any conditional phases queued
if (this.conditionalQueue?.length) { while (this.conditionalQueue?.length) {
// Retrieve the first conditional phase from the queue // Retrieve the first conditional phase from the queue
const conditionalPhase = this.conditionalQueue.shift(); const conditionalPhase = this.conditionalQueue.shift();
// Evaluate the condition associated with the phase // Evaluate the condition associated with the phase
@ -2775,11 +2776,12 @@ export default class BattleScene extends SceneBase {
this.pushPhase(conditionalPhase[1]); this.pushPhase(conditionalPhase[1]);
} else if (conditionalPhase) { } else if (conditionalPhase) {
// If the condition is not met, re-add the phase back to the front of the conditional queue // 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 { } else {
console.warn("condition phase is undefined/null!", conditionalPhase); console.warn("condition phase is undefined/null!", conditionalPhase);
} }
} }
this.conditionalQueue.push(...unactivatedConditionalPhases);
if (this.currentPhase) { if (this.currentPhase) {
console.log(`%cStart Phase ${this.currentPhase.constructor.name}`, "color:green;"); console.log(`%cStart Phase ${this.currentPhase.constructor.name}`, "color:green;");