Skip to content

Tile injection

import { Aside } from ‘@astrojs/starlight/components’;

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.

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' },
});
  • 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 water neighbors may flag warnings.
  • Snapshot stability. Post-mutation runtime.snapshot() reflects the new state; deterministic replay from the same script reproduces the same sequence.