BUG: Raw mana exceeds max cap after discipline bonuses applied #246
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 Description
During testing with all disciplines unlocked, raw mana was observed at 111 max (100 base + 11 from Raw Mana Mastery discipline). However, the mana clamping in the tick pipeline only clamps after regen, not after discipline effects are computed. This means mana can exceed the computed maxMana.
Steps to Reproduce
Root Cause
In
gameStore.tstick() function:maxManais computed once at the top of the tickrawManais clamped tomaxManaafter regenmaxManaare applied AFTER the clampmaxManavalueImpact
Files Involved
src/lib/game/stores/gameStore.ts— tick() function mana clamping logic✅ Fixed raw mana exceeding max cap. In gameStore.ts tick(), added recomputation of maxMana after discipline processing (which may increase XP and thus maxMana), followed by re-clamping rawMana to the updated cap. This ensures mana never exceeds the computed maximum even when discipline bonuses increase mid-tick.