[High] [Bug] Victory condition unreachable — game-over fires before victory check #356
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: High
File:
src/lib/game/stores/gameStore.ts(lines 139-155)Description:
The
day > MAX_DAYcheck at line 139 fires and setsgameOver: true, victory: falsebefore the victory condition at line 152 is ever evaluated. If a player reaches floor 100 with pact 100 signed on exactly day 30 (the last day), the next tick advancesdayto 31, and the game-over branch runs first, returning early withvictory: false.Impact: The victory condition is nearly impossible to achieve. Players who reach floor 100 and sign the final pact on day 30 get "game over with defeat" instead of "victory." This is a core game loop completion bug.
Fix needed: Reorder the checks so the victory condition is evaluated before (or instead of) the game-over condition when victory criteria are met.
Starting work on fixing the victory condition being unreachable. Investigating the tick pipeline order to find where game-over fires before victory check.
Fixed. Moved the victory condition check (maxFloorReached >= 100 && signedPacts includes floor 100) BEFORE the day > MAX_DAY game-over check in the tick pipeline. Previously, the day overflow would trigger game-over with victory:false before the victory condition was ever evaluated. All 1157 tests pass.