🔴 DisciplinesTab: canProceedDiscipline called with wrong arguments #52

Closed
opened 2026-05-18 17:06:36 +02:00 by Anexim · 2 comments
Owner

File: src/lib/game/stores/discipline-slice.ts, line 61

if (!canProceedDiscipline(id, gameState)) return s;

The function canProceedDiscipline in src/lib/game/utils/discipline-math.ts (line 65) expects 3 arguments:

canProceedDiscipline(
  discipline: DisciplineDefinition,
  disciplineState: DisciplineState,
  gameState: { elements?: Record<string, any>; rawMana?: number }
)

But the store call passes only 2 arguments (id: string and gameState), passing a string where a DisciplineDefinition object is expected, and omitting the disciplineState parameter entirely.

Impact: Runtime crash — discipline.manaType will fail on a string value. Discipline activation will never work correctly.

Fix: Look up the discipline definition and state before calling:

const def = DISCIPLINE_MAP[id];
const discState = s.disciplines[id];
if (!canProceedDiscipline(def, discState, gameState)) return s;
**File:** `src/lib/game/stores/discipline-slice.ts`, line 61 ```ts if (!canProceedDiscipline(id, gameState)) return s; ``` The function `canProceedDiscipline` in `src/lib/game/utils/discipline-math.ts` (line 65) expects **3 arguments**: ```ts canProceedDiscipline( discipline: DisciplineDefinition, disciplineState: DisciplineState, gameState: { elements?: Record<string, any>; rawMana?: number } ) ``` But the store call passes only **2 arguments** (`id: string` and `gameState`), passing a string where a `DisciplineDefinition` object is expected, and omitting the `disciplineState` parameter entirely. **Impact:** Runtime crash — `discipline.manaType` will fail on a string value. Discipline activation will never work correctly. **Fix:** Look up the discipline definition and state before calling: ```ts const def = DISCIPLINE_MAP[id]; const discState = s.disciplines[id]; if (!canProceedDiscipline(def, discState, gameState)) return s; ```
Anexim added the ai:todo label 2026-05-18 17:06:36 +02:00
n8n-gitea was assigned by Anexim 2026-05-18 17:06:36 +02:00
Author
Owner

[priority: 5] CRASH/BLOCKER — canProceedDiscipline called with wrong arguments, crashes DisciplinesTab.

[priority: 5] CRASH/BLOCKER — canProceedDiscipline called with wrong arguments, crashes DisciplinesTab.
Author
Owner

Fixed: In discipline-slice.ts activate(), now correctly looks up discState = s.disciplines[id] and passes (def, discState, gameState) to canProceedDiscipline() instead of (id, gameState).

Fixed: In discipline-slice.ts `activate()`, now correctly looks up `discState = s.disciplines[id]` and passes `(def, discState, gameState)` to `canProceedDiscipline()` instead of `(id, gameState)`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#52