BUG: Raw mana exceeds max cap after discipline bonuses applied #246

Closed
opened 2026-06-01 10:48:47 +02:00 by Anexim · 1 comment
Owner

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

  1. Activate Raw Mana Mastery discipline (gives +11.86 Max Mana at 65 XP)
  2. Let mana regen to max
  3. Observe: mana shows 111/111 which is correct
  4. But during tick processing, regen is applied BEFORE discipline bonuses are computed, potentially causing temporary overflow

Root Cause

In gameStore.ts tick() function:

  1. maxMana is computed once at the top of the tick
  2. rawMana is clamped to maxMana after regen
  3. But discipline effects that increase maxMana are applied AFTER the clamp
  4. This means the clamp uses a stale maxMana value

Impact

  • Minor: mana display shows correct value but internal computation may have brief inconsistencies
  • Could cause issues with mana-dependent calculations during the tick

Files Involved

  • src/lib/game/stores/gameStore.ts — tick() function mana clamping logic
## 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 1. Activate Raw Mana Mastery discipline (gives +11.86 Max Mana at 65 XP) 2. Let mana regen to max 3. Observe: mana shows 111/111 which is correct 4. But during tick processing, regen is applied BEFORE discipline bonuses are computed, potentially causing temporary overflow ## Root Cause In `gameStore.ts` tick() function: 1. `maxMana` is computed once at the top of the tick 2. `rawMana` is clamped to `maxMana` after regen 3. But discipline effects that increase `maxMana` are applied AFTER the clamp 4. This means the clamp uses a stale `maxMana` value ## Impact - Minor: mana display shows correct value but internal computation may have brief inconsistencies - Could cause issues with mana-dependent calculations during the tick ## Files Involved - `src/lib/game/stores/gameStore.ts` — tick() function mana clamping logic
Anexim added the ai:todo label 2026-06-01 10:48:47 +02:00
n8n-gitea was assigned by Anexim 2026-06-01 10:48:47 +02:00
Anexim added this to the (deleted) project 2026-06-01 11:45:48 +02:00
Author
Owner

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.

✅ 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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#246