Bug: Practicing discipline doesn't reset to 'meditating' when mana runs out #143
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
When a player is practicing a discipline and runs out of mana, the discipline correctly stops (sets
paused: true), butcurrentActionin the combat store remains stuck at'practicing'instead of being reset to'meditate'.Root Cause
In
src/lib/game/stores/discipline-slice.ts(~line 171), when mana runs out duringprocessTick, the discipline'spausedflag is set totrue, but the discipline ID is never removed fromactiveIds. TheonStopPracticingcallback (which setscurrentActionback to'meditate') is only called whenactiveIdsbecomes empty in thedeactivatemethod.Fix Required
In
processTick, after detecting insufficient mana and settingpaused: true, also remove the discipline ID fromactiveIds. After the loop, ifactiveIdsis now empty, callonStopPracticing().Affected Files
src/lib/game/stores/discipline-slice.ts—processTickmethod (~lines 158-171)src/lib/game/stores/combatStore.ts—startPracticing/stopPracticingactions (lines 166-177)Fixed #143 — Discipline now resets to 'meditating' when mana runs out.
Root cause: In
discipline-slice.tsprocessTick, when mana was insufficient, the discipline was paused (paused: true) but never removed fromactiveIds. SinceonStopPracticing(which resetscurrentActionto'meditate') only fired whenactiveIdsbecame empty, it never triggered.Fix:
drainedIdsarray during the tick loopactiveIdsactiveIdsis now empty (and wasn't before), callonStopPracticing()Changed files:
src/lib/game/stores/discipline-slice.ts— processTick now removes drained disciplines and fires onStopPracticingAll 885 tests pass. Committed and pushed as
7962a4f.Closing — fixed in commit
7962a4f