Bug: Practicing discipline doesn't reset to 'meditating' when mana runs out #143

Closed
opened 2026-05-27 10:22:50 +02:00 by Anexim · 2 comments
Owner

Bug Description

When a player is practicing a discipline and runs out of mana, the discipline correctly stops (sets paused: true), but currentAction in 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 during processTick, the discipline's paused flag is set to true, but the discipline ID is never removed from activeIds. The onStopPracticing callback (which sets currentAction back to 'meditate') is only called when activeIds becomes empty in the deactivate method.

Fix Required

In processTick, after detecting insufficient mana and setting paused: true, also remove the discipline ID from activeIds. After the loop, if activeIds is now empty, call onStopPracticing().

Affected Files

  • src/lib/game/stores/discipline-slice.tsprocessTick method (~lines 158-171)
  • src/lib/game/stores/combatStore.tsstartPracticing/stopPracticing actions (lines 166-177)
## Bug Description When a player is practicing a discipline and runs out of mana, the discipline correctly stops (sets `paused: true`), but `currentAction` in 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 during `processTick`, the discipline's `paused` flag is set to `true`, but the discipline ID is **never removed from `activeIds`**. The `onStopPracticing` callback (which sets `currentAction` back to `'meditate'`) is only called when `activeIds` becomes empty in the `deactivate` method. ## Fix Required In `processTick`, after detecting insufficient mana and setting `paused: true`, also remove the discipline ID from `activeIds`. After the loop, if `activeIds` is now empty, call `onStopPracticing()`. ## Affected Files - `src/lib/game/stores/discipline-slice.ts` — `processTick` method (~lines 158-171) - `src/lib/game/stores/combatStore.ts` — `startPracticing`/`stopPracticing` actions (lines 166-177)
Anexim added the ai:todo label 2026-05-27 10:22:50 +02:00
n8n-gitea was assigned by Anexim 2026-05-27 10:22:50 +02:00
Author
Owner

Fixed #143 — Discipline now resets to 'meditating' when mana runs out.

Root cause: In discipline-slice.ts processTick, when mana was insufficient, the discipline was paused (paused: true) but never removed from activeIds. Since onStopPracticing (which resets currentAction to 'meditate') only fired when activeIds became empty, it never triggered.

Fix:

  • Track which disciplines got drained in a drainedIds array during the tick loop
  • After the loop, filter drained IDs out of activeIds
  • If activeIds is now empty (and wasn't before), call onStopPracticing()

Changed files:

  • src/lib/game/stores/discipline-slice.ts — processTick now removes drained disciplines and fires onStopPracticing

All 885 tests pass. Committed and pushed as 7962a4f.

Fixed #143 — Discipline now resets to 'meditating' when mana runs out. **Root cause**: In `discipline-slice.ts` `processTick`, when mana was insufficient, the discipline was paused (`paused: true`) but never removed from `activeIds`. Since `onStopPracticing` (which resets `currentAction` to `'meditate'`) only fired when `activeIds` became empty, it never triggered. **Fix**: - Track which disciplines got drained in a `drainedIds` array during the tick loop - After the loop, filter drained IDs out of `activeIds` - If `activeIds` is now empty (and wasn't before), call `onStopPracticing()` ### Changed files: - `src/lib/game/stores/discipline-slice.ts` — processTick now removes drained disciplines and fires onStopPracticing All 885 tests pass. Committed and pushed as 7962a4f.
Author
Owner

Closing — fixed in commit 7962a4f

Closing — fixed in commit 7962a4f
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#143