Cards become JSON data in course/cards (one file per card, validated against card.schema.json and the catalog); the M5 references load them via registerCards and interpret effects, replacing content closures. Adds assemble(base, donor, half), the assemble/buffHand effects with an injected chooser, Fleshshape as the data-only Expansion Drop, and stages course/cards in verify-references and start-module. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
/// <reference types="vite/client" />
|
|
// Module 5 Expansion Drop: Fleshshape. Matches expansion/README.md.
|
|
import { expect, test } from "vitest";
|
|
import { newGame, type CardDef } from "../src/harness";
|
|
|
|
const files = import.meta.glob<CardDef>("../cards/*.json", { eager: true, import: "default" });
|
|
|
|
/** Names of the minion files in `cards/` with a trigger clause listening for `on`, sorted. */
|
|
const minionsWithTrigger = (on: string): string[] =>
|
|
Object.values(files)
|
|
.filter((c) => c.type === "minion" && c.text.some((clause) => clause.kind === "trigger" && clause.on === on))
|
|
.map((c) => c.name)
|
|
.sort();
|
|
|
|
test("test_05x_fleshshape_pool_filter", () => {
|
|
const g = newGame();
|
|
const calls: [string, string[]][] = [];
|
|
g.setChooser((kind, options) => {
|
|
calls.push([kind, [...options]]);
|
|
return kind === "base" ? "Loot Hoarder" : kind === "donor" ? "Novice Engineer" : "top";
|
|
});
|
|
g.clearLog();
|
|
|
|
g.cast("Fleshshape", 0);
|
|
|
|
expect(calls.map(([kind]) => kind)).toEqual(["base", "donor", "half"]);
|
|
const bases = minionsWithTrigger("deathrattle");
|
|
expect(bases).toContain("Loot Hoarder");
|
|
expect(bases).not.toContain("Novice Engineer");
|
|
expect(calls[0][1]).toEqual(bases);
|
|
expect(calls[1][1]).toContain("Novice Engineer");
|
|
|
|
const hand = g.hand(0);
|
|
expect(hand).toHaveLength(1);
|
|
const [a] = hand;
|
|
expect(g.nameOf(a)).toBe("Loot Hoarder (Assembled)");
|
|
expect(g.cost(a)).toBe(2);
|
|
expect(g.attack(a)).toBe(4);
|
|
expect(g.health(a)).toBe(3);
|
|
expect(g.log()).toEqual([
|
|
{ type: "SpellCast", card: "Fleshshape" },
|
|
{ type: "StatsChanged", id: a, attack: 4, health: 3 },
|
|
]);
|
|
});
|