Initial commit

This commit is contained in:
Z User
2026-04-03 17:23:15 +00:00
commit 4f474dbcf3
192 changed files with 47527 additions and 0 deletions
+82
View File
@@ -0,0 +1,82 @@
// ─── Time Slice ───────────────────────────────────────────────────────────────
// Manages game time, loops, and game state
import type { StateCreator } from 'zustand';
import type { GameState } from '../types';
import { MAX_DAY } from '../constants';
import { calcInsight } from './computed';
export interface TimeSlice {
// State
day: number;
hour: number;
loopCount: number;
gameOver: boolean;
victory: boolean;
paused: boolean;
incursionStrength: number;
loopInsight: number;
log: string[];
// Actions
togglePause: () => void;
resetGame: () => void;
startNewLoop: () => void;
addLog: (message: string) => void;
}
export const createTimeSlice = (
set: StateCreator<GameState>['set'],
get: () => GameState,
initialOverrides?: Partial<GameState>
): TimeSlice => ({
day: 1,
hour: 0,
loopCount: initialOverrides?.loopCount || 0,
gameOver: false,
victory: false,
paused: false,
incursionStrength: 0,
loopInsight: 0,
log: ['✨ The loop begins. You start with Mana Bolt. Gather your strength, mage.'],
togglePause: () => {
set((state) => ({ paused: !state.paused }));
},
resetGame: () => {
if (typeof window !== 'undefined') {
localStorage.removeItem('mana-loop-storage');
}
// Reset to initial state
window.location.reload();
},
startNewLoop: () => {
const state = get();
const insightGained = state.loopInsight || calcInsight(state);
const total = state.insight + insightGained;
// Spell preservation is handled through the prestige upgrade "spellMemory"
// which is purchased with insight
// This will be handled by the main store reset
set({
day: 1,
hour: 0,
gameOver: false,
victory: false,
loopCount: state.loopCount + 1,
insight: total,
totalInsight: (state.totalInsight || 0) + insightGained,
loopInsight: 0,
log: ['✨ A new loop begins. Your insight grows...'],
});
},
addLog: (message: string) => {
set((state) => ({
log: [message, ...state.log.slice(0, 49)],
}));
},
});