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,31 @@
|
||||
// Module 0 tests for the naive engine. See course/00-rewrite-trap/lesson.md.
|
||||
import { expect, test } from "vitest";
|
||||
import { Game } from "../src/engine";
|
||||
|
||||
test("test_00_naive_runs", () => {
|
||||
const game = new Game();
|
||||
const hoarder = game.summon("Loot Hoarder");
|
||||
game.dealDamage(hoarder, 1);
|
||||
expect(game.boardNames()).toEqual([]); // Loot Hoarder is gone
|
||||
expect(game.cardsDrawn).toBe(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.fails("test_00_real_rules_whirlwind_order", () => {
|
||||
const game = new Game();
|
||||
game.summon("Acolyte of Pain"); // played first
|
||||
game.summon("Loot Hoarder");
|
||||
game.cast("Whirlwind");
|
||||
expect(game.log).toEqual([
|
||||
"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