[High] [Bug] Non-combat rooms grant repeated rewards during descent (library XP, treasure loot) #382
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 Summary
When descending the spire, non-combat rooms (especially library and treasure) grant rewards every tick without completion guards, causing repeated XP/loot accumulation.
Expected Behavior
Non-combat rooms should only grant rewards while
progress < required. Once complete, no more rewards should be awarded.Root Cause
Primary bug —
tickLibraryRoominsrc/lib/game/stores/non-combat-room-actions.ts:127-140: Library XP is granted unconditionally every tick BEFORE the completion check at line 141. There is no guard likeif (progress < required)` around the XP grant.Secondary bug —
tickTreasureRoomin the same file, lines 174-222:Loot is granted based on threshold ratios. Once
progress >= required,advance()is called, but the loot for the final threshold is granted every subsequent tick.Tertiary issue —
combat-descent-actions.ts:66-100:During descent, non-combat rooms are never initialized (no
onEnter*Roomcalls), so they retain default progress=0, required=1 fromgenerateSpireFloorState. The tick pipeline processes them and grants rewards.Severity
High — Library rooms grant
Math.floor(50 * 25 * hours)XP every tick unconditionally. At 200ms ticks, that's 250 XP/tick = 1,250 XP/second per library room, accumulating indefinitely during descent.Files Involved
src/lib/game/stores/non-combat-room-actions.tssrc/lib/game/stores/non-combat-room-actions.tssrc/lib/game/stores/non-combat-room-actions.tssrc/lib/game/stores/combat-descent-actions.tsFix Direction
if (progress < required)Starting work on this bug. Reading the affected files to understand the current code structure before implementing fixes.
✅ Fixed and pushed. All 1194 tests pass (0 regressions).
Changes made:
non-combat-room-actions.ts— Wrapped library XP grant inif (progress < required)guard so completed rooms don't grant XP every ticknon-combat-room-actions.ts— Added early return intickTreasureRoomwhenprogress >= requiredto skip loot processingcombat-descent-actions.ts— Added non-combat room initialization (library, treasure, recovery) inonEnterRoomDescendduring descentnon-combat-room-reward-guards.test.ts— New regression test file with 8 tests covering all three fixes