Files
systemic-game-design-course/course/05-assemble/reference/ts/src/engine/event.ts
T
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

25 lines
1.2 KiB
TypeScript

// What happened, in order. The engine records an event each time it changes the game.
import type { TriggerOn } from "./card";
import type { EntityId, PlayerId } from "./world";
export type Event =
| { type: "Summoned"; id: EntityId }
| { type: "Damaged"; target: EntityId; amount: number }
| { type: "Triggered"; source: EntityId; on: TriggerOn }
| { type: "Drew"; player: PlayerId; id: EntityId }
| { type: "Fatigue"; player: PlayerId }
| { type: "ArmorGained"; player: PlayerId; amount: number }
| { type: "StatsChanged"; id: EntityId; attack: number; health: number }
| { type: "SpellCast"; card: string }
/**
* A Death Event: the Death Creation Step moved `id` from play to the graveyard.
* `before` is the nearest minion to its right that did not die in the same step, if any:
* its Deathrattle summons immediately left of that minion, or at the right end. It is a
* handle because a board index goes stale when a minion further left dies in the same step.
*/
| { type: "Destroyed"; id: EntityId; before: EntityId | undefined }
| { type: "DeathPhase"; round: number }
/** A minion was played from hand (it has just entered the board). Its Battlecry answers this. */
| { type: "Played"; id: EntityId };