BUG: useManaStats in Stats tab ignores discipline maxManaBonus (Stats shows wrong Total Max Mana) #213

Closed
opened 2026-05-30 14:56:52 +02:00 by Anexim · 3 comments
Owner

Summary

The Stats tab displays "Total Max Mana" without including discipline bonuses, while the LeftPanel mana bar correctly shows the increased max. This is because useManaStats() computes maxMana without passing disciplineEffects to computeMaxMana().

Root Cause

In src/lib/game/hooks/useGameDerived.ts:

// Line 56: disciplineEffects IS computed
const disciplineEffects = computeDisciplineEffects();

// Line 57-59: but NOT passed to computeMaxMana
const maxMana = useMemo(
  () => computeMaxMana({ prestigeUpgrades }, upgradeEffects),
  [prestigeUpgrades, upgradeEffects]
);

Meanwhile computeMaxMana in src/lib/game/utils/mana-utils.ts:40-51 accepts a third discipline parameter:

export function computeMaxMana(
  state: Partial<ManaComputeParams>,
  effects?: ComputedEffects,
  discipline?: DisciplineBonuses,
): number {
  const base = 100 + (pu.manaWell || 0) * 500 + (discipline?.bonuses?.maxManaBonus || 0);

The disciplineEffects are computed on line 56 but never used in the computeMaxMana call.

Meanwhile LeftPanel.tsx uses computeTotalMaxMana() from src/lib/game/effects.ts which correctly merges discipline bonuses.

Fix

Change useGameDerived.ts lines 57-59 from:

const maxMana = useMemo(
  () => computeMaxMana({ prestigeUpgrades }, upgradeEffects),
  [prestigeUpgrades, upgradeEffects]
);

To:

const maxMana = useMemo(
  () => computeMaxMana({ prestigeUpgrades }, upgradeEffects, disciplineEffects),
  [prestigeUpgrades, upgradeEffects, disciplineEffects]
);

Reproduction

  1. Start a new game
  2. Activate "Raw Mana Mastery" discipline
  3. Gather XP (~65 XP gives +11.86 Max Mana)
  4. Observe LeftPanel shows mana bar up to ~111
  5. Observe Stats tab still shows "Total Max Mana: 100"

Severity

Medium - Stats display inconsistency. The actual mana cap may be correct (via LeftPanel path) but the Stats tab shows wrong information.

Note

This bug shares the same root file (useGameDerived.ts) as issue #212 (meditation bonus bug). Both can be fixed in the same PR.

## Summary The Stats tab displays "Total Max Mana" without including discipline bonuses, while the LeftPanel mana bar correctly shows the increased max. This is because `useManaStats()` computes `maxMana` without passing `disciplineEffects` to `computeMaxMana()`. ## Root Cause In `src/lib/game/hooks/useGameDerived.ts`: ```ts // Line 56: disciplineEffects IS computed const disciplineEffects = computeDisciplineEffects(); // Line 57-59: but NOT passed to computeMaxMana const maxMana = useMemo( () => computeMaxMana({ prestigeUpgrades }, upgradeEffects), [prestigeUpgrades, upgradeEffects] ); ``` Meanwhile `computeMaxMana` in `src/lib/game/utils/mana-utils.ts:40-51` accepts a third `discipline` parameter: ```ts export function computeMaxMana( state: Partial<ManaComputeParams>, effects?: ComputedEffects, discipline?: DisciplineBonuses, ): number { const base = 100 + (pu.manaWell || 0) * 500 + (discipline?.bonuses?.maxManaBonus || 0); ``` The `disciplineEffects` are computed on line 56 but never used in the `computeMaxMana` call. Meanwhile `LeftPanel.tsx` uses `computeTotalMaxMana()` from `src/lib/game/effects.ts` which correctly merges discipline bonuses. ## Fix Change `useGameDerived.ts` lines 57-59 from: ```ts const maxMana = useMemo( () => computeMaxMana({ prestigeUpgrades }, upgradeEffects), [prestigeUpgrades, upgradeEffects] ); ``` To: ```ts const maxMana = useMemo( () => computeMaxMana({ prestigeUpgrades }, upgradeEffects, disciplineEffects), [prestigeUpgrades, upgradeEffects, disciplineEffects] ); ``` ## Reproduction 1. Start a new game 2. Activate "Raw Mana Mastery" discipline 3. Gather XP (~65 XP gives +11.86 Max Mana) 4. Observe LeftPanel shows mana bar up to ~111 5. Observe Stats tab still shows "Total Max Mana: 100" ## Severity **Medium** - Stats display inconsistency. The actual mana cap may be correct (via LeftPanel path) but the Stats tab shows wrong information. ## Note This bug shares the same root file (`useGameDerived.ts`) as issue #212 (meditation bonus bug). Both can be fixed in the same PR.
Anexim added the ai:todo label 2026-05-30 14:56:52 +02:00
n8n-gitea was assigned by Anexim 2026-05-30 14:56:52 +02:00
Author
Owner

Playwright Test Ref

The Playwright test e2e/playtest.spec.ts2 - Stats Tab → KNOWN BUG #210 navigates to Stats and checks for "Total Max Mana" text. After the fix, the Stats tab should show discipline-included max mana.

A future enhancement to the Playwright test could verify that the Stats tab max mana matches the LeftPanel max mana value (currently they diverge when disciplines are active).

## Playwright Test Ref The Playwright test `e2e/playtest.spec.ts` → `2 - Stats Tab → KNOWN BUG #210` navigates to Stats and checks for "Total Max Mana" text. After the fix, the Stats tab should show discipline-included max mana. A future enhancement to the Playwright test could verify that the Stats tab max mana matches the LeftPanel max mana value (currently they diverge when disciplines are active).
Author
Owner

Fix Applied

Fixed useGameDerived.ts to pass disciplineEffects to computeMaxMana():

// Before:
const maxMana = useMemo(
  () => computeMaxMana({ prestigeUpgrades }, upgradeEffects),
  [prestigeUpgrades, upgradeEffects]
);

// After:
const maxMana = useMemo(
  () => computeMaxMana({ prestigeUpgrades }, upgradeEffects, disciplineEffects),
  [prestigeUpgrades, upgradeEffects, disciplineEffects]
);

The Stats tab "Total Max Mana" will now correctly include discipline bonuses (e.g., Raw Mana Mastery's maxManaBonus), matching the LeftPanel mana bar display.

Build: passing

## ✅ Fix Applied Fixed `useGameDerived.ts` to pass `disciplineEffects` to `computeMaxMana()`: ```ts // Before: const maxMana = useMemo( () => computeMaxMana({ prestigeUpgrades }, upgradeEffects), [prestigeUpgrades, upgradeEffects] ); // After: const maxMana = useMemo( () => computeMaxMana({ prestigeUpgrades }, upgradeEffects, disciplineEffects), [prestigeUpgrades, upgradeEffects, disciplineEffects] ); ``` The Stats tab "Total Max Mana" will now correctly include discipline bonuses (e.g., Raw Mana Mastery's maxManaBonus), matching the LeftPanel mana bar display. Build: ✅ passing
Author
Owner

Fixed — disciplineEffects now passed to computeMaxMana in useGameDerived.ts. Stats tab will now show correct Total Max Mana including discipline bonuses.

Fixed — disciplineEffects now passed to computeMaxMana in useGameDerived.ts. Stats tab will now show correct Total Max Mana including discipline bonuses.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#213