// Build the choropleth payload from a GameState: every region key (see // public/region-keys.json) maps to its owning nation plus that nation's stable // color (see shared.nationColor). The client merges this onto the sub-national // regions.geo.json (resolving each feature by its own region key) and calls // source.setData(). Format-agnostic: it maps whatever keys sit in territory. import { nationColor, type RegionMap } from '../shared/protocol'; import type { GameState } from '../shared/types'; export function buildRegionMap(state: GameState): RegionMap { const map: RegionMap = {}; for (const [id, nation] of Object.entries(state.nations)) { const color = nationColor(id); for (const key of nation.territory) { map[key] = { color, owner: nation.name, ownerId: id }; } } return map; }