piclets / src /lib /db /resetGame.ts
Fraser's picture
rm legacy
1f2c086
import { db } from './index';
// Utility function to reset the game state (useful for testing)
export async function resetGameState() {
// Clear all game data
await db.picletInstances.clear();
await db.encounters.clear();
await db.gameState.clear();
// Note: All Piclets are now stored in picletInstances table
console.log('Game state reset - all caught piclets and encounters cleared');
}
// Clear only uncaught piclets (discovered but not caught)
export async function clearDiscoveredPiclets() {
// Remove all uncaught piclets from the database
await db.picletInstances.where('caught').equals(false).delete();
console.log('Uncaught piclets cleared');
}
// Full reset including all piclets
export async function fullGameReset() {
await db.picletInstances.clear();
await db.encounters.clear();
await db.gameState.clear();
console.log('Full game reset - all data cleared');
}
// Make functions available globally for debugging
if (typeof window !== 'undefined') {
(window as any).resetGameState = resetGameState;
(window as any).clearDiscoveredPiclets = clearDiscoveredPiclets;
(window as any).fullGameReset = fullGameReset;
}