Movement planned in full, then committed: a Planner builds a plan (moving and destroyed ids) by running content's movement responses (OPEN/SHUT, PUSH, STOP) for every step, rolling back failed branches. Edge of level blocks; YOU objects move furthest-ahead first; rules are reparsed once after movement. Harness: move/move_dir(Dir), posOf, kindsAt. Expansion Drop: PULL as one word plus one content response. Co-Authored-By: Claude Opus 5.5 <[email protected]>
22 lines
1009 B
TypeScript
22 lines
1009 B
TypeScript
// The Death Creation Step: the one place minions leave play.
|
|
//
|
|
// Damage and destroy effects only mark a minion (0 or less Health, or pending
|
|
// destroy). It stays in play, and keeps triggering, until the outermost Phase
|
|
// ends. Then this step removes every marked minion at once.
|
|
|
|
import type { Event } from "./event";
|
|
import type { World } from "./world";
|
|
|
|
/**
|
|
* Remove every mortally wounded or pending-destroy minion from play, simultaneously.
|
|
* Returns their Death Events in order of play; empty if nothing died.
|
|
*/
|
|
export function deathCreationStep(world: World): Event[] {
|
|
const dying = world.minionsInPlay().filter((id) => world.isDoomed(id));
|
|
// Every position is read before anything moves: removal is simultaneous, and each
|
|
// Death Event remembers where its minion stood when the step began.
|
|
const deaths = dying.map((id) => ({ type: "Destroyed" as const, id, position: world.boardIndex(id)! }));
|
|
for (const { id, position } of deaths) world.kill(id, position);
|
|
return deaths;
|
|
}
|