[priority: high] Unlocking Fabricator starts earth mana conversion but earth mana type stays locked #177

Closed
opened 2026-05-28 11:39:12 +02:00 by Anexim · 2 comments
Owner

Description

When the Fabricator attunement is unlocked and activated, it begins converting raw mana into earth mana (visible in the mana pool), but the earth mana type itself never gets formally "unlocked". This causes:

  1. Earth mana UI elements remain hidden (filtered by .unlocked === false)
  2. Manual conversion to earth via convertMana('earth', ...) fails with ELEMENT_NOT_UNLOCKED
  3. processConvertAction() skips earth entirely

Root Cause

The tick pipeline in src/lib/game/stores/gameStore.ts (lines 187–197) iterates over active attunements and adds mana to element pools, but the guard at line 191 only checks that the element exists in the record (if (elements[def.primaryManaType])), NOT that the element is unlocked (elements[def.primaryManaType].unlocked). No code ever calls unlockElement('earth', ...) when the Fabricator is activated.

The Enchanter attunement avoids this bug because its primary mana type (transference) is in BASE_UNLOCKED_ELEMENTS. The Fabricator's primary mana type (earth) is NOT pre-unlocked.

The debug tools (AttunementDebugSection.tsx lines 17–21) manually unlock transference when unlocking the Enchanter, but have no equivalent handling for Fabricator → earth.

Affected Files

  • src/lib/game/stores/gameStore.ts lines 187–197 — conversion loop missing unlock step
  • src/lib/game/stores/manaStore.ts lines 120–127 — unlockElement() function (never called for earth)
  • src/lib/game/stores/manaStore.ts line 21 — BASE_UNLOCKED_ELEMENTS = ['transference'] (earth not included)
  • src/components/game/debug/AttunementDebug.tsx — debug unlock missing earth handling

Reproduction

  1. Unlock Fabricator attunement
  2. Activate it
  3. Wait for ticks to pass — earth mana accumulates
  4. Try to use earth mana — it's still locked
  5. Try manual conversion to earth — fails

Expected Behavior

Activating the Fabricator should auto-unlock the earth mana type (cost 0), similar to how the debug tools unlock transference for the Enchanter.

## Description When the Fabricator attunement is unlocked and activated, it begins converting raw mana into earth mana (visible in the mana pool), but the earth mana type itself never gets formally "unlocked". This causes: 1. Earth mana UI elements remain hidden (filtered by `.unlocked === false`) 2. Manual conversion to earth via `convertMana('earth', ...)` fails with `ELEMENT_NOT_UNLOCKED` 3. `processConvertAction()` skips earth entirely ## Root Cause The tick pipeline in `src/lib/game/stores/gameStore.ts` (lines 187–197) iterates over active attunements and adds mana to element pools, but the guard at line 191 only checks that the element **exists** in the record (`if (elements[def.primaryManaType])`), NOT that the element is **unlocked** (`elements[def.primaryManaType].unlocked`). No code ever calls `unlockElement('earth', ...)` when the Fabricator is activated. The Enchanter attunement avoids this bug because its primary mana type (`transference`) is in `BASE_UNLOCKED_ELEMENTS`. The Fabricator's primary mana type (`earth`) is NOT pre-unlocked. The debug tools (`AttunementDebugSection.tsx` lines 17–21) manually unlock transference when unlocking the Enchanter, but have **no equivalent handling for Fabricator → earth**. ## Affected Files - `src/lib/game/stores/gameStore.ts` lines 187–197 — conversion loop missing unlock step - `src/lib/game/stores/manaStore.ts` lines 120–127 — `unlockElement()` function (never called for earth) - `src/lib/game/stores/manaStore.ts` line 21 — `BASE_UNLOCKED_ELEMENTS = ['transference']` (earth not included) - `src/components/game/debug/AttunementDebug.tsx` — debug unlock missing earth handling ## Reproduction 1. Unlock Fabricator attunement 2. Activate it 3. Wait for ticks to pass — earth mana accumulates 4. Try to use earth mana — it's still locked 5. Try manual conversion to earth — fails ## Expected Behavior Activating the Fabricator should auto-unlock the earth mana type (cost 0), similar to how the debug tools unlock transference for the Enchanter.
Anexim added the ai:todo label 2026-05-28 11:39:12 +02:00
n8n-gitea was assigned by Anexim 2026-05-28 11:39:12 +02:00
Author
Owner

Starting investigation. The issue is that Fabricator attunement accumulates earth mana but never unlocks the earth element type. Need to auto-unlock elements when their attunement is active, and add Fabricator→earth debug unlock handling.

Starting investigation. The issue is that Fabricator attunement accumulates earth mana but never unlocks the earth element type. Need to auto-unlock elements when their attunement is active, and add Fabricator→earth debug unlock handling.
Author
Owner

Fixed. Three changes:

  1. gameStore.ts — Merged the attunement conversion calculation and application into a single loop. Before adding converted mana to an element pool, the code now auto-unlocks it (unlocked: true) if it wasn't already. This handles Fabricator→earth and any future attunements.

  2. AttunementDebug.tsx — Replaced the hardcoded if (id === 'enchanter') block with a generic lookup: any attunement with a primaryManaType now unlocks its element (cost 0) when debug-unlocked.

  3. gameStore.ts refactoring — Merging the two separate attunement loops (one for total conversion calculation, one for applying to elements) into a single loop eliminated redundant iteration and brought the file from 403 → 393 lines (under the 400-line limit).

All 916 tests pass. Committed and pushed as 268baf3.

Fixed. Three changes: 1. **gameStore.ts** — Merged the attunement conversion calculation and application into a single loop. Before adding converted mana to an element pool, the code now auto-unlocks it (`unlocked: true`) if it wasn't already. This handles Fabricator→earth and any future attunements. 2. **AttunementDebug.tsx** — Replaced the hardcoded `if (id === 'enchanter')` block with a generic lookup: any attunement with a `primaryManaType` now unlocks its element (cost 0) when debug-unlocked. 3. **gameStore.ts refactoring** — Merging the two separate attunement loops (one for total conversion calculation, one for applying to elements) into a single loop eliminated redundant iteration and brought the file from 403 → 393 lines (under the 400-line limit). All 916 tests pass. Committed and pushed as `268baf3`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#177