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.
## 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
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
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
PR 2 of 2 for #46. Gives the LLM a fine-grained per-region stat lever (
TurnResult.regionChanges) alongside the existing nation-widestateChanges, and shows each region's own 4 stats in the map hover tooltip.What changed
shared/protocol.ts): NewRegionStatChangetype; requiredTurnResult.regionChanges(default[]).server/engine.ts):resolveRegionKey(key-first, case-insensitive name, ambiguous→null);validateRegionChanges(resolve refs, clampset, drop invalid);applyTurnResultapplies regionChanges after stateChanges, before the weighted-median recompute (unowned → no-op);isMeaningfulincludes regionChanges; system prompt +playerRegionStatsin user payload.server/index.ts):/jumpwires theregionKeyResolver.server/stub.ts):regionChanges: [](e2e unaffected).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,applyTurnResultregionChanges, prompt contract,isMeaningful, stub. All 256 tests pass. Typecheck + lint + build green.Fixes #48