[High] [Bug] Victory condition unreachable — game-over fires before victory check #356

Closed
opened 2026-06-10 19:24:42 +02:00 by Anexim · 2 comments
Owner

Severity: High
File: src/lib/game/stores/gameStore.ts (lines 139-155)

Description:
The day > MAX_DAY check at line 139 fires and sets gameOver: true, victory: false before 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 advances day to 31, and the game-over branch runs first, returning early with victory: 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.

**Severity:** High **File:** `src/lib/game/stores/gameStore.ts` (lines 139-155) **Description:** The `day > MAX_DAY` check at line 139 fires and sets `gameOver: true, victory: false` **before** 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 advances `day` to 31, and the game-over branch runs first, returning early with `victory: 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.
Anexim added the ai:todo label 2026-06-10 19:24:42 +02:00
n8n-gitea was assigned by Anexim 2026-06-10 19:24:42 +02:00
Anexim added ai:in-progress and removed ai:todo labels 2026-06-10 22:56:24 +02:00
Author
Owner

Starting work on fixing the victory condition being unreachable. Investigating the tick pipeline order to find where game-over fires before victory check.

Starting work on fixing the victory condition being unreachable. Investigating the tick pipeline order to find where game-over fires before victory check.
Anexim added ai:done and removed ai:in-progress labels 2026-06-10 22:58:02 +02:00
Author
Owner

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.

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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#356