Bug: Cannot restart practicing a discipline after stopping it #163
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
After stopping a discipline (deactivating it), the player cannot start practicing it again. Clicking "Start Practicing" does nothing.
Steps to Reproduce
Root Cause
In
DisciplinesTab.tsx, thehandleTogglecallback callsactivate(id, { elements, signedPacts })but never passesrawManain the gameState object.In
discipline-math.ts→canProceedDiscipline(), when the discipline'smanaTypeis'raw', it checks:Since
rawManaisundefined, this evaluates to0 >= drainBasewhich isfalsefor any discipline withdrainBase > 0.On first activation,
disciplineStateisundefined, socanProceedDisciplineshort-circuits withreturn true. But after deactivation, the discipline state exists (with accumulated XP), so the mana check runs and silently fails.Fix
Pass
rawManafrom the mana store into thegameStateargument when callingactivateinDisciplinesTab.tsx.Fix Applied
File changed:
src/components/game/tabs/DisciplinesTab.tsxTwo changes:
rawManafromuseManaStoreand passed it in thegameStateobject toactivate()useCallbackdependency array to includerawManaandsignedPacts(was missing both)Root cause confirmed:
canProceedDiscipline()indiscipline-math.tschecksgameState.rawMana >= drainfor raw mana disciplines. SincerawManawas never passed, it evaluated to0 >= drainBase→false, silently blocking reactivation. First-time activation worked becausedisciplineStateisundefined, which short-circuits the check.Regression test added:
src/lib/game/__tests__/discipline-reactivate-bug.test.ts— 4 tests covering:rawMana, verifies fix with it)All 906 tests pass (47 files).
Fixed and pushed to master (commit
5f8a860). The fix passesrawManafrom the mana store into theactivate()call in DisciplinesTab, and fixes the useCallback dependency array to includerawManaandsignedPacts. Regression tests added and all 906 tests pass.