BUG: Combat store maxFloorReached (1) desyncs with clearedFloors (0) at game start #241

Closed
opened 2026-06-01 09:34:17 +02:00 by Anexim · 1 comment
Owner

Bug Description

The combat store initializes maxFloorReached: 1 while clearedFloors starts as {} (empty). This means the Spire summary shows "Max Floor Reached: 1" but "Floors Cleared: 0" from the very beginning, which is semantically contradictory.

After an ErrorBoundary recovery from any crash, this desync persists and shows confusing state to the player.

Steps to Reproduce

  1. Start a new game (or recover from a crash via "Reset & Recover")
  2. Open the Spire tab
  3. Observe: "Max Floor Reached: 1" but "Floors Cleared: 0"

Root Cause

The initial state in src/lib/game/stores/combatStore.ts sets:

  • maxFloorReached: 1 (meaning floor 1 is considered "reached")
  • clearedFloors: {} (meaning no floors have been cleared)

These two fields are updated independently throughout the game, and the enterSpireMode() / exitSpireMode() actions reset clearedFloors to {} without adjusting maxFloorReached, causing persistent desync.

Suggested Fix

Either:

  1. Set maxFloorReached: 0 in the initial state, OR
  2. Make the "Floors Cleared" display derive from Object.keys(clearedFloors).length consistently with how maxFloorReached is computed, OR
  3. Reset maxFloorReached when clearedFloors is cleared in exitSpireMode()

Files Involved

  • src/lib/game/stores/combatStore.ts — initial state and enterSpireMode/exitSpireMode actions
## Bug Description The combat store initializes `maxFloorReached: 1` while `clearedFloors` starts as `{}` (empty). This means the Spire summary shows "Max Floor Reached: 1" but "Floors Cleared: 0" from the very beginning, which is semantically contradictory. After an ErrorBoundary recovery from any crash, this desync persists and shows confusing state to the player. ## Steps to Reproduce 1. Start a new game (or recover from a crash via "Reset & Recover") 2. Open the Spire tab 3. Observe: "Max Floor Reached: 1" but "Floors Cleared: 0" ## Root Cause The initial state in `src/lib/game/stores/combatStore.ts` sets: - `maxFloorReached: 1` (meaning floor 1 is considered "reached") - `clearedFloors: {}` (meaning no floors have been cleared) These two fields are updated independently throughout the game, and the `enterSpireMode()` / `exitSpireMode()` actions reset `clearedFloors` to `{}` without adjusting `maxFloorReached`, causing persistent desync. ## Suggested Fix Either: 1. Set `maxFloorReached: 0` in the initial state, OR 2. Make the "Floors Cleared" display derive from `Object.keys(clearedFloors).length` consistently with how `maxFloorReached` is computed, OR 3. Reset `maxFloorReached` when `clearedFloors` is cleared in `exitSpireMode()` ## Files Involved - `src/lib/game/stores/combatStore.ts` — initial state and enterSpireMode/exitSpireMode actions
Anexim added the ai:todo label 2026-06-01 09:34:17 +02:00
n8n-gitea was assigned by Anexim 2026-06-01 09:34:17 +02:00
Anexim added this to the (deleted) project 2026-06-01 11:45:48 +02:00
Author
Owner

Fixed. Changed maxFloorReached initial state from 1 to 0 in combatStore.ts. Also added maxFloorReached: 0 reset to exitSpireMode(). This resolves the desync where Spire tab showed "Max Floor 1" but "Floors Cleared 0" at game start or after reset.

Fixed. Changed `maxFloorReached` initial state from 1 to 0 in `combatStore.ts`. Also added `maxFloorReached: 0` reset to `exitSpireMode()`. This resolves the desync where Spire tab showed "Max Floor 1" but "Floors Cleared 0" at game start or after reset.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#241