// 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; }