From ed616738fd9d68e689195626e53198e335779e60 Mon Sep 17 00:00:00 2001
From: Refactoring Agent <[email protected]>
Date: Tue, 5 May 2026 15:00:22 +0200
Subject: [PATCH] fix: lootInventory, prestige, golemancy, attunementStore
export, debug components
---
.../game/crafting/EquipmentCrafter.tsx | 6 +-
src/components/game/debug/GameStateDebug.tsx | 12 +--
src/components/game/debug/PactDebug.tsx | 79 ++++++++-----------
src/components/game/tabs/GolemancyTab.tsx | 4 +-
src/components/game/tabs/LootTab.tsx | 10 +--
src/components/game/tabs/PrestigeTab.tsx | 19 +++--
src/components/game/tabs/SkillsTab.tsx | 4 +-
src/lib/game/stores/combatStore.ts | 25 ++++++
src/lib/game/stores/craftingStore.ts | 55 +++++++++++++
src/lib/game/stores/prestigeStore.ts | 25 ++++++
10 files changed, 171 insertions(+), 68 deletions(-)
diff --git a/src/components/game/crafting/EquipmentCrafter.tsx b/src/components/game/crafting/EquipmentCrafter.tsx
index 4b547f0..ab6f154 100644
--- a/src/components/game/crafting/EquipmentCrafter.tsx
+++ b/src/components/game/crafting/EquipmentCrafter.tsx
@@ -11,16 +11,16 @@ import { CRAFTING_RECIPES, canCraftRecipe } from '@/lib/game/data/crafting-recip
import { LOOT_DROPS, RARITY_COLORS } from '@/lib/game/data/loot-drops';
import type { EquipmentInstance, AppliedEnchantment, LootInventory, EquipmentCraftingProgress } from '@/lib/game/types';
import { fmt } from '@/lib/game/stores';
-import { useGameStore } from '@/lib/game/stores';
+import { useGameStore, useCraftingStore } from '@/lib/game/stores';
export function EquipmentCrafter() {
- const lootInventory = useGameStore((s) => s.lootInventory);
+ const lootInventory = useCraftingStore((s) => s.lootInventory);
const equipmentCraftingProgress = useGameStore((s) => s.equipmentCraftingProgress);
const rawMana = useGameStore((s) => s.rawMana);
const currentAction = useGameStore((s) => s.currentAction);
const startCraftingEquipment = useGameStore((s) => s.startCraftingEquipment);
const cancelEquipmentCrafting = useGameStore((s) => s.cancelEquipmentCrafting);
- const deleteMaterial = useGameStore((s) => s.deleteMaterial);
+ const deleteMaterial = useCraftingStore((s) => s.deleteMaterial);
return (
diff --git a/src/components/game/debug/GameStateDebug.tsx b/src/components/game/debug/GameStateDebug.tsx
index 266248a..80fd341 100644
--- a/src/components/game/debug/GameStateDebug.tsx
+++ b/src/components/game/debug/GameStateDebug.tsx
@@ -10,7 +10,7 @@ import {
RotateCcw, AlertTriangle, Zap, Clock, Settings, Eye,
} from 'lucide-react';
import { useDebug } from '@/lib/game/debug-context';
-import { useGameStore, useManaStore } from '@/lib/game/stores';
+import { useGameStore, useManaStore, useUIStore, useCombatStore } from '@/lib/game/stores';
import { computeMaxMana } from '@/lib/game/stores';
export function GameStateDebug() {
@@ -24,14 +24,14 @@ export function GameStateDebug() {
const gatherMana = useGameStore((s) => s.gatherMana);
const day = useGameStore((s) => s.day);
const hour = useGameStore((s) => s.hour);
- const paused = useGameStore((s) => s.paused);
- const togglePause = useGameStore((s) => s.togglePause);
+ const paused = useUIStore((s) => s.paused);
+ const togglePause = useUIStore((s) => s.togglePause);
// Get actions from stores
const resetGame = useGameStore((s) => s.resetGame);
- const setTime = useGameStore((s) => s.debugSetTime);
- const setFloor = useGameStore((s) => s.debugSetFloor);
- const resetHP = useGameStore((s) => s.resetFloorHP);
+ const setTime = useCombatStore((s) => s.debugSetTime);
+ const setFloor = useCombatStore((s) => s.debugSetFloor);
+ const resetHP = useCombatStore((s) => s.resetFloorHP);
const handleReset = () => {
if (confirmReset) {
diff --git a/src/components/game/debug/PactDebug.tsx b/src/components/game/debug/PactDebug.tsx
index 1d3f71a..4d0be03 100644
--- a/src/components/game/debug/PactDebug.tsx
+++ b/src/components/game/debug/PactDebug.tsx
@@ -3,25 +3,29 @@
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 { usePrestigeStore, useManaStore, useUIStore } 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 state from modular stores
+ const signedPacts = usePrestigeStore((s) => s.signedPacts);
+ const signedPactDetails = usePrestigeStore((s) => s.signedPactDetails);
+ const elements = useManaStore((s) => s.elements);
+ const prestigeUpgrades = usePrestigeStore((s) => s.prestigeUpgrades);
+
+ // Get actions
+ const addSignedPact = usePrestigeStore((s) => s.addSignedPact);
+ const removePact = usePrestigeStore((s) => s.removePact);
+ const debugSetSignedPacts = usePrestigeStore((s) => s.debugSetSignedPacts);
+ const debugSetPactDetails = usePrestigeStore((s) => s.debugSetPactDetails);
+ const unlockElement = useManaStore((s) => s.unlockElement);
+
+ // Get log function from uiStore
+ const addLog = useUIStore((s) => s.addLog);
// 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];
@@ -41,7 +45,7 @@ export function PactDebug() {
}
// Force sign the pact
- const newSignedPacts = [...signedPacts, floor];
+ addSignedPact(floor);
// Add pact details
const newSignedPactDetails = {
@@ -49,74 +53,59 @@ export function PactDebug() {
[floor]: {
floor,
guardianId: guardian.element,
- signedAt: { day: store.day, hour: store.hour },
+ signedAt: { day: useGameStore.getState().day, hour: useGameStore.getState().hour },
skillLevels: {} as Record
,
},
};
+ debugSetPactDetails(newSignedPactDetails);
// Unlock mana types
- let newElements = { ...elements };
for (const elemId of guardian.unlocksMana) {
- if (newElements[elemId]) {
- newElements = {
- ...newElements,
- [elemId]: { ...newElements[elemId], unlocked: true },
- };
+ if (!elements[elemId]?.unlocked) {
+ unlockElement(elemId, 500);
}
}
// Check for compound element unlocks
+ const currentElements = useManaStore.getState().elements;
const unlockedSet = new Set(
- Object.entries(newElements)
+ Object.entries(currentElements)
.filter(([, e]) => e.unlocked)
.map(([id]) => id)
);
for (const [elemId, elemDef] of Object.entries(ELEMENTS)) {
- if (elemDef.recipe && !newElements[elemId]?.unlocked) {
+ if (elemDef.recipe && !currentElements[elemId]?.unlocked) {
const canUnlock = elemDef.recipe.every((comp: string) => unlockedSet.has(comp));
if (canUnlock) {
- newElements = {
- ...newElements,
- [elemId]: { ...newElements[elemId], unlocked: true },
- };
+ unlockElement(elemId, 500);
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 removePactHandler = (floor: number) => {
const guardian = GUARDIANS[floor];
- const newSignedPacts = signedPacts.filter(f => f !== floor);
+
+ removePact(floor);
+
+ // Remove pact details
const newSignedPactDetails = { ...signedPactDetails };
delete newSignedPactDetails[floor];
+ debugSetPactDetails(newSignedPactDetails);
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: {},
- });
+ debugSetSignedPacts([]);
+ debugSetPactDetails({});
};
return (
@@ -162,7 +151,7 @@ export function PactDebug() {