[priority: high] Unlocking Fabricator starts earth mana conversion but earth mana type stays locked #177
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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:
.unlocked === false)convertMana('earth', ...)fails withELEMENT_NOT_UNLOCKEDprocessConvertAction()skips earth entirelyRoot 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 callsunlockElement('earth', ...)when the Fabricator is activated.The Enchanter attunement avoids this bug because its primary mana type (
transference) is inBASE_UNLOCKED_ELEMENTS. The Fabricator's primary mana type (earth) is NOT pre-unlocked.The debug tools (
AttunementDebugSection.tsxlines 17–21) manually unlock transference when unlocking the Enchanter, but have no equivalent handling for Fabricator → earth.Affected Files
src/lib/game/stores/gameStore.tslines 187–197 — conversion loop missing unlock stepsrc/lib/game/stores/manaStore.tslines 120–127 —unlockElement()function (never called for earth)src/lib/game/stores/manaStore.tsline 21 —BASE_UNLOCKED_ELEMENTS = ['transference'](earth not included)src/components/game/debug/AttunementDebug.tsx— debug unlock missing earth handlingReproduction
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.
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.
Fixed. Three changes:
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.AttunementDebug.tsx — Replaced the hardcoded
if (id === 'enchanter')block with a generic lookup: any attunement with aprimaryManaTypenow unlocks its element (cost 0) when debug-unlocked.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.