Debug discipline XP buttons don't update totalXP or concurrentLimit #253
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?
Steps to reproduce:
Expected: After adding 1000 XP,
concurrentLimitshould increase from 1 to 3 (formula:1 + floor(totalXP / 500), max 4). With 2000+ total XP, limit should be 3.Actual: "Active: 1 / 1" stays at limit 1 regardless of how much XP is added. The
concurrentLimitnever updates.Root cause: The
handleAddXPfunction inDisciplineDebugSection.tsxupdates discipline XP directly viauseDisciplineStore.setState(), but it only modifiesdisciplines[id].xp. It does NOT updatetotalXPor recalculateconcurrentLimit. These values are only updated duringprocessTick()in the discipline store, which only runs during the game tick loop (every 200ms). Since the game was paused during testing, no ticks fired.Fix: In
handleAddXP, also updatetotalXPby the same amount, and recalculateconcurrentLimitusing the formulaMath.min(MAX_CONCURRENT_DISCIPLINES + Math.floor(newTotalXP / 500), MAX_CONCURRENT_DISCIPLINES + 3).Affected file:
src/components/game/tabs/DebugTab/DisciplineDebugSection.tsx(thehandleAddXPfunction)Store:
useDisciplineStore(disciplines, totalXP, concurrentLimit)Starting fix. handleAddXP in DisciplineDebugSection.tsx only updates disciplines[id].xp but not totalXP or concurrentLimit. Fix: also update totalXP and recalculate concurrentLimit using the same formula as processTick.
Fixed: handleAddXP in DisciplineDebugSection.tsx now updates totalXP and recalculates concurrentLimit alongside disciplines[id].xp. The formula matches processTick:
Math.min(MAX_CONCURRENT_DISCIPLINES + Math.floor(newTotalXP / 500), MAX_CONCURRENT_DISCIPLINES + 3). All 97 tests pass across DebugTab, discipline-math, and store-actions-discipline suites.