From 9f029d93e1a36fb94d980c59b50d1ece90b78e4b Mon Sep 17 00:00:00 2001 From: Refactoring Agent <[email protected]> Date: Sun, 26 Apr 2026 12:52:48 +0200 Subject: [PATCH] Task 2: DebugTab Update - add Invoker Debugging Buttons for Pacts --- src/components/game/debug/PactDebug.tsx | 209 ++++++++++++++++++++++++ src/components/game/debug/index.tsx | 1 + src/components/game/tabs/DebugTab.tsx | 4 +- 3 files changed, 213 insertions(+), 1 deletion(-) create mode 100644 src/components/game/debug/PactDebug.tsx diff --git a/src/components/game/debug/PactDebug.tsx b/src/components/game/debug/PactDebug.tsx new file mode 100644 index 0000000..4265d89 --- /dev/null +++ b/src/components/game/debug/PactDebug.tsx @@ -0,0 +1,209 @@ +'use client'; + +import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; +import { Button } from '@/components/ui/button'; +import { Bug } from 'lucide-react'; +import { useGameStore } from '@/lib/game/stores'; +import { GUARDIANS, ELEMENTS } from '@/lib/game/constants'; + +export function PactDebug() { + // Get state from the main game store where pacts are stored + const store = useGameStore(); + const signedPacts = useGameStore((s) => s.signedPacts); + const signedPactDetails = useGameStore((s) => s.signedPactDetails); + const elements = useGameStore((s) => s.elements); + const prestigeUpgrades = useGameStore((s) => s.prestigeUpgrades); + + // Get all guardian floors + const guardianFloors = Object.keys(GUARDIANS).map(Number).sort((a, b) => a - b); + + // Helper to add log messages + const addLog = (message: string) => { + store.log.unshift(message); + }; + + // Force sign a pact with a guardian (bypass costs and time) + const forcePact = (floor: number) => { + const guardian = GUARDIANS[floor]; + if (!guardian) return; + + // Check if already signed + if (signedPacts.includes(floor)) { + addLog(`⚠️ Already signed pact with ${guardian.name}!`); + return; + } + + // Check max pacts + const maxPacts = 1 + (prestigeUpgrades?.pactCapacity || 0); + if (signedPacts.length >= maxPacts) { + addLog(`⚠️ Cannot sign more pacts! Maximum: ${maxPacts}.`); + return; + } + + // Force sign the pact + const newSignedPacts = [...signedPacts, floor]; + + // Add pact details + const newSignedPactDetails = { + ...signedPactDetails, + [floor]: { + floor, + guardianId: guardian.element, + signedAt: { day: store.day, hour: store.hour }, + skillLevels: {} as Record, + }, + }; + + // Unlock mana types + let newElements = { ...elements }; + for (const elemId of guardian.unlocksMana) { + if (newElements[elemId]) { + newElements = { + ...newElements, + [elemId]: { ...newElements[elemId], unlocked: true }, + }; + } + } + + // Check for compound element unlocks + const unlockedSet = new Set( + Object.entries(newElements) + .filter(([, e]) => e.unlocked) + .map(([id]) => id) + ); + + for (const [elemId, elemDef] of Object.entries(ELEMENTS)) { + if (elemDef.recipe && !newElements[elemId]?.unlocked) { + const canUnlock = elemDef.recipe.every((comp: string) => unlockedSet.has(comp)); + if (canUnlock) { + newElements = { + ...newElements, + [elemId]: { ...newElements[elemId], unlocked: true }, + }; + addLog(`🔮 ${elemDef.name} mana unlocked through component synergy!`); + } + } + } + + addLog(`📜 DEBUG: Pact with ${guardian.name} force-signed! ${guardian.unlocksMana.map(e => ELEMENTS[e]?.name || e).join(', ')} mana unlocked!`); + + // Update store + store.setState({ + signedPacts: newSignedPacts, + signedPactDetails: newSignedPactDetails, + elements: newElements, + }); + }; + + // Remove a pact + const removePact = (floor: number) => { + const guardian = GUARDIANS[floor]; + const newSignedPacts = signedPacts.filter(f => f !== floor); + const newSignedPactDetails = { ...signedPactDetails }; + delete newSignedPactDetails[floor]; + + addLog(`📜 DEBUG: Removed pact with ${guardian?.name || 'Unknown'}!`); + + store.setState({ + signedPacts: newSignedPacts, + signedPactDetails: newSignedPactDetails, + }); + }; + + // Clear all pacts + const clearAllPacts = () => { + addLog(`📜 DEBUG: Cleared all pacts!`); + store.setState({ + signedPacts: [], + signedPactDetails: {}, + }); + }; + + return ( + + + + + Pact Debug + + + +
+

+ Force sign pacts with guardians (bypasses mana costs and signing time) +

+ +
+ {guardianFloors.map((floor) => { + const guardian = GUARDIANS[floor]; + const isSigned = signedPacts.includes(floor); + + return ( +
+
+
+ {guardian.name} +
+
+ Floor {floor} | {guardian.pact}x multiplier +
+
+ Unlocks: {guardian.unlocksMana.map(e => ELEMENTS[e]?.name || e).join(', ')} +
+
+
+ {isSigned ? ( + + ) : ( + + )} +
+
+ ); + })} +
+ + {/* Clear All Button */} + {signedPacts.length > 0 && ( +
+ +
+ )} + + {/* Status */} +
+ Signed Pacts: {signedPacts.length} | + Max Pacts: {1 + (prestigeUpgrades?.pactCapacity || 0)} +
+
+
+
+ ); +} diff --git a/src/components/game/debug/index.tsx b/src/components/game/debug/index.tsx index e30262b..469cfe2 100644 --- a/src/components/game/debug/index.tsx +++ b/src/components/game/debug/index.tsx @@ -3,3 +3,4 @@ export { SkillDebug } from './SkillDebug'; export { ElementDebug } from './ElementDebug'; export { AttunementDebug } from './AttunementDebug'; export { GolemDebug } from './GolemDebug'; +export { PactDebug } from './PactDebug'; diff --git a/src/components/game/tabs/DebugTab.tsx b/src/components/game/tabs/DebugTab.tsx index faebb46..c7a42a7 100755 --- a/src/components/game/tabs/DebugTab.tsx +++ b/src/components/game/tabs/DebugTab.tsx @@ -6,7 +6,8 @@ import { SkillDebug, ElementDebug, AttunementDebug, - GolemDebug + GolemDebug, + PactDebug } from '@/components/game/debug'; interface DebugTabProps { @@ -25,6 +26,7 @@ export function DebugTab({ store }: DebugTabProps) { + ); }