[Bug][Beta] Fix Fun and Games playing in wrong order (#6644)

Unshift using `currentLevel` instead of `length`
This commit is contained in:
Dean 2025-10-25 19:46:33 -07:00 committed by GitHub
parent 82181c5264
commit fef48ac2e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -32,6 +32,9 @@ export class PhaseTree {
* @throws Error if `level` is out of legal bounds * @throws Error if `level` is out of legal bounds
*/ */
private add(phase: Phase, level: number): void { private add(phase: Phase, level: number): void {
if (level === this.currentLevel + 1 && level === this.levels.length) {
this.levels.push([]);
}
const addLevel = this.levels[level]; const addLevel = this.levels[level];
if (addLevel == null) { if (addLevel == null) {
throw new Error("Attempted to add a phase to a nonexistent level of the PhaseTree!\nLevel: " + level.toString()); 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) { if (defer && !this.deferredActive) {
this.deferredActive = true; this.deferredActive = true;
this.levels.splice(-1, 0, []); 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--; 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(); return this.levels[this.currentLevel].shift();
} }
@ -155,6 +157,7 @@ export class PhaseTree {
*/ */
public clear(leaveFirstLevel = false) { public clear(leaveFirstLevel = false) {
this.levels = [leaveFirstLevel ? (this.levels.at(-1) ?? []) : []]; this.levels = [leaveFirstLevel ? (this.levels.at(-1) ?? []) : []];
this.currentLevel = 0;
} }
/** /**