"Can't resume practicing discipline when stopped" #230

Closed
opened 2026-05-31 10:17:52 +02:00 by Anexim · 2 comments
Owner

Description: After deactivating a discipline, clicking "Start Practicing" does not re-activate the discipline. The button changes but the discipline remains paused/inactive.

Root Cause:

The activate method in discipline-slice.ts has a guard in canProceedDiscipline() that checks if the player has sufficient mana to cover the discipline's drain:

// discipline-slice.ts activate():
if (!canProceedDiscipline(def, existing, gameState)) return s;

When re-activating a discipline with gameState.elements but no rawMana property (which is the case from DisciplinesTab.tsx — only elements and signedPacts are passed), canProceedDiscipline checks gameState.rawMana which is undefined, fails the drain check, and silently returns without activating.

From DisciplinesTab.tsx:

const handleToggle = useCallback((id: string, paused: boolean) => {
    if (paused) {
      activate(id, { elements, signedPacts });  // <-- NO rawMana passed!
    } else {
      deactivate(id);
    }
}, [activate, deactivate, rawMana, elements, signedPacts]);

The rawMana variable is available in scope but NOT passed in the gameState object. This is a mismatch — the activate method needs rawMana for raw-type disciplines, but the UI doesn't pass it.

Files involved:

  • src/lib/game/stores/discipline-slice.tsactivate method, mana drain check
  • src/components/game/tabs/DisciplinesTab.tsxhandleToggle doesn't pass rawMana
  • src/lib/game/utils/discipline-math.tscanProceedDiscipline checks mana

Fix needed: Pass rawMana from DisciplinesTab.tsx into the gameState parameter of activate().

AGENTS.md rules: All fixes must keep files under 400 lines.

**Description:** After deactivating a discipline, clicking "Start Practicing" does not re-activate the discipline. The button changes but the discipline remains paused/inactive. **Root Cause:** The `activate` method in `discipline-slice.ts` has a guard in `canProceedDiscipline()` that checks if the player has sufficient mana to cover the discipline's drain: ```ts // discipline-slice.ts activate(): if (!canProceedDiscipline(def, existing, gameState)) return s; ``` When re-activating a discipline with `gameState.elements` but **no `rawMana`** property (which is the case from `DisciplinesTab.tsx` — only `elements` and `signedPacts` are passed), `canProceedDiscipline` checks `gameState.rawMana` which is `undefined`, fails the drain check, and silently returns without activating. From `DisciplinesTab.tsx`: ```ts const handleToggle = useCallback((id: string, paused: boolean) => { if (paused) { activate(id, { elements, signedPacts }); // <-- NO rawMana passed! } else { deactivate(id); } }, [activate, deactivate, rawMana, elements, signedPacts]); ``` The `rawMana` variable is available in scope but NOT passed in the `gameState` object. This is a mismatch — the `activate` method needs `rawMana` for raw-type disciplines, but the UI doesn't pass it. **Files involved:** - `src/lib/game/stores/discipline-slice.ts` — `activate` method, mana drain check - `src/components/game/tabs/DisciplinesTab.tsx` — `handleToggle` doesn't pass `rawMana` - `src/lib/game/utils/discipline-math.ts` — `canProceedDiscipline` checks mana **Fix needed:** Pass `rawMana` from `DisciplinesTab.tsx` into the `gameState` parameter of `activate()`. **AGENTS.md rules:** All fixes must keep files under 400 lines.
Anexim added the ai:todo label 2026-05-31 10:17:52 +02:00
n8n-gitea was assigned by Anexim 2026-05-31 10:17:52 +02:00
Author
Owner

Starting work on the discipline re-activation fix. The issue is that DisciplinesTab.tsx doesn't pass rawMana to the activate() call.

Starting work on the discipline re-activation fix. The issue is that DisciplinesTab.tsx doesn't pass rawMana to the activate() call.
Author
Owner

Fixed discipline re-activation by passing rawMana in the gameState object to activate() in DisciplinesTab.tsx. Changed activate(id, { elements, signedPacts }) to activate(id, { elements, signedPacts, rawMana }). All 70 discipline tests pass.

Fixed discipline re-activation by passing rawMana in the gameState object to activate() in DisciplinesTab.tsx. Changed `activate(id, { elements, signedPacts })` to `activate(id, { elements, signedPacts, rawMana })`. All 70 discipline tests pass.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#230