Files
systemic-game-design-course/course/12-combat/reference/rust/README.md
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

15 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Module 12 reference engine (Rust)
The course's own engine as of the end of Module 12: Module 11's engine (Part I's card engine, Part II's grid engine with conditions, and SpellGrid joining them), with combat and the end of a turn in Part I. Every test from Modules 1–11 still passes. Module 11's reference was the starting point, so a diff between the two shows what this module adds. `course/11-conditions/reference/rust/README.md` and the READMEs it points to describe everything else.
- `cards/` and `levels/` (at the crate root; not in this directory): staged by `tools/verify-references.mjs` as for Module 11, plus `course/12-combat/cards/` (`Test Bell`).
- Part I (`src/engine/`):
- `combat.rs` (new): `attack_error(world, attacker, defender)`, the legality rules (a minion in play attacks an enemy character in play, with more than 0 Attack, and a Taunt minion if the defender's side has one), and `TAUNT`.
- `card.rs`: `Card::keywords`, compiled from keyword clauses. `TriggerOn::EndOfTurn` now fires.
- `event.rs`: `Event::TurnEnded { player }`, which end of turn triggers answer. The course's log doesn't show it.
- `queue.rs`: `Action::Damage` carries `hits`, each a target, an amount and a `Priority` (`hits(targets, amount)` builds the usual one-amount list). `react` takes the priority of each event's entries and sorts its Queue by priority, highest first, keeping the order it was filled in within one priority. `Action::Attack` builds one Damage action: the attacker's Attack to the defender at priority `DEFENDER`, and the defender's Attack (if more than 0) to the attacker at `NORMAL`. `Action::EndTurn` records `TurnEnded` and resolves the triggers that answer it.
- `src/harness.rs`: `order_attack(attacker, defender) -> Result<(), String>`, `can_attack(attacker, defender) -> Option<String>` and `end_turn(player)` on `Game`.
- Part II, Part III, `src/cli.rs` and `src/bin/spellgrid.rs`: unchanged from Module 11. SpellGrid doesn't attack. `tools/diff-tracks.mjs` uses this module's CLIs by default.
Run it with the module's tests: `node tools/verify-references.mjs 12` from the course repository.