🐛 TRANSFERENCE MANA FLOW: Discipline always shows as locked despite transference being unlocked at start #169

Closed
opened 2026-05-27 17:28:13 +02:00 by Anexim · 1 comment
Owner

Bug

The "Transference Mana Flow" discipline appears permanently locked even though the player has transference mana unlocked from the start.

Root Cause

checkDisciplinePrerequisites() in src/lib/game/utils/discipline-math.ts:119-155 handles the requires field by searching for a matching discipline ID first, then falling back to treating it as a mana type name. When it encounters 'transference':

  1. It searches ALL_DISCIPLINES for a discipline with id === 'transference' — none exists (the actual ID is 'regen-transference')
  2. It falls to the else branch and unconditionally adds "transference mana" to missingPrereqs
  3. It has no access to the player's element/mana state, so it can never verify that transference is unlocked

Meanwhile, the UI's separate sourceManaTypes check does correctly check elements['transference']?.unlocked and would return no missing mana — but isLocked from checkDisciplinePrerequisites is already true, so effectiveIsLocked is always true.

Fix

checkDisciplinePrerequisites needs to either:

  • Accept the player's elements state as a parameter to verify mana type unlocks
  • Or distinguish between "requires discipline X" and "requires mana type Y" in the requires field and verify accordingly

Files

  • src/lib/game/utils/discipline-math.ts:119-155 (the buggy function)
  • src/lib/game/data/disciplines/elemental-regen.ts:71-96 (discipline definition with requires: ['transference'])
  • src/components/game/tabs/DisciplinesTab.tsx:~263 (uses !prereqCheck.canProceed)
  • src/lib/game/stores/discipline-slice.ts:82 (also calls this function in activate())
## Bug The "Transference Mana Flow" discipline appears permanently locked even though the player has transference mana unlocked from the start. ## Root Cause `checkDisciplinePrerequisites()` in `src/lib/game/utils/discipline-math.ts:119-155` handles the `requires` field by searching for a matching discipline ID first, then falling back to treating it as a mana type name. When it encounters `'transference'`: 1. It searches `ALL_DISCIPLINES` for a discipline with `id === 'transference'` — none exists (the actual ID is `'regen-transference'`) 2. It falls to the `else` branch and **unconditionally** adds `"transference mana"` to `missingPrereqs` 3. It has **no access to the player's element/mana state**, so it can never verify that transference is unlocked Meanwhile, the UI's separate `sourceManaTypes` check **does** correctly check `elements['transference']?.unlocked` and would return no missing mana — but `isLocked` from `checkDisciplinePrerequisites` is already `true`, so `effectiveIsLocked` is always `true`. ## Fix `checkDisciplinePrerequisites` needs to either: - Accept the player's `elements` state as a parameter to verify mana type unlocks - Or distinguish between "requires discipline X" and "requires mana type Y" in the `requires` field and verify accordingly ## Files - `src/lib/game/utils/discipline-math.ts:119-155` (the buggy function) - `src/lib/game/data/disciplines/elemental-regen.ts:71-96` (discipline definition with `requires: ['transference']`) - `src/components/game/tabs/DisciplinesTab.tsx:~263` (uses `!prereqCheck.canProceed`) - `src/lib/game/stores/discipline-slice.ts:82` (also calls this function in `activate()`)
Anexim added the ai:todo label 2026-05-27 17:28:13 +02:00
n8n-gitea was assigned by Anexim 2026-05-27 17:28:13 +02:00
Author
Owner

Fixed in commit 8cebea9. Added elements parameter to checkDisciplinePrerequisites so mana type requirements (like transference) are verified against the player's unlocked elements. Updated callers in DisciplinesTab.tsx and discipline-slice.ts. Added 4 new tests.

Fixed in commit 8cebea9. Added `elements` parameter to `checkDisciplinePrerequisites` so mana type requirements (like `transference`) are verified against the player's unlocked elements. Updated callers in DisciplinesTab.tsx and discipline-slice.ts. Added 4 new tests.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#169