Files
systemic-game-design-course/course/03-death-step/reference/ts
Lucas WintherandClaude Fable 5.2 429137a6ef fix(reference): Death Events remember a right-hand neighbour, not a board index
A Deathrattle summon used the dying minion's board index from before the
Death Creation Step removed anything. That index is stale when a minion to
its left dies in the same step, so the token landed one place too far right.

Each Death Event now records `before`: the nearest minion to the right that
is not dying in the same step. The position handed to the effect context is
resolved when the trigger resolves: the current index of `before`, or the
right end. Applied to the Rust and TS references of Modules 3-10.

Module 3 gains two tests, documented in scenarios.md:
test_03_summon_position_after_simultaneous_deaths (fails before the fix) and
test_03_simultaneous_summons_keep_board_order.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-11 09:15:48 +01:00
..
2026-10-29 02:42:12 +01:00
2026-10-29 02:42:12 +01:00
2026-10-29 02:42:12 +01:00
2026-10-29 02:42:12 +01:00
2026-10-29 02:42:12 +01:00
2026-10-29 02:42:12 +01:00
2026-10-29 02:42:12 +01:00

Module 3 reference engine (TypeScript)

The course's own engine as of the end of Module 3. It adds deferred death: damage and destroy effects only mark minions, and the Death Creation Step removes them when the outermost Phase ends, followed by Death Phases that resolve Deathrattles until no new deaths occur. Module 2's reference was the starting point, so a diff between the two shows what this module adds. Module 4's reference starts from this one.

  • src/engine/: generic machinery. Names no cards.
    • queue.ts: actions, the context an effect sees, and the resolver. A Sequence performs its action, then runs the end-of-outermost-Phase steps and the Death Phase loop. Module 4's aura updates go in the marked seam next to the Death Creation Step. A Death Phase is the same Phase function as a damage reaction, fed Death Events; the dead minion answers its own Death Event with its Deathrattle.
    • death.ts: the Death Creation Step. It collects every mortally wounded or pending-destroy minion, reads all their board positions first, then removes them together and returns their Death Events in order of play.
    • world.ts: entities, zones, order of play, heroes, stats, Armor, the pending-destroy flag and the log. Every state change records its event, except marking a minion pending destroy, which the course log does not show.
    • card.ts: card definitions (stats, triggers, a spell's effect) and the library.
    • event.ts: the engine's events. A Death Event also carries the remembered board position. src/harness.ts translates them into the course's GameEvent.
  • src/content/index.ts: card definitions. Each effect is a small function that returns actions; Module 5 turns them into data.
  • src/harness.ts: the adapter the course tests call. destroy runs one Sequence that marks its target. play is still the Module 1 Expansion Drop stub.

Run it with the module's tests: node tools/verify-references.mjs 03 from the course repository.