feat: module 0 rewrite trap
Naive engine in Rust and TypeScript (immediate damage, inline triggers, recursive Deathrattles, cards defined in the engine) with test_00_naive_runs and the expected-fail test_00_real_rules_whirlwind_order, plus the Module 0 lesson. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
00662639ba
commit
ffa99785c3
13 files changed
+2121
No files matched your search
@@ -0,0 +1,36 @@
|
||||
//! Module 0 tests for the naive engine. See course/00-rewrite-trap/lesson.md.
|
||||
use naive_engine::Game;
|
||||
|
||||
#[test]
|
||||
fn test_00_naive_runs() {
|
||||
let mut game = Game::new();
|
||||
let hoarder = game.summon("Loot Hoarder");
|
||||
game.deal_damage(&hoarder, 1);
|
||||
assert!(game.board_names().is_empty(), "Loot Hoarder should be gone");
|
||||
assert_eq!(game.cards_drawn, 1, "its Deathrattle draws one card");
|
||||
}
|
||||
|
||||
// EXPECTED TO FAIL. This test states the order the real game uses (all damage
|
||||
// first, then damage triggers in order of play, then deaths and Deathrattles).
|
||||
// The naive engine cannot produce it. Read course/00-rewrite-trap/lesson.md,
|
||||
// "Predict", before changing anything here.
|
||||
#[test]
|
||||
#[should_panic(expected = "left == right")]
|
||||
fn test_00_real_rules_whirlwind_order() {
|
||||
let mut game = Game::new();
|
||||
game.summon("Acolyte of Pain"); // played first
|
||||
game.summon("Loot Hoarder");
|
||||
game.cast("Whirlwind");
|
||||
assert_eq!(
|
||||
game.log,
|
||||
vec![
|
||||
"damaged Acolyte of Pain 1",
|
||||
"damaged Loot Hoarder 1",
|
||||
"triggered Acolyte of Pain",
|
||||
"drew a card",
|
||||
"died Loot Hoarder",
|
||||
"deathrattle Loot Hoarder",
|
||||
"drew a card",
|
||||
]
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user