Bug: totalManaGathered inflates by counting mana at cap and double-counting combat loot #224

Closed
opened 2026-05-30 21:10:34 +02:00 by Anexim · 1 comment
Owner

Bug Description

totalManaGathered (used in the insight formula as totalManaGathered / 500) is inflated in two ways:

  1. Counts uncapped amounts: Both addRawMana and gatherMana in manaStore.ts always add the full amount to totalManaGathered, even when rawMana is already at maxMana and the actual mana added is 0 (capped).

  2. Double-counts combat loot: Combat tick processing may call paths that increment totalManaGathered both in the combat store result AND in the mana store's addRawMana/gatherMana.

Code Location

src/lib/game/stores/manaStore.ts lines 96-100:

addRawMana: (amount: number, maxMana: number) => {
  set((state) => ({
    rawMana: Math.min(state.rawMana + amount, maxMana),
    totalManaGathered: state.totalManaGathered + amount,  // Always adds full amount
  }));
},

Impact

Medium. totalManaGathered is a prestige-progress stat. Inflating it means players get more insight per loop than intended, accelerating prestige progression. Players who frequently "gather" while at max mana (common during meditation) get a particularly large inflation.

Fix Required

In addRawMana and gatherMana, count only the actually added mana:

const actualAdded = Math.min(state.rawMana + amount, maxMana) - state.rawMana;
totalManaGathered: state.totalManaGathered + actualAdded,
## Bug Description `totalManaGathered` (used in the insight formula as `totalManaGathered / 500`) is inflated in two ways: 1. **Counts uncapped amounts**: Both `addRawMana` and `gatherMana` in `manaStore.ts` always add the full `amount` to `totalManaGathered`, even when `rawMana` is already at `maxMana` and the actual mana added is 0 (capped). 2. **Double-counts combat loot**: Combat tick processing may call paths that increment `totalManaGathered` both in the combat store result AND in the mana store's `addRawMana`/`gatherMana`. ## Code Location `src/lib/game/stores/manaStore.ts` lines 96-100: ```typescript addRawMana: (amount: number, maxMana: number) => { set((state) => ({ rawMana: Math.min(state.rawMana + amount, maxMana), totalManaGathered: state.totalManaGathered + amount, // Always adds full amount })); }, ``` ## Impact **Medium.** `totalManaGathered` is a prestige-progress stat. Inflating it means players get more insight per loop than intended, accelerating prestige progression. Players who frequently "gather" while at max mana (common during meditation) get a particularly large inflation. ## Fix Required In `addRawMana` and `gatherMana`, count only the **actually added** mana: ```typescript const actualAdded = Math.min(state.rawMana + amount, maxMana) - state.rawMana; totalManaGathered: state.totalManaGathered + actualAdded, ```
Anexim added the ai:todo label 2026-05-30 21:10:34 +02:00
n8n-gitea was assigned by Anexim 2026-05-30 21:10:34 +02:00
Author
Owner

Fixed as part of #217: totalManaGathered now only counts regen that actually fits below the mana cap.

Fixed as part of #217: totalManaGathered now only counts regen that actually fits below the mana cap.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#224