feat: add StateManager.dump() and expose window.__sm for debugging

- StateManager.dump(): console.table formatted dump of variables, flags, history
- window.__sm: exposes engine.stateManager in dev mode for console inspection
This commit is contained in:
2026-06-07 17:27:52 +08:00
parent b96a12a2f3
commit 2de9f99a81
2 changed files with 12 additions and 0 deletions

View File

@@ -91,4 +91,12 @@ export class StateManager {
this.flags = new Set(data.flags)
this.history = [...data.history]
}
dump() {
console.group('StateManager')
console.table(this.variables)
console.log('flags:', [...this.flags])
console.table(this.history)
console.groupEnd()
}
}

View File

@@ -9,6 +9,10 @@ export function useGameEngine(videoEls: () => [HTMLVideoElement | null, HTMLVide
const saveSystem = new SaveSystem()
const store = useGameStore()
if (import.meta.env.DEV) {
;(window as any).__sm = engine.stateManager
}
async function loadGame(dataUrl: string) {
const resp = await fetch(dataUrl)
const data: GameData = await resp.json()