feat(#52): dynamic scenario client (form → review → finalize) + e2e

Additive 'Create scenario' path (v0.31): the home screen's create-scenario
card opens a ScenarioForm (pick one of 3 light era templates + a free-text
description + an editable, era-prefilled start year) whose 'Generate world'
posts the draft request; the CheckpointReview screen shows the generated
world (per-nation stats/territory/relations + backstory) and the advisor's
checkpoint list as an approve/remove checklist, then the player picks a
nation to lead and finalizes into a saved, playable game. Both LLM steps ride
the scenario client (deterministic stub under LLM_STUB=1); a failure toasts
and stays on the current screen. The turn stub and static presets are
untouched. New e2e covers the full deterministic flow (near-future 2035,
remove checkpoint 3, lead Boreas, finalize, one empty jump) and the 3-template
manifest.
This commit is contained in:
2026-10-15 10:21:53 +00:00
parent 832957c635
commit 396702b9da
7 changed files with 971 additions and 3 deletions
+35
View File
@@ -115,6 +115,41 @@ export interface WorldDraft {
*/
export type Checkpoint = string;
// --- Client ↔ server message shapes (the two LLM steps) -----------------------
/** The body of `POST /api/scenarios/draft` (step 1: design the world). */
export interface ScenarioDraftRequest {
templateId: string;
description: string;
/** The chosen start year (the server falls back to the template's year). */
year?: number;
}
/** The response of `POST /api/scenarios/draft` — the draft world + checkpoints. */
export interface ScenarioDraftResponse {
world: WorldDraft;
checkpoints: string[];
}
/** The body of `POST /api/scenarios/commit` (step 2: finalize + save the game). */
export interface ScenarioCommitRequest {
templateId: string;
description: string;
/** The chosen start year (the server falls back to the template's year). */
year?: number;
/** The step-1 draft, re-sent so the final world stays close to it. */
draft?: WorldDraft;
/** The checkpoints the player approved (the finalize step's constraints). */
approvedCheckpoints: string[];
/** The nation id the player will lead (kept in the final world when present). */
playerNationId: string;
}
/** The response of `POST /api/scenarios/commit` — the saved game's id. */
export interface ScenarioCommitResponse {
id: string;
}
// --- Validation + transforms (pure) ------------------------------------------
/** The 8 known event types (a local copy so this module needs no runtime import). */