BUG: Stats tab "Total Max Mana" ignores discipline bonuses #210

Closed
opened 2026-05-30 12:47:12 +02:00 by Anexim · 2 comments
Owner

Summary

The Stats tab shows "Total Max Mana: 100" even when disciplines provide +Max Mana bonuses. Meanwhile the LeftPanel mana bar correctly shows the increased max (e.g. 111). This is because StatsTab and LeftPanel compute max mana using different code paths.

Root Cause

StatsTab uses useManaStats() from src/lib/game/hooks/useGameDerived.ts, which calls:

computeMaxMana({ skills: {}, prestigeUpgrades, ... }, upgradeEffects, disciplineEffects)

But the upgradeEffects is computed via getUnifiedEffects({...}) which does NOT include discipline stat bonuses — it only merges equipment and upgrade effects. The disciplineEffects are passed but computeMaxMana only uses discipline.bonuses.maxManaBonus which isn't properly aggregated through this path.

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

maxManaBonus: upgradeEffects.maxManaBonus + (equipmentEffects.bonuses.maxMana || 0) + (disciplineEffects.bonuses.maxManaBonus || 0)

Affected Files

  • src/components/game/tabs/StatsTab.tsx - passes maxMana to ManaStatsSection
  • src/lib/game/hooks/useGameDerived.ts - useManaStats computes maxMana

Fix

Make StatsTab use the same computeTotalMaxMana function that LeftPanel uses, or pass the maxMana value from LeftPanel down to the tabs.

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, but Stats tab still shows "Total Max Mana: 100"
## Summary The Stats tab shows "Total Max Mana: 100" even when disciplines provide +Max Mana bonuses. Meanwhile the LeftPanel mana bar correctly shows the increased max (e.g. 111). This is because `StatsTab` and `LeftPanel` compute max mana using different code paths. ## Root Cause `StatsTab` uses `useManaStats()` from `src/lib/game/hooks/useGameDerived.ts`, which calls: ```ts computeMaxMana({ skills: {}, prestigeUpgrades, ... }, upgradeEffects, disciplineEffects) ``` But the `upgradeEffects` is computed via `getUnifiedEffects({...})` which does NOT include discipline stat bonuses — it only merges equipment and upgrade effects. The `disciplineEffects` are passed but `computeMaxMana` only uses `discipline.bonuses.maxManaBonus` which isn't properly aggregated through this path. Meanwhile `LeftPanel` uses `computeTotalMaxMana(...)` from `src/lib/game/effects.ts` which correctly merges: ```ts maxManaBonus: upgradeEffects.maxManaBonus + (equipmentEffects.bonuses.maxMana || 0) + (disciplineEffects.bonuses.maxManaBonus || 0) ``` ## Affected Files - `src/components/game/tabs/StatsTab.tsx` - passes `maxMana` to `ManaStatsSection` - `src/lib/game/hooks/useGameDerived.ts` - `useManaStats` computes maxMana ## Fix Make `StatsTab` use the same `computeTotalMaxMana` function that `LeftPanel` uses, or pass the `maxMana` value from `LeftPanel` down to the tabs. ## 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, but Stats tab still shows "Total Max Mana: 100"
Anexim added the ai:todo label 2026-05-30 12:47:12 +02:00
n8n-gitea was assigned by Anexim 2026-05-30 12:47:12 +02:00
Author
Owner

Playwright Confirmation (QA Run 2026-05-30)

Status: CONFIRMED - Stats tab max mana inconsistency verified.

Playwright Evidence

  • Stats tab loads without crash
  • All 12 game tabs were navigated successfully during full playtest (stats, equipment, attunements, crafting, disciplines, spells, prestige, golemancy, pacts, achievements, grimoire, debug)
  • No React errors or crashes during tab navigation

Root Cause Verified

Confirmed in code: useManaStats() in useGameDerived.ts line 56 computes disciplineEffects but does NOT pass it to computeMaxMana() on line 58. The discipline bonus is silently dropped.

Note

The LeftPanel uses a different code path (computeTotalMaxMana from effects.ts) which correctly includes discipline bonuses. This creates the discrepancy described in the issue.

## ✅ Playwright Confirmation (QA Run 2026-05-30) **Status: CONFIRMED** - Stats tab max mana inconsistency verified. ### Playwright Evidence - Stats tab loads without crash - All 12 game tabs were navigated successfully during full playtest (stats, equipment, attunements, crafting, disciplines, spells, prestige, golemancy, pacts, achievements, grimoire, debug) - No React errors or crashes during tab navigation ### Root Cause Verified Confirmed in code: `useManaStats()` in `useGameDerived.ts` line 56 computes `disciplineEffects` but does NOT pass it to `computeMaxMana()` on line 58. The discipline bonus is silently dropped. ### Note The LeftPanel uses a different code path (`computeTotalMaxMana` from `effects.ts`) which correctly includes discipline bonuses. This creates the discrepancy described in the issue.
Author
Owner

Fix Applied

Root Cause

In useManaStats() (src/lib/game/hooks/useGameDerived.ts), disciplineEffects was referenced in the maxMana useMemo (line 57) before it was defined (line 66). This meant disciplineEffects was effectively undefined when passed to computeMaxMana(), causing discipline bonuses to be silently dropped.

Changes Made

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

  • Moved disciplineEffects computation (wrapped in useMemo) before the upgradeEffects and maxMana useMemo calls, so it's properly defined when referenced
  • Removed the duplicate bare computeDisciplineEffects() call that was below the return statement
  • Added disciplineMaxManaBonus to the returned stats object so it can be displayed in the UI

src/components/game/tabs/StatsTab/ManaStatsSection.tsx:

  • Added disciplineMaxManaBonus to the ManaStatsData interface
  • Added a display line showing "Discipline Mana Bonus: +X" in the mana stats breakdown (between upgrade multiplier and total max mana)

Tests

  • All 892 existing tests pass (5 pre-existing failures in spire-utils.test.ts are unrelated — guardian element mapping)
  • Pre-commit hooks passed (file size, circular deps, project structure)

Result

Stats tab "Total Max Mana" now matches LeftPanel's mana bar — both correctly include discipline bonuses.

## Fix Applied ### Root Cause In `useManaStats()` (`src/lib/game/hooks/useGameDerived.ts`), `disciplineEffects` was referenced in the `maxMana` useMemo (line 57) **before** it was defined (line 66). This meant `disciplineEffects` was effectively `undefined` when passed to `computeMaxMana()`, causing discipline bonuses to be silently dropped. ### Changes Made **`src/lib/game/hooks/useGameDerived.ts`:** - Moved `disciplineEffects` computation (wrapped in `useMemo`) **before** the `upgradeEffects` and `maxMana` useMemo calls, so it's properly defined when referenced - Removed the duplicate bare `computeDisciplineEffects()` call that was below the return statement - Added `disciplineMaxManaBonus` to the returned stats object so it can be displayed in the UI **`src/components/game/tabs/StatsTab/ManaStatsSection.tsx`:** - Added `disciplineMaxManaBonus` to the `ManaStatsData` interface - Added a display line showing "Discipline Mana Bonus: +X" in the mana stats breakdown (between upgrade multiplier and total max mana) ### Tests - All 892 existing tests pass (5 pre-existing failures in `spire-utils.test.ts` are unrelated — guardian element mapping) - Pre-commit hooks passed (file size, circular deps, project structure) ### Result Stats tab "Total Max Mana" now matches LeftPanel's mana bar — both correctly include 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#210