[priority: high] Elemental Mana Capacity disciplines don't increase element capacity / show NaN #185
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: Elemental capacity disciplines show NaN and don't actually increase capacity
Description
Stat Bonus: NaN/sec on Earth Mana Capacity(NaN/sec with perks)instead of a meaningful valueRoot Cause Analysis
Part 1 — NaN display: The stat bonus key is
elementCap_earth(dynamic key generated inelemental.tsline 38):The UI in
DisciplinesTab.tsxdisplays this as{activeStatBonus.toFixed(2)}/sec on {statBonusLabel}. The/secsuffix is wrong for capacity (it's a flat bonus), and NaN can occur ifcalculateStatBonusreceives unexpected inputs.Part 2 — Effect not applied: In
discipline-effects.ts, thecomputeDisciplineEffects()function collects bonuses into abonusesrecord. The keyelementCap_earthgets collected. Then ineffects.ts→computeAllEffects(), there's code that specifically handleselementCap_prefix keys:However, the INITIAL value of
perElementCapBonuscomes fromupgradeEffects.perElementCapBonuswhich only has keys fromupgradesEffectsin the prestige store. The discipline bonuses ARE being added. So the effect IS being computed.But — in
SpireCombatPage.tsx, theuseSpireStatshook callsgetUnifiedEffects()but passes{ skillUpgrades: {}, skillTiers: {}, equippedInstances, equipmentInstances }— nodisciplineEffects. ThecomputeAllEffectsfunction internally callscomputeDisciplineEffects(), so discipline effects should still be picked up.However, the main game tick in
gameStore.tsDOES use discipline effects properly. The issue might be that:elementCap_stat keys are not in theKNOWN_BONUS_STATSset indiscipline-effects.ts— but that set is only used for perk routing, not for the main bonus applicationPart 3 — Actual capacity not increasing: Need to verify that
perElementCapBonusis actually used in the mana capacity calculation. ThemanaStore.tselement max is set inresetManaandsetElementMax. Check if discipline effects are applied to element max during gameplay ticks.Affected Files
src/lib/game/data/disciplines/elemental.ts— capacity discipline definitionssrc/lib/game/effects/discipline-effects.ts— effect computationsrc/lib/game/effects.ts—computeAllEffectsmergingsrc/components/game/tabs/DisciplinesTab.tsx— displaysrc/lib/game/stores/manaStore.ts— element max applicationSteps to Reproduce
Expected Behavior
Suggested Fix Direction
/secsuffixelementCap_discipline bonuses are applied to element max values during gameplayStarting investigation of Elemental Mana Capacity disciplines NaN bug. Will examine all affected files and implement fix.
Fix Summary for Issue #185
Root Cause
Elemental Mana Capacity disciplines (e.g. "Earth Mana Capacity") computed their stat bonuses correctly in
discipline-effects.tsandcomputeAllEffects(), but the computedperElementCapBonuswas never actually applied to any element's max capacity during the game tick. The bonuses existed in the unified effects system but were never written back to actual element state.Changes Made
1. Added
baseMaxfield toElementState(src/lib/game/types/elements.ts)baseMaxfield tracks the prestige-derived element max (fromelementalAttuneupgrade)undefinedfalls back tomaxfor backward compatibility with existing code2. Added
computeElementMaxWithBonusesto manaStore (src/lib/game/stores/manaStore.ts)baseMax + per-element bonus3. Applied per-element cap bonuses in game tick (
src/lib/game/stores/gameStore.ts)elementCap_*keys from bothcomputeElementMaxWithBonuseson mana store4. Fixed
resetManaprestige key (src/lib/game/stores/manaStore.ts)prestigeUpgrades.elemMax(nonexistent key, always 0) toprestigeUpgrades.elementalAttune(correct key)×5to×25matching the prestige definitionbaseMaxto persisted state5. Fixed test files to include
baseMaxin element literalsdiscipline-reactivate-bug.test.tsstore-actions-discipline.test.ts6. Fixed type annotation in
crafting-fabricator.tsto use importedElementStatetypeTest Results
All 917 tests pass (48 test files).
Files Changed
src/lib/game/types/elements.ts— Added optionalbaseMaxfieldsrc/lib/game/stores/manaStore.ts— AddedcomputeElementMaxWithBonuses, fixed prestige key, added migrationsrc/lib/game/stores/gameStore.ts— Applied per-element cap bonuses in ticksrc/lib/game/__tests__/discipline-reactivate-bug.test.ts— AddedbaseMaxto test elementssrc/lib/game/__tests__/store-actions-discipline.test.ts— AddedbaseMaxto test elementssrc/lib/game/crafting-fabricator.ts— Used importedElementStatetypeFixed and pushed in commit
6355cf3.Summary
Root cause: Elemental Mana Capacity disciplines computed stat bonuses correctly into
perElementCapBonusviacomputeAllEffects(), but this was never written back to actual elementmaxvalues. The bonus existed in the effects system but had no effect on gameplay.Fix:
baseMaxfield toElementStateto track prestige-derived capacity separately from discipline/equipment bonuses (prevents double-counting on ticks)computeElementMaxWithBonuses()to mana store — computesmax = baseMax + bonusresetManaprestige key (elementalAttuneinstead of nonexistentelemMax)baseMaxfrom persisted stateAll 916 passing tests continue to pass.