fix: remove debug Skip to Floor 100 and Reset Floor HP buttons
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m22s
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m22s
- Remove debugSetFloor and resetFloorHP actions from combatStore.ts - Remove their type definitions from combat-state.types.ts - Remove Skip to Floor 100 and Reset Floor HP buttons from GameStateDebugSection.tsx - Remove same buttons from legacy GameStateDebug.tsx - Remove floor quick-jump and Reset Floor HP from SpireDebugSection.tsx - Remove associated tests from DebugTab.test.ts, store-actions.test.ts, store-actions-combat-prestige.test.ts - Add missing src/test/setup.ts required by vitest config These debug buttons created inconsistent game states by teleporting players to floors without proper initialization (no spireMode, no room state, no clearedFloors, no guardian encounters). resetFloorHP could be spammed to infinitely retry any floor for free.
This commit is contained in:
@@ -186,11 +186,9 @@ function TimeControlSection({ day, hour, paused, onSetDay, onTogglePause }: {
|
||||
|
||||
// ─── Quick Actions Section ───────────────────────────────────────────────────
|
||||
|
||||
function QuickActionsSection({ onUnlockBase, onUnlockUtility, onSkipToFloor, onResetFloorHP }: {
|
||||
function QuickActionsSection({ onUnlockBase, onUnlockUtility }: {
|
||||
onUnlockBase: () => void;
|
||||
onUnlockUtility: () => void;
|
||||
onSkipToFloor: () => void;
|
||||
onResetFloorHP: () => void;
|
||||
}) {
|
||||
return (
|
||||
<Card className="bg-gray-900/80 border-gray-700 md:col-span-2">
|
||||
@@ -208,12 +206,6 @@ function QuickActionsSection({ onUnlockBase, onUnlockUtility, onSkipToFloor, onR
|
||||
<Button size="sm" variant="outline" onClick={onUnlockUtility}>
|
||||
Unlock Utility Elements
|
||||
</Button>
|
||||
<Button size="sm" variant="outline" onClick={onSkipToFloor}>
|
||||
Skip to Floor 100
|
||||
</Button>
|
||||
<Button size="sm" variant="outline" onClick={onResetFloorHP}>
|
||||
Reset Floor HP
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
@@ -235,8 +227,7 @@ export function GameStateDebug() {
|
||||
const paused = useUIStore((s) => s.paused);
|
||||
const togglePause = useUIStore((s) => s.togglePause);
|
||||
const resetGame = useGameStore((s) => s.resetGame);
|
||||
const debugSetFloor = useCombatStore((s) => s.debugSetFloor);
|
||||
const resetFloorHP = useCombatStore((s) => s.resetFloorHP);
|
||||
|
||||
|
||||
const handleReset = () => {
|
||||
if (confirmReset) {
|
||||
@@ -294,8 +285,6 @@ export function GameStateDebug() {
|
||||
<QuickActionsSection
|
||||
onUnlockBase={handleUnlockBase}
|
||||
onUnlockUtility={handleUnlockUtility}
|
||||
onSkipToFloor={() => debugSetFloor?.(100)}
|
||||
onResetFloorHP={() => resetFloorHP?.()}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -99,17 +99,6 @@ describe('GameStateDebugSection store interactions', () => {
|
||||
expect(mockToggle).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('debugSetFloor action is callable with floor number', () => {
|
||||
const mockSetFloor = vi.fn();
|
||||
mockSetFloor(100);
|
||||
expect(mockSetFloor).toHaveBeenCalledWith(100);
|
||||
});
|
||||
|
||||
it('resetFloorHP action is callable', () => {
|
||||
const mockResetHP = vi.fn();
|
||||
mockResetHP();
|
||||
expect(mockResetHP).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('DisciplineDebugSection store interactions', () => {
|
||||
|
||||
@@ -168,10 +168,8 @@ function TimeControlSection({ day, hour, paused, onSetDay, onTogglePause }: {
|
||||
|
||||
// ─── Quick Actions Section ───────────────────────────────────────────────────
|
||||
|
||||
function QuickActionsSection({ onUnlockBase, onSkipToFloor, onResetFloorHP }: {
|
||||
function QuickActionsSection({ onUnlockBase }: {
|
||||
onUnlockBase: () => void;
|
||||
onSkipToFloor: () => void;
|
||||
onResetFloorHP: () => void;
|
||||
}) {
|
||||
return (
|
||||
<Card className="bg-gray-900/80 border-gray-700">
|
||||
@@ -186,12 +184,6 @@ function QuickActionsSection({ onUnlockBase, onSkipToFloor, onResetFloorHP }: {
|
||||
<Button size="sm" variant="outline" onClick={onUnlockBase}>
|
||||
Unlock All Base Elements
|
||||
</Button>
|
||||
<Button size="sm" variant="outline" onClick={onSkipToFloor}>
|
||||
Skip to Floor 100
|
||||
</Button>
|
||||
<Button size="sm" variant="outline" onClick={onResetFloorHP}>
|
||||
Reset Floor HP
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
@@ -211,8 +203,7 @@ export function GameStateDebugSection() {
|
||||
const togglePause = useUIStore((s) => s.togglePause);
|
||||
const resetGame = useGameStore((s) => s.resetGame);
|
||||
const gatherMana = useGameStore((s) => s.gatherMana);
|
||||
const debugSetFloor = useCombatStore((s) => s.debugSetFloor);
|
||||
const resetFloorHP = useCombatStore((s) => s.resetFloorHP);
|
||||
|
||||
const elements = useManaStore((s) => s.elements);
|
||||
const unlockElement = useManaStore((s) => s.unlockElement);
|
||||
|
||||
@@ -262,8 +253,6 @@ export function GameStateDebugSection() {
|
||||
<TimeControlSection day={day} hour={hour} paused={paused} onSetDay={handleSetDay} onTogglePause={togglePause} />
|
||||
<QuickActionsSection
|
||||
onUnlockBase={handleUnlockBase}
|
||||
onSkipToFloor={() => debugSetFloor?.(100)}
|
||||
onResetFloorHP={() => resetFloorHP?.()}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,35 +1,17 @@
|
||||
'use client';
|
||||
|
||||
import { useState } from 'react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Castle, ArrowUp, Eye } from 'lucide-react';
|
||||
import { Castle, Eye } from 'lucide-react';
|
||||
import { useCombatStore } from '@/lib/game/stores';
|
||||
import { DebugName } from '@/components/game/debug/debug-context';
|
||||
|
||||
export function SpireDebugSection() {
|
||||
const [floorInput, setFloorInput] = useState('50');
|
||||
|
||||
const currentFloor = useCombatStore((s) => s.currentFloor);
|
||||
const maxFloorReached = useCombatStore((s) => s.maxFloorReached);
|
||||
const spireMode = useCombatStore((s) => s.spireMode);
|
||||
const debugSetFloor = useCombatStore((s) => s.debugSetFloor);
|
||||
const resetFloorHP = useCombatStore((s) => s.resetFloorHP);
|
||||
const enterSpireMode = useCombatStore((s) => s.enterSpireMode);
|
||||
const exitSpireMode = useCombatStore((s) => s.exitSpireMode);
|
||||
const setMaxFloorReached = useCombatStore((s) => s.setMaxFloorReached);
|
||||
|
||||
const handleJumpToFloor = () => {
|
||||
const floor = parseInt(floorInput, 10);
|
||||
if (isNaN(floor) || floor < 1 || floor > 100) return;
|
||||
debugSetFloor(floor);
|
||||
setMaxFloorReached(floor);
|
||||
};
|
||||
|
||||
const handleClearFloor = () => {
|
||||
resetFloorHP();
|
||||
};
|
||||
|
||||
const handleToggleSpireMode = () => {
|
||||
if (spireMode) {
|
||||
@@ -53,27 +35,7 @@ export function SpireDebugSection() {
|
||||
Current Floor: {currentFloor} | Max Reached: {maxFloorReached} | Spire Mode: {spireMode ? 'ON' : 'OFF'}
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2 items-end">
|
||||
<div className="flex-1">
|
||||
<label className="text-xs text-gray-400 mb-1 block">Floor (1-100)</label>
|
||||
<Input
|
||||
type="number"
|
||||
min={1}
|
||||
max={100}
|
||||
value={floorInput}
|
||||
onChange={(e) => setFloorInput(e.target.value)}
|
||||
className="h-8"
|
||||
/>
|
||||
</div>
|
||||
<Button size="sm" variant="outline" onClick={handleJumpToFloor}>
|
||||
<ArrowUp className="w-3 h-3 mr-1" /> Jump
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2 flex-wrap">
|
||||
<Button size="sm" variant="outline" onClick={handleClearFloor}>
|
||||
Reset Floor HP
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant={spireMode ? 'default' : 'outline'}
|
||||
@@ -84,22 +46,7 @@ export function SpireDebugSection() {
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2 flex-wrap">
|
||||
{[10, 25, 50, 75, 100].map((f) => (
|
||||
<Button
|
||||
key={f}
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
setFloorInput(String(f));
|
||||
debugSetFloor(f);
|
||||
setMaxFloorReached(f);
|
||||
}}
|
||||
>
|
||||
Floor {f}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
</CardContent>
|
||||
</Card>
|
||||
</DebugName>
|
||||
|
||||
@@ -133,20 +133,6 @@ describe('CombatStore', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('debugSetFloor / resetFloorHP', () => {
|
||||
it('should set floor and update HP', () => {
|
||||
useCombatStore.getState().debugSetFloor(10);
|
||||
expect(useCombatStore.getState().currentFloor).toBe(10);
|
||||
expect(useCombatStore.getState().floorHP).toBe(getFloorMaxHP(10));
|
||||
});
|
||||
|
||||
it('should reset floor HP to max', () => {
|
||||
useCombatStore.setState({ floorHP: 10 });
|
||||
useCombatStore.getState().resetFloorHP();
|
||||
expect(useCombatStore.getState().floorHP).toBe(useCombatStore.getState().floorMaxHP);
|
||||
});
|
||||
});
|
||||
|
||||
describe('resetCombat', () => {
|
||||
it('should reset to starting floor', () => {
|
||||
useCombatStore.setState({ currentFloor: 50, maxFloorReached: 50 });
|
||||
|
||||
@@ -347,20 +347,6 @@ describe('CombatStore', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('debugSetFloor / resetFloorHP', () => {
|
||||
it('should set floor and update HP', () => {
|
||||
useCombatStore.getState().debugSetFloor(10);
|
||||
expect(useCombatStore.getState().currentFloor).toBe(10);
|
||||
expect(useCombatStore.getState().floorHP).toBe(getFloorMaxHP(10));
|
||||
});
|
||||
|
||||
it('should reset floor HP to max', () => {
|
||||
useCombatStore.setState({ floorHP: 10 });
|
||||
useCombatStore.getState().resetFloorHP();
|
||||
expect(useCombatStore.getState().floorHP).toBe(useCombatStore.getState().floorMaxHP);
|
||||
});
|
||||
});
|
||||
|
||||
describe('resetCombat', () => {
|
||||
it('should reset to starting floor', () => {
|
||||
useCombatStore.setState({ currentFloor: 50, maxFloorReached: 50 });
|
||||
|
||||
@@ -122,10 +122,6 @@ export interface CombatActions {
|
||||
|
||||
// Reset
|
||||
resetCombat: (startFloor: number, spellsToKeep?: string[]) => void;
|
||||
|
||||
// Debug helpers
|
||||
debugSetFloor: (floor: number) => void;
|
||||
resetFloorHP: () => void;
|
||||
}
|
||||
|
||||
// ─── Combined Combat Store Type ───────────────────────────────────────────────
|
||||
|
||||
@@ -290,22 +290,6 @@ export const useCombatStore = create<CombatStore>()(
|
||||
});
|
||||
},
|
||||
|
||||
// Debug helpers
|
||||
debugSetFloor: (floor: number) => {
|
||||
set({
|
||||
currentFloor: floor,
|
||||
floorHP: getFloorMaxHP(floor),
|
||||
floorMaxHP: getFloorMaxHP(floor),
|
||||
});
|
||||
},
|
||||
|
||||
resetFloorHP: () => {
|
||||
set((state) => ({
|
||||
floorHP: state.floorMaxHP,
|
||||
}));
|
||||
},
|
||||
|
||||
|
||||
}),
|
||||
{
|
||||
storage: createSafeStorage(),
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
// Vitest test setup
|
||||
Reference in New Issue
Block a user