BUG: Combat store maxFloorReached (1) desyncs with clearedFloors (0) at game start #241
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?
Bug Description
The combat store initializes
maxFloorReached: 1whileclearedFloorsstarts 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
Root Cause
The initial state in
src/lib/game/stores/combatStore.tssets: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 resetclearedFloorsto{}without adjustingmaxFloorReached, causing persistent desync.Suggested Fix
Either:
maxFloorReached: 0in the initial state, ORObject.keys(clearedFloors).lengthconsistently with howmaxFloorReachedis computed, ORmaxFloorReachedwhenclearedFloorsis cleared inexitSpireMode()Files Involved
src/lib/game/stores/combatStore.ts— initial state and enterSpireMode/exitSpireMode actionsFixed. Changed
maxFloorReachedinitial state from 1 to 0 incombatStore.ts. Also addedmaxFloorReached: 0reset toexitSpireMode(). This resolves the desync where Spire tab showed "Max Floor 1" but "Floors Cleared 0" at game start or after reset.