feat: bootstrap walking skeleton
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { create } from 'zustand';
|
||||
import type { GameView } from './viewModel';
|
||||
|
||||
/**
|
||||
* The view store. The runtime owns the authoritative engine state and pushes a
|
||||
* fresh view snapshot here at ~10 fps; React components subscribe to slices of
|
||||
* it. The store is a dumb mirror plus an event log — no game logic lives here.
|
||||
*/
|
||||
|
||||
const MAX_LOG_LINES = 50;
|
||||
|
||||
export interface GameStoreState extends GameView {
|
||||
log: string[];
|
||||
setView: (view: GameView) => void;
|
||||
appendLog: (line: string) => void;
|
||||
}
|
||||
|
||||
export const useGameStore = create<GameStoreState>((set) => ({
|
||||
resources: [],
|
||||
activeActionId: null,
|
||||
actionName: null,
|
||||
actionProgress: 0,
|
||||
log: [],
|
||||
setView: (view) => set(view),
|
||||
appendLog: (line) => set((state) => ({ log: [...state.log, line].slice(-MAX_LOG_LINES) })),
|
||||
}));
|
||||
Reference in New Issue
Block a user