Deferred death: damage and destroy only mark minions; the Death Creation Step removes them when the outermost Phase ends, and Death Phases resolve Deathrattles in order of play until no new deaths occur. Deathrattle summons use the board position the Death Event remembered. Harness adds destroy(target). Expansion Drop: Twisting Nether as content only. test_02_mortally_wounded_still_triggers no longer asserts the Acolyte is still on the board: from Module 3 on it leaves at the end of the Sequence, and verify-references runs Module 2's tests against the Module 3 reference. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1.9 KiB
1.9 KiB
Module 3 reference engine (Rust)
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.rs: 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.rs: 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.rs: 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.rs: card definitions (stats, triggers, a spell's effect) and the library.event.rs: the engine's events. A Death Event also carries the remembered board position.src/harness.rstranslates them into the course'sGameEvent.
src/content/mod.rs: card definitions. Each effect is a small function that returns actions; Module 5 turns them into data.src/harness.rs: the adapter the course tests call.destroyruns one Sequence that marks its target.playis still the Module 1 Expansion Drop stub.
Run it with the module's tests: node tools/verify-references.mjs 03 from the course repository.