v0.29.0: Per-region stat lever (regionChanges) + region-stat hover #49

Merged
kamilkrzywda merged 1 commits from feat/46-region-stats into master 2026-10-15 03:10:07 +02:00
Owner

Summary

PR 2 of 2 for #46. Gives the LLM a fine-grained per-region stat lever (TurnResult.regionChanges) alongside the existing nation-wide stateChanges, and shows each region's own 4 stats in the map hover tooltip.

What changed

  • Protocol (shared/protocol.ts): New RegionStatChange type; required TurnResult.regionChanges (default []).
  • Engine (server/engine.ts): resolveRegionKey (key-first, case-insensitive name, ambiguous→null); validateRegionChanges (resolve refs, clamp set, drop invalid); applyTurnResult applies regionChanges after stateChanges, before the weighted-median recompute (unowned → no-op); isMeaningful includes regionChanges; system prompt + playerRegionStats in user payload.
  • Server route (server/index.ts): /jump wires the regionKeyResolver.
  • Stub (server/stub.ts): regionChanges: [] (e2e unaffected).
  • Client (WorldMap.tsx / App.tsx): hover tooltip shows the region's own 4 stats (placeholder when no entry); NationPanel unchanged.

Tests

New unit suites: resolveRegionKey, validateRegionChanges, applyTurnResult regionChanges, prompt contract, isMeaningful, stub. All 256 tests pass. Typecheck + lint + build green.

Fixes #48

## Summary PR 2 of 2 for #46. Gives the LLM a fine-grained per-region stat lever (`TurnResult.regionChanges`) alongside the existing nation-wide `stateChanges`, and shows each region's own 4 stats in the map hover tooltip. ### What changed - **Protocol (`shared/protocol.ts`):** New `RegionStatChange` type; required `TurnResult.regionChanges` (default `[]`). - **Engine (`server/engine.ts`):** `resolveRegionKey` (key-first, case-insensitive name, ambiguous→null); `validateRegionChanges` (resolve refs, clamp `set`, drop invalid); `applyTurnResult` applies regionChanges after stateChanges, before the weighted-median recompute (unowned → no-op); `isMeaningful` includes regionChanges; system prompt + `playerRegionStats` in user payload. - **Server route (`server/index.ts`):** `/jump` wires the `regionKeyResolver`. - **Stub (`server/stub.ts`):** `regionChanges: []` (e2e unaffected). - **Client (`WorldMap.tsx` / `App.tsx`):** hover tooltip shows the region's own 4 stats (placeholder when no entry); NationPanel unchanged. ### Tests New unit suites: `resolveRegionKey`, `validateRegionChanges`, `applyTurnResult` regionChanges, prompt contract, `isMeaningful`, stub. All 256 tests pass. Typecheck + lint + build green. Fixes #48
kamilkrzywda added 1 commit 2026-10-15 03:07:38 +02:00
feat(#46 PR 2): per-region stat lever (regionChanges) + region-stat hover
CI / build + unit + e2e (pull_request) Successful in 2m31s
cdabf16052
v0.29.0 — the LLM can now target individual regions' stats via
TurnResult.regionChanges (set/add per stat, clamped 0-100), applied
after nation-wide stateChanges and before the weighted-median
recompute. The map hover tooltip shows each region's own four stats.
The stub stays deterministic (regionChanges: []).

Fixes #46 (PR 2 of 2)
kamilkrzywda scheduled this pull request to auto merge when all checks succeed 2026-10-15 03:07:52 +02:00
kamilkrzywda merged commit 44e54470e2 into master 2026-10-15 03:10:07 +02:00
kamilkrzywda deleted branch feat/46-region-stats 2026-10-15 03:10:07 +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#49