fix: update StatsTab, DebugTab and all child components to use modular stores
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m42s
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m42s
- Updated StatsTab to use hooks directly (useSkillStore, usePrestigeStore, etc.) - Updated DebugTab to use hooks directly - Updated all debug child components (GameStateDebug, SkillDebug, AttunementDebug, etc.) - Updated all stats child components (ManaStatsSection, CombatStatsSection, etc.) - Fixed UpgradeEffectsSection.tsx syntax errors - Updated page.tsx to not pass store prop to StatsTab and DebugTab - All components now use modular stores directly instead of receiving store prop
This commit is contained in:
@@ -8,23 +8,20 @@ import { Switch } from '@/components/ui/switch';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import {
|
||||
RotateCcw, AlertTriangle, Zap, Clock, Settings, Eye,
|
||||
Plus
|
||||
} from 'lucide-react';
|
||||
import type { GameStore } from '@/lib/game/store';
|
||||
import { fmt } from '@/lib/game/store';
|
||||
import { useDebug } from '@/lib/game/debug-context';
|
||||
import { useGameStore } from '@/lib/game/store';
|
||||
|
||||
interface GameStateDebugProps {
|
||||
store: GameStore;
|
||||
}
|
||||
|
||||
export function GameStateDebug({ store }: GameStateDebugProps) {
|
||||
export function GameStateDebug() {
|
||||
const [confirmReset, setConfirmReset] = useState(false);
|
||||
const { showComponentNames, toggleComponentNames } = useDebug();
|
||||
|
||||
// Get state from store
|
||||
const store = useGameStore((s) => s);
|
||||
|
||||
const handleReset = () => {
|
||||
if (confirmReset) {
|
||||
store.resetGame();
|
||||
useGameStore.getState().resetGame();
|
||||
setConfirmReset(false);
|
||||
} else {
|
||||
setConfirmReset(true);
|
||||
@@ -34,17 +31,19 @@ export function GameStateDebug({ store }: GameStateDebugProps) {
|
||||
|
||||
const handleAddMana = (amount: number) => {
|
||||
// Use gatherMana multiple times to add mana
|
||||
const state = useGameStore.getState();
|
||||
for (let i = 0; i < amount; i++) {
|
||||
store.gatherMana();
|
||||
state.gatherMana();
|
||||
}
|
||||
};
|
||||
|
||||
const handleSetTime = (day: number, hour: number) => {
|
||||
if (store.debugSetTime) {
|
||||
store.debugSetTime(day, hour);
|
||||
const state = useGameStore.getState();
|
||||
if (state.debugSetTime) {
|
||||
state.debugSetTime(day, hour);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
{/* Warning Banner */}
|
||||
@@ -127,20 +126,20 @@ export function GameStateDebug({ store }: GameStateDebugProps) {
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-3">
|
||||
<div className="text-xs text-gray-400 mb-2">
|
||||
Current: {fmt(store.rawMana)} / {fmt(store.getMaxMana())}
|
||||
Current: {store.rawMana} / {store.getMaxMana?.() || '?'}
|
||||
</div>
|
||||
<div className="flex gap-2 flex-wrap">
|
||||
<Button size="sm" variant="outline" onClick={() => handleAddMana(10)}>
|
||||
<Plus className="w-3 h-3 mr-1" /> +10
|
||||
<Zap className="w-3 h-3 mr-1" /> +10
|
||||
</Button>
|
||||
<Button size="sm" variant="outline" onClick={() => handleAddMana(100)}>
|
||||
<Plus className="w-3 h-3 mr-1" /> +100
|
||||
<Zap className="w-3 h-3 mr-1" /> +100
|
||||
</Button>
|
||||
<Button size="sm" variant="outline" onClick={() => handleAddMana(1000)}>
|
||||
<Plus className="w-3 h-3 mr-1" /> +1K
|
||||
<Zap className="w-3 h-3 mr-1" /> +1K
|
||||
</Button>
|
||||
<Button size="sm" variant="outline" onClick={() => handleAddMana(10000)}>
|
||||
<Plus className="w-3 h-3 mr-1" /> +10K
|
||||
<Zap className="w-3 h-3 mr-1" /> +10K
|
||||
</Button>
|
||||
</div>
|
||||
<Separator className="bg-gray-700" />
|
||||
@@ -149,7 +148,7 @@ export function GameStateDebug({ store }: GameStateDebugProps) {
|
||||
size="sm"
|
||||
className="w-full bg-blue-600 hover:bg-blue-700"
|
||||
onClick={() => {
|
||||
const max = store.getMaxMana();
|
||||
const max = store.getMaxMana?.() || 100;
|
||||
const current = store.rawMana;
|
||||
for (let i = 0; i < Math.floor(max - current); i++) {
|
||||
store.gatherMana();
|
||||
@@ -192,7 +191,7 @@ export function GameStateDebug({ store }: GameStateDebugProps) {
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={() => store.togglePause()}
|
||||
onClick={() => useGameStore.getState().togglePause()}
|
||||
>
|
||||
{store.paused ? '▶ Resume' : '⏸ Pause'}
|
||||
</Button>
|
||||
@@ -217,7 +216,7 @@ export function GameStateDebug({ store }: GameStateDebugProps) {
|
||||
// Unlock all base elements
|
||||
['fire', 'water', 'air', 'earth', 'light', 'dark', 'death'].forEach(e => {
|
||||
if (!store.elements[e]?.unlocked) {
|
||||
store.unlockElement(e);
|
||||
useGameStore.getState().unlockElement(e);
|
||||
}
|
||||
});
|
||||
}}
|
||||
@@ -228,10 +227,10 @@ export function GameStateDebug({ store }: GameStateDebugProps) {
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
// Unlock utility elements (only transference remains)
|
||||
// Unlock utility elements
|
||||
['transference'].forEach(e => {
|
||||
if (!store.elements[e]?.unlocked) {
|
||||
store.unlockElement(e);
|
||||
useGameStore.getState().unlockElement(e);
|
||||
}
|
||||
});
|
||||
}}
|
||||
@@ -244,7 +243,7 @@ export function GameStateDebug({ store }: GameStateDebugProps) {
|
||||
onClick={() => {
|
||||
// Max floor
|
||||
if (store.debugSetFloor) {
|
||||
store.debugSetFloor(100);
|
||||
useGameStore.getState().debugSetFloor(100);
|
||||
}
|
||||
}}
|
||||
>
|
||||
@@ -256,7 +255,7 @@ export function GameStateDebug({ store }: GameStateDebugProps) {
|
||||
onClick={() => {
|
||||
// Reset floor HP
|
||||
if (store.resetFloorHP) {
|
||||
store.resetFloorHP();
|
||||
useGameStore.getState().resetFloorHP();
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user