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 <[email protected]>
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
// 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",
|
|
]);
|
|
});
|