Files
systemic-game-design-course/course/12-combat/reference/rust/src/engine/event.rs
T
Lucas WintherandClaude Opus 5.5 fb9d0a4eb4 feat: Module 12, Combat (attack as one Sequence, Taunt, defender-first as a queue priority, end of turn; Bonechewer Brawler as the Expansion Drop)
Adds course/12-combat: lesson, scenarios, nine test_12 tests in both tracks,
the cumulative reference (Module 11's plus combat) and the drop. The Damage
action carries per-target hits with a priority; react stable-sorts its Queue by
priority before order of play, so the triggers answering the defender's Damage
Event go first. orderAttack/canAttack/endTurn join the harness (orderAttack
because attack(id) already reads Attack). endOfTurn triggers fire, so Drakkari
Enchanter's data is live. Test Bell is scoped to Module 12's cards. Harness
contract, catalog, research notes and earlier lessons' forward pointers follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 13:34:20 +01:00

77 lines
2.3 KiB
Rust

//! What happened, in order. The engine records an event each time it changes the game.
//! The world also keeps the nesting depth each event was recorded at (`World::log_depths`).
use super::card::TriggerOn;
use super::world::{EntityId, PlayerId};
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Event {
/// `id` entered the board. `by` is the minion whose triggered ability put it there (the
/// trigger resolving when it entered), or `None` for a spell, a play or a summon from
/// outside a Sequence. Module 10: SpellGrid puts it on `by`'s grid tile. The course's log
/// doesn't show `by`.
Summoned {
id: EntityId,
by: Option<EntityId>,
},
Damaged {
target: EntityId,
amount: i32,
},
Triggered {
source: EntityId,
on: TriggerOn,
},
Drew {
player: PlayerId,
id: EntityId,
},
Fatigue {
player: PlayerId,
},
ArmorGained {
player: PlayerId,
amount: i32,
},
/// Armor absorbed `amount` of a Damage to `player`'s hero. The `Damaged` that follows
/// shows the full amount.
ArmorLost {
player: PlayerId,
amount: i32,
},
StatsChanged {
id: EntityId,
attack: i32,
health: i32,
},
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.
Destroyed {
id: EntityId,
before: Option<EntityId>,
},
DeathPhase {
round: u32,
},
/// A minion was played from hand (it has just entered the board). Its Battlecry answers this.
Played {
id: EntityId,
},
/// Module 12: `player`'s turn ended. Their minions' end of turn triggers answer this.
TurnEnded {
player: PlayerId,
},
/// Module 10: `source`'s effect asked for `word` to be written on its grid tile.
/// Part I has no grid: it only records the request. SpellGrid reads it when the
/// Sequence ends.
TextSpawned {
source: EntityId,
word: String,
},
}