// Build the choropleth payload from a GameState: every ISO_A3 region maps to its // owning nation plus that nation's stable color (see shared.nationColor). The // client merges this onto public/countries.geo.json and calls source.setData(). 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 code of nation.territory) { map[code] = { color, owner: nation.name, ownerId: id }; } } return map; }