This commit is contained in:
2026-10-29 15:21:05 +01:00
parent bb85881cac
commit bc05b63083
36 changed files with 4654 additions and 5080 deletions

View File

@@ -18,6 +18,7 @@ const game = new Game({
startingLife: 40,
startingHandSize: 7,
commander: true,
mulligans: true,
players: [
{ id: 'p1', deck: deckFromOracleIds(decklist1), commander: commanderCard1 },
{ id: 'p2', deck: deckFromOracleIds(decklist2), commander: commanderCard2 },
@@ -32,7 +33,9 @@ in `commander.ts` checks size, singleton, color identity, and the commander type
`catalog.ts` merges Scryfall card data with `data/card-effects.json`. It also adds
intrinsic mana abilities for basic lands, because Scryfall's oracle text only has
reminder text for them and the compiler produces no ability.
reminder text for them and the compiler produces no ability. When a compiled card
declares a `typeLine`, that value is used instead of Scryfall's; the generated
card source carries the type line and an override can change it.
For tests or hand-authored cards, build a `CardDefinition` yourself:
@@ -56,7 +59,10 @@ const bolt: CardDefinition = {
| Method | Purpose |
| ------ | ------- |
| `start()` | Shuffles libraries, draws opening hands, begins turn 1. |
| `start()` | Shuffles libraries and draws opening hands. With `mulligans: true`, turn 1 waits until every player keeps. |
| `keepHand(playerId)` | Keeps the opening hand; begins turn 1 once every living player has kept. |
| `mulligan(playerId)` | Shuffles the hand back, draws a new opening hand, and queues bottom-of-library choices (one more each time). |
| `putOnBottom(playerId, cardId)` | Puts one chosen card from a mulliganed opening hand on the bottom of its owner's library. |
| `playLand(playerId, cardId)` | Plays a land from hand; once per turn, main phase, empty stack. |
| `castSpell(playerId, cardId, { targets, x, mode, overload })` | Puts a spell on the stack and pays its mana cost. Accepts a commander in the command zone, adds commander tax, and can pay the overload cost instead. |
| `activateAbility(playerId, sourceId, abilityIndex, { targets, x, mode })` | Activates an ability on a permanent. Mana abilities resolve immediately. |
@@ -87,6 +93,10 @@ the permanent, and the match API refuses other priority actions until `chooseCre
(the `choose_type` action) receives one of the creature types in `CREATURE_TYPES`.
The chosen type is stored on the object and cleared when it leaves the battlefield.
With mulligans enabled, the game starts in the `mulligan` status. A mulligan shuffles
the hand back and draws seven; the second mulligan puts one card on the bottom, the
third two, and so on (London rule). Turn 1 begins when every living player has kept.
## Turn structure
```text
@@ -132,8 +142,8 @@ shown to players who can actually do something.
lifelink, vigilance, haste, indestructible. Regeneration shields replace
destruction.
- State-based actions: life at or below zero, ten poison counters, 21 commander
damage from one commander, lethal or deathtouch damage, zero toughness, and
drawing from an empty library.
damage from one commander, lethal or deathtouch damage, zero toughness, the
legend rule, and drawing from an empty library.
## Known limitations
@@ -144,11 +154,13 @@ shown to players who can actually do something.
- Commander support covers single commanders. Partner, backgrounds, companions,
and "choose a commander" variants are not modelled. The engine always takes the
command-zone replacement instead of asking.
- The legend rule, planeswalker loyalty abilities, attacking planeswalkers, and
- Planeswalker loyalty abilities, attacking planeswalkers, and
protection/menace/defender are not implemented unless expressed as a compiled
restriction.
restriction. When the legend rule applies, the engine keeps the first copy it
finds and moves the rest to the graveyard instead of asking the controller.
- Modal spells choose a mode by index (`options.mode`); optional "you may" choices
are not modelled. An optional `pay` is simply not paid when unaffordable. Search
are not modelled, except "pay a cost or enter tapped" which pauses for the
controller. An optional `pay` is simply not paid when unaffordable. Search
effects with several matching cards do pause for the player's pick.
- "As this enters, choose a creature type" pauses for a pick and stores the type on
the permanent, but no effect reads the chosen type yet. The other `choose` kinds
@@ -160,7 +172,9 @@ shown to players who can actually do something.
- Overload widens only top-level effect targets; a nested modal or conditional target
keeps its printed target. Free alternative costs are modelled only for controlling
a commander, and search restrictions cap the searching player's own library.
- Opening hands are kept automatically; there is no mulligan flow.
- Opening hands use the London mulligan when `mulligans` is enabled: each mulligan
draws seven, then puts one more card on the bottom than the previous one. The
match API starts with mulligans on.
- Replacement/prevention effects, layers, and dependency ordering are simplified.
Continuous effects apply in creation order rather than in full rules order.
- The engine is synchronous and exposes full state. `rooms.ts` owns the in-memory