feat(#54): non-military takeovers — automatic regime rename (v0.32.0) #55

Merged
kamilkrzywda merged 2 commits from feat/54-takeover-consequence into master 2026-10-15 13:01:31 +02:00
Owner

Make the v0.30 stability/gathering mechanic a visible world change: a new TurnResult.takeovers field carries non-military regime changes (coups / revolutions) that automatically rename the target nation — no player confirm (that stays the domain of nationOps rename).

  • shared/protocol.ts: new Takeover = { nationRef, newRegimeName }; TurnResult.takeovers required (default []), between nationOps and markers
  • server/engine.ts:
    • validateTakeovers — defensive (non-array → [], non-empty trimmed ref + name, 200-char cap, never throws); nationRef resolved at apply time via resolveNationRef (unknown/ambiguous → no-op)
    • applyTurnResult applies takeovers after the per-region recompute, before markers: only n.name changes — stable id, territory, relations, stats, and playerNationId all preserved (the player keeps leading an overthrown nation under its new regime)
    • isMeaningful counts a takeovers-only turn; buildSystemPrompt documents the field (automatic, NOT player-confirmed) tied to the stability < 30 + gathering mechanic; the runTurn "unclear" fallback carries takeovers: []
  • server/stub.ts: returns takeovers: [] (never performs a takeover) — one-conquest behavior and all e2e assertions untouched
  • Client: no change (a takeover is a plain name change; nations keep their stable id-keyed color)
  • 15 new unit tests (apply: rename-with-preservation / player takeover / unknown ref / ambiguous ref / empty name / multiple / single version bump / case-insensitive name; isMeaningful; system-prompt contract both modes; validateTakeovers; stub) + takeovers: [] on every existing TurnResult literal
  • Version bump 0.32.0 + changelog

Local gates: typecheck, lint, 322 unit tests (14 files), build all green.

Fixes #54

Make the v0.30 stability/gathering mechanic a *visible* world change: a new `TurnResult.takeovers` field carries non-military regime changes (coups / revolutions) that **automatically rename** the target nation — no player confirm (that stays the domain of `nationOps` rename). - `shared/protocol.ts`: new `Takeover = { nationRef, newRegimeName }`; `TurnResult.takeovers` required (default `[]`), between `nationOps` and `markers` - `server/engine.ts`: - `validateTakeovers` — defensive (non-array → `[]`, non-empty trimmed ref + name, 200-char cap, never throws); `nationRef` resolved at apply time via `resolveNationRef` (unknown/ambiguous → no-op) - `applyTurnResult` applies takeovers after the per-region recompute, before markers: only `n.name` changes — stable id, territory, relations, stats, and `playerNationId` all preserved (the player keeps leading an overthrown nation under its new regime) - `isMeaningful` counts a takeovers-only turn; `buildSystemPrompt` documents the field (automatic, NOT player-confirmed) tied to the stability < 30 + `gathering` mechanic; the `runTurn` "unclear" fallback carries `takeovers: []` - `server/stub.ts`: returns `takeovers: []` (never performs a takeover) — one-conquest behavior and all e2e assertions untouched - Client: no change (a takeover is a plain name change; nations keep their stable id-keyed color) - 15 new unit tests (apply: rename-with-preservation / player takeover / unknown ref / ambiguous ref / empty name / multiple / single version bump / case-insensitive name; isMeaningful; system-prompt contract both modes; validateTakeovers; stub) + `takeovers: []` on every existing `TurnResult` literal - Version bump 0.32.0 + changelog Local gates: typecheck, lint, 322 unit tests (14 files), build all green. Fixes #54
kamilkrzywda added 2 commits 2026-10-15 12:58:50 +02:00
kamilkrzywda scheduled this pull request to auto merge when all checks succeed 2026-10-15 12:58:58 +02:00
kamilkrzywda merged commit 38d3202472 into master 2026-10-15 13:01:31 +02:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: OpenCode/History#55