[Critical] [Bug] All 22 mana types auto-unlocked on first tick via conversion system #377
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?
Bug Summary
All 22 mana types (including exotic elements like Crystal, Stellar, Void, Soul, Time, Plasma) are unlocked from the very first tick, bypassing the intended guardian pact unlock progression.
Expected Behavior
Only Transference should be unlocked at game start (
BASE_UNLOCKED_ELEMENTS = ['transference']). All other mana types should be unlocked through:Root Cause
Two lines in
src/lib/game/stores/gameStore.tsunconditionally auto-unlock any element that has a non-zero net conversion rate:if (!elements[elem].unlocked) elements[elem] = { ...elements[elem], unlocked: true };These lines reside inside loops iterating over
conversionResult.rates(all 22 elements). On the first tick, the Enchanter attunement (active at level 1) provides conversion rate bonuses for transference-containing elements (soul, plasma, time), causing them to get non-zero rates and be auto-unlocked. This creates a cascade that unlocks all 22 elements within the first few ticks.Severity
Critical — Completely breaks the core progression loop. The guardian pact system (the intended unlock mechanism) is bypassed entirely.
Fix Direction
Remove the auto-unlock lines at gameStore.ts:211 and :324. The conversion system should only apply mana deltas to elements that are already unlocked. If
elements[elem].unlockedis false, skip that element.Files Involved
src/lib/game/stores/gameStore.tssrc/lib/game/constants/elements.tsBASE_UNLOCKED_ELEMENTS = ['transference']src/lib/game/stores/manaStore.tsBASE_UNLOCKED_ELEMENTSFix Applied
Root cause: Two lines in
gameStore.tsunconditionally auto-unlocked any element with a non-zero conversion rate:// Apply net element regen to pools)On the first tick, the Enchanter attunement (active at level 1) provides conversion rate bonuses for transference-containing elements (soul, plasma, time), causing them to get non-zero rates and be auto-unlocked. This cascaded to unlock all 22 elements within the first few ticks.
Fix: Replaced both
if (!elements[elem].unlocked) elements[elem] = { ...elements[elem], unlocked: true };lines with a guard that skips locked elements entirely:if (entry.paused || !elements[elem] || !elements[elem].unlocked) continue;Regression test: Added
bug-377-mana-auto-unlock.test.tswith 4 tests:Verification: All 73 test files (1186 tests) pass. The regression test was confirmed to FAIL on the unfixed code and PASS on the fixed code.
Files changed:
src/lib/game/stores/gameStore.ts— removed 2 auto-unlock lines, added unlocked guardssrc/lib/game/__tests__/bug-377-mana-auto-unlock.test.ts— new regression test