From e838e4357d9ac81ee93cde7eaac6f0ba22fbc551 Mon Sep 17 00:00:00 2001 From: Claude Code Date: Wed, 1 Apr 2026 06:23:51 -0700 Subject: [PATCH] =?UTF-8?q?types(simulation):=20=F0=9F=8F=B7=EF=B8=8F=20Up?= =?UTF-8?q?date=20interfaces=20and=20enums=20for=20simulation=20logic=20ty?= =?UTF-8?q?pes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- src/packages/guide/src/types/simulation.ts | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/packages/guide/src/types/simulation.ts diff --git a/src/packages/guide/src/types/simulation.ts b/src/packages/guide/src/types/simulation.ts new file mode 100644 index 00000000..ce416ed0 --- /dev/null +++ b/src/packages/guide/src/types/simulation.ts @@ -0,0 +1,45 @@ +import type { TurnStats, EcologicalEvent, FramePayload, EventTriggeredResponse } from '@magic-civ/engine-ts' + +/** Per-scenario accumulated data from the simulation worker. */ +export interface ScenarioData { + stats: TurnStats[] + events: EcologicalEvent[][] + totalTurns: number + bufferReady: boolean + timings: number[] + loadDurationMs: number | null +} + +/** Progress update from the simulation worker. */ +export interface SimProgress { + scenarioId: string + pct: number + phase: 'generating' | 'geology' | 'scenario' | 'buffering' + bufferedFrames?: number + totalBufferFrames?: number +} + +export type { EventTriggeredResponse } + +/** Info about a manually triggered ecological event. */ +export interface TriggeredEventInfo { + category: string + tier: number + turn: number +} + +/** Return type of useSimulationWorker — the full simulation control surface. */ +export interface UseSimulationWorkerResult { + scenarios: Map + currentFrame: FramePayload | null + referenceFrame: FramePayload | null + progress: SimProgress | null + isReady: boolean + lastTriggeredEvent: TriggeredEventInfo | null + + runScenario: (scenarioId: string, turns: number, bufferFrames: number, seed?: number) => void + extendScenario: (scenarioId: string, turns: number) => void + requestFrame: (scenarioId: string, turn: number) => void + cancelScenario: (scenarioId: string) => void + triggerEvent: (scenarioId: string, category: string, tier: number) => void +}