From fef48ac2e81001af445f4bca1a3c291b60976f7e Mon Sep 17 00:00:00 2001 From: Dean <69436131+emdeann@users.noreply.github.com> Date: Sat, 25 Oct 2025 19:46:33 -0700 Subject: [PATCH] [Bug][Beta] Fix Fun and Games playing in wrong order (#6644) Unshift using `currentLevel` instead of `length` --- src/phase-tree.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/phase-tree.ts b/src/phase-tree.ts index 69bb72ca4f0..f0501a6ece6 100644 --- a/src/phase-tree.ts +++ b/src/phase-tree.ts @@ -32,6 +32,9 @@ export class PhaseTree { * @throws Error if `level` is out of legal bounds */ private add(phase: Phase, level: number): void { + if (level === this.currentLevel + 1 && level === this.levels.length) { + this.levels.push([]); + } const addLevel = this.levels[level]; if (addLevel == null) { throw new Error("Attempted to add a phase to a nonexistent level of the PhaseTree!\nLevel: " + level.toString()); @@ -57,8 +60,9 @@ export class PhaseTree { if (defer && !this.deferredActive) { this.deferredActive = true; this.levels.splice(-1, 0, []); + this.currentLevel += 1; } - this.add(phase, this.levels.length - 1 - +defer); + this.add(phase, this.currentLevel + 1 - +defer); } /** @@ -107,8 +111,6 @@ export class PhaseTree { this.currentLevel--; } - // TODO: right now, this is preventing properly marking when one set of unshifted phases ends - this.levels.push([]); return this.levels[this.currentLevel].shift(); } @@ -155,6 +157,7 @@ export class PhaseTree { */ public clear(leaveFirstLevel = false) { this.levels = [leaveFirstLevel ? (this.levels.at(-1) ?? []) : []]; + this.currentLevel = 0; } /**