Tile injection
import { Aside } from ‘@astrojs/starlight/components’;
Problem
Section titled “Problem”A river runs through your board. At runtime a quest objective dams the river upstream; downstream tiles need to switch from water to mud for the next 50 simulation ticks, then revert.
Snippet
Section titled “Snippet”import { gameboardCommandActions } from 'declarative-hex-worlds/commands';import { HexTileState } from 'declarative-hex-worlds/traits';
const swap = world.actions(gameboardCommandActions).plan({ kind: 'inject-tile', tileKey: '4,2', patch: { terrain: 'mud' },});world.actions(gameboardCommandActions).execute(swap);
// Later, revert.world.actions(gameboardCommandActions).execute({ ...swap, patch: { terrain: 'water' },});What the library handles
Section titled “What the library handles”- Trait mutation under koota’s transaction model. Tile state changes are observable by queries.
- Re-validation. Connectivity rules re-run; downstream placements that depended on
waterneighbors may flag warnings. - Snapshot stability. Post-mutation
runtime.snapshot()reflects the new state; deterministic replay from the same script reproduces the same sequence.