From 4103423b95a5510c833fb2167ef4d0d378f18cb2 Mon Sep 17 00:00:00 2001 From: n8n-gitea Date: Mon, 1 Jun 2026 09:54:01 +0200 Subject: [PATCH] fix: debug panel shows correct max mana using full computeTotalMaxMana - GameStateDebugSection.tsx: use real prestigeUpgrades, equipment, and unified effects instead of empty objects always returning base 100 - GameStateDebug.tsx (legacy): same fix - Both now compute max mana identically to LeftPanel.tsx Fixes #242 (closes incorrect #237 - mana wasn't exceeding cap) --- docs/circular-deps.txt | 2 +- docs/dependency-graph.json | 2 +- src/components/game/debug/GameStateDebug.tsx | 28 +++++++++++-------- .../tabs/DebugTab/GameStateDebugSection.tsx | 28 +++++++++++-------- 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/docs/circular-deps.txt b/docs/circular-deps.txt index 4e4b8a1..dd2bdc0 100644 --- a/docs/circular-deps.txt +++ b/docs/circular-deps.txt @@ -1,4 +1,4 @@ # Circular Dependencies -Generated: 2026-05-31T14:13:00.373Z +Generated: 2026-05-31T18:23:54.984Z No circular dependencies found. ✅ diff --git a/docs/dependency-graph.json b/docs/dependency-graph.json index ae060b4..be0b28c 100644 --- a/docs/dependency-graph.json +++ b/docs/dependency-graph.json @@ -1,6 +1,6 @@ { "_meta": { - "generated": "2026-05-31T14:12:58.516Z", + "generated": "2026-05-31T18:23:53.253Z", "description": "Import dependency graph for src/lib/game. Keys are files, values are arrays of files they import.", "usage": "To find what a file affects, search for its path in the VALUES. To find what a file depends on, look at its KEY entry." }, diff --git a/src/components/game/debug/GameStateDebug.tsx b/src/components/game/debug/GameStateDebug.tsx index 2f1bd43..dbf135c 100644 --- a/src/components/game/debug/GameStateDebug.tsx +++ b/src/components/game/debug/GameStateDebug.tsx @@ -10,8 +10,9 @@ import { RotateCcw, AlertTriangle, Zap, Clock, Settings, Eye, } from 'lucide-react'; import { DebugName, useDebug } from '@/components/game/debug/debug-context'; -import { useGameStore, useManaStore, useUIStore } from '@/lib/game/stores'; -import { computeMaxMana } from '@/lib/game/stores'; +import { useGameStore, useManaStore, useUIStore, usePrestigeStore, useCraftingStore } from '@/lib/game/stores'; +import { computeTotalMaxMana } from '@/lib/game/effects'; +import { getUnifiedEffects } from '@/lib/game/effects'; // ─── Warning Banner ────────────────────────────────────────────────────────── @@ -101,14 +102,12 @@ function GameResetSection({ confirmReset, onReset }: { confirmReset: boolean; on // ─── Mana Debug Section ────────────────────────────────────────────────────── -function ManaDebugSection({ rawMana, onAddMana, onFillMana }: { +function ManaDebugSection({ rawMana, maxMana, onAddMana, onFillMana }: { rawMana: number; + maxMana: number; onAddMana: (amount: number) => void; onFillMana: () => void; }) { - const maxMana = computeMaxMana( - { skills: {}, prestigeUpgrades: {}, skillUpgrades: {}, skillTiers: {} } - ); return ( @@ -228,6 +227,10 @@ export function GameStateDebug() { const togglePause = useUIStore((s) => s.togglePause); const resetGame = useGameStore((s) => s.resetGame); + const prestigeUpgrades = usePrestigeStore((s) => s.prestigeUpgrades); + const equippedInstances = useCraftingStore((s) => s.equippedInstances); + const equipmentInstances = useCraftingStore((s) => s.equipmentInstances); + const handleReset = () => { if (confirmReset) { @@ -245,11 +248,14 @@ export function GameStateDebug() { } }; + const upgradeEffects = getUnifiedEffects({ skillUpgrades: {}, skillTiers: {}, equippedInstances, equipmentInstances }); + const computedMaxMana = computeTotalMaxMana( + { skills: {}, prestigeUpgrades, skillUpgrades: {}, skillTiers: {}, equippedInstances, equipmentInstances }, + upgradeEffects + ); + const handleFillMana = () => { - const maxMana = computeMaxMana( - { skills: {}, prestigeUpgrades: {}, skillUpgrades: {}, skillTiers: {} } - ) || 100; - useManaStore.setState((s) => ({ rawMana: Math.max(s.rawMana, maxMana) })); + useManaStore.setState((s) => ({ rawMana: Math.max(s.rawMana, computedMaxMana) })); }; const handleSetDay = (d: number) => { @@ -280,7 +286,7 @@ export function GameStateDebug() {
- + void; onFillMana: () => void; }) { - const maxMana = computeMaxMana( - { skills: {}, prestigeUpgrades: {}, skillUpgrades: {}, skillTiers: {} } - ); return ( @@ -204,6 +203,10 @@ export function GameStateDebugSection() { const resetGame = useGameStore((s) => s.resetGame); const gatherMana = useGameStore((s) => s.gatherMana); + const prestigeUpgrades = usePrestigeStore((s) => s.prestigeUpgrades); + const equippedInstances = useCraftingStore((s) => s.equippedInstances); + const equipmentInstances = useCraftingStore((s) => s.equipmentInstances); + const elements = useManaStore((s) => s.elements); const unlockElement = useManaStore((s) => s.unlockElement); @@ -223,11 +226,14 @@ export function GameStateDebugSection() { } }; + const upgradeEffects = getUnifiedEffects({ skillUpgrades: {}, skillTiers: {}, equippedInstances, equipmentInstances }); + const computedMaxMana = computeTotalMaxMana( + { skills: {}, prestigeUpgrades, skillUpgrades: {}, skillTiers: {}, equippedInstances, equipmentInstances }, + upgradeEffects + ); + const handleFillMana = () => { - const maxMana = computeMaxMana( - { skills: {}, prestigeUpgrades: {}, skillUpgrades: {}, skillTiers: {} } - ) || 100; - useManaStore.setState((s) => ({ rawMana: Math.max(s.rawMana, maxMana) })); + useManaStore.setState((s) => ({ rawMana: Math.max(s.rawMana, computedMaxMana) })); }; const handleSetDay = (d: number) => { @@ -249,7 +255,7 @@ export function GameStateDebugSection() {
- +