enjine 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +55 -1
- data/README.md +2 -1
- data/SUPPORTED.md +12 -9
- data/docs/ARCHITECTURE.md +2 -0
- data/docs/DESIGN.md +12 -5
- data/docs/MECHANICS_COVERAGE.md +33 -5
- data/docs/guides/api.md +51 -0
- data/docs/guides/card-data-format.md +43 -4
- data/docs/guides/deck-builder.md +18 -0
- data/docs/plans/commander.md +63 -0
- data/docs/plans/dsl-gaps.md +606 -0
- data/docs/plans/standard.md +3 -0
- data/docs/reference/abilities.md +33 -7
- data/docs/reference/costs.md +11 -1
- data/docs/reference/decisions.md +6 -2
- data/docs/reference/effects.md +30 -9
- data/docs/reference/triggers.md +3 -2
- data/lib/enjine/actions/cast.rb +2 -1
- data/lib/enjine/actions/special_action.rb +4 -2
- data/lib/enjine/card_definition.rb +24 -3
- data/lib/enjine/cli/text.rb +23 -1
- data/lib/enjine/cli.rb +2 -1
- data/lib/enjine/color_identity.rb +38 -0
- data/lib/enjine/decisions/commander_zone.rb +36 -0
- data/lib/enjine/deck.rb +73 -14
- data/lib/enjine/deck_builder.rb +62 -18
- data/lib/enjine/engine/casting/alt_casting.rb +19 -2
- data/lib/enjine/engine/casting/casting.rb +3 -3
- data/lib/enjine/engine/casting/costs.rb +5 -1
- data/lib/enjine/engine/casting/permissions.rb +3 -3
- data/lib/enjine/engine/characteristics.rb +0 -13
- data/lib/enjine/engine/commander.rb +125 -0
- data/lib/enjine/engine/damage.rb +1 -0
- data/lib/enjine/engine/defined_power_toughness.rb +30 -0
- data/lib/enjine/engine/emblems.rb +1 -1
- data/lib/enjine/engine/mana_sources.rb +8 -1
- data/lib/enjine/engine/pregame.rb +1 -0
- data/lib/enjine/engine/priority.rb +1 -0
- data/lib/enjine/engine/resolution.rb +1 -0
- data/lib/enjine/engine/rules.rb +1 -1
- data/lib/enjine/engine/state_based_actions.rb +1 -0
- data/lib/enjine/engine/triggers.rb +2 -1
- data/lib/enjine/engine/turn_history.rb +25 -1
- data/lib/enjine/engine/zones.rb +17 -6
- data/lib/enjine/format.rb +53 -0
- data/lib/enjine/fuzz.rb +17 -0
- data/lib/enjine/game.rb +4 -3
- data/lib/enjine/mechanics/abilities/additional_triggers.rb +23 -11
- data/lib/enjine/mechanics/abilities/cost_changes.rb +20 -7
- data/lib/enjine/mechanics/abilities/mana_ability.rb +21 -6
- data/lib/enjine/mechanics/abilities/stack_abilities.rb +13 -9
- data/lib/enjine/mechanics/abilities/static.rb +13 -7
- data/lib/enjine/mechanics/costs/sacrifice.rb +28 -2
- data/lib/enjine/mechanics/effects/become.rb +8 -4
- data/lib/enjine/mechanics/effects/choose_cards.rb +9 -7
- data/lib/enjine/mechanics/effects/delayed_triggers.rb +2 -1
- data/lib/enjine/mechanics/effects/search.rb +15 -8
- data/lib/enjine/mechanics/keywords/plot.rb +79 -0
- data/lib/enjine/mechanics/triggers/casting.rb +8 -6
- data/lib/enjine/mechanics/values.rb +82 -14
- data/lib/enjine/player.rb +2 -1
- data/lib/enjine/rules_monitor.rb +25 -1
- data/lib/enjine/setup.rb +10 -4
- data/lib/enjine/snapshot/player_checks.rb +47 -0
- data/lib/enjine/snapshot.rb +4 -1
- data/lib/enjine/state.rb +33 -14
- data/lib/enjine/version.rb +1 -1
- data/lib/enjine/view.rb +18 -1
- data/lib/enjine.rb +2 -0
- metadata +9 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6185d26cd439c9c35ad53fedbdcfeb548eba3a57c854544e2b19189166fd7741
|
|
4
|
+
data.tar.gz: 66c20bcf046ba5b04e2e8029957355858d666dde6f704368d8268dd90f6932f3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 83201217a12702675bf26d3c888189de9c9c94d72add0372a583b014176d69c0f88e431747a25050bd9f7d6f722942a2b3020c2d66d15e97b56bf352e85ab466
|
|
7
|
+
data.tar.gz: 44cc90a0c0634195e040fdcbcfc9fcece4860b00228b50d15674d65b8645eaa755774479d25697955b2ae43e524862294567cc5ca405a226a73da8103a905f98
|
data/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,58 @@ change the public API; the stable surface is described in
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [0.3.0] - 2026-11-20
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
- Duel Commander (CR 903): `Enjine::Setup.new(alice, bob, format: :duel_commander)`
|
|
15
|
+
(`Enjine::Format`). Commanders start in the command zone, players start at 40 life,
|
|
16
|
+
a commander is cast from the command zone with `via: "command"` and pays the commander
|
|
17
|
+
tax, a new `commander_zone` decision lets its owner return it to the command zone
|
|
18
|
+
(903.9a–b), and 21 combat damage from one commander loses the game (reason
|
|
19
|
+
`"commander_damage"`).
|
|
20
|
+
- Deck documents take `"commander"`. `Deck#errors(format)`, `Deck#valid?(format)` and
|
|
21
|
+
`Player#ready?(format)` check a deck against a format. Commander decks need exactly
|
|
22
|
+
100 cards, singleton, and color identity.
|
|
23
|
+
- `CardDefinition#color_identity`, derived from the card's data across all faces;
|
|
24
|
+
the card field `color_identity` overrides it.
|
|
25
|
+
- `DeckBuilder#build(commander:)` builds Duel Commander decks; `Fuzz.random_commander_deck`;
|
|
26
|
+
`rake fuzz[games,seed,duel_commander]`; the CLI's `--format`.
|
|
27
|
+
- Views show the command zone's commanders and, per player, `commander`,
|
|
28
|
+
`commander_tax` and `commander_damage`.
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
- Only emblems' abilities function from the command zone (CR 113.6, 114.4); the
|
|
32
|
+
command zone may now also hold commanders.
|
|
33
|
+
- `State::STARTING_LIFE` is gone: starting life comes from the format.
|
|
34
|
+
|
|
35
|
+
## [0.2.0] - 2026-11-12
|
|
36
|
+
|
|
37
|
+
### Added
|
|
38
|
+
- Amounts `card_types` (how many card types among cards: delirium, "*" power),
|
|
39
|
+
`greatest_mana_value` and `library_size` ("half their library, rounded up").
|
|
40
|
+
- Amount `sacrificed` (`power`, `toughness` or `mana_value` of the permanents sacrificed to pay the cost).
|
|
41
|
+
- `choose_cards` `put: discard`: the owner discards the cards chosen from their hand ("you choose a
|
|
42
|
+
nonland card from it; that player discards that card").
|
|
43
|
+
- `mana` abilities take `limit: "once_each_turn"`.
|
|
44
|
+
- `cost_modifier` `spells` takes `subtypes` and `colors` ("Dragon spells", "red spells").
|
|
45
|
+
- `grant` and `become` take `duration: "until_your_next_turn"`.
|
|
46
|
+
- Cost `exile_self` ("Exile this enchantment: …").
|
|
47
|
+
- `additional_triggers` takes `of`, a filter of the permanent whose ability triggers; `cause` is optional.
|
|
48
|
+
- Plot (CR 702.170): ability `plot` (a special action from the hand) and effect `plot` ("it becomes
|
|
49
|
+
plotted"); a plotted card is cast from exile for free on a later turn with `via: "plotted"`.
|
|
50
|
+
- Statics can grant loyalty abilities; loyalty abilities take `cost: "-X"`; `activates_ability` takes
|
|
51
|
+
`loyalty: true`.
|
|
52
|
+
- `search_library` `put: graveyard`, and `put: library_top` ("then shuffle and put that card on top").
|
|
53
|
+
|
|
54
|
+
### Fixed
|
|
55
|
+
- Power, toughness and mana value of a permanent that left the battlefield while the spell or ability
|
|
56
|
+
resolves are read as it last existed (CR 608.2h): a destroyed target, or `{"result": n}` of a sacrifice.
|
|
57
|
+
They read 0 or the card's printed values before. A reflexive trigger ("when you do") reads them too.
|
|
58
|
+
- `search_library` works out computed bounds in `for` ("mana value equal to 1 plus …"); such a search
|
|
59
|
+
found nothing before.
|
|
60
|
+
- A characteristic-defining power/toughness that counts cards in graveyards no longer recurses forever
|
|
61
|
+
while its own card is in a graveyard.
|
|
62
|
+
|
|
11
63
|
## [0.1.0] - 2026-11-11
|
|
12
64
|
|
|
13
65
|
### Added
|
|
@@ -24,5 +76,7 @@ change the public API; the stable surface is described in
|
|
|
24
76
|
- `enjine` CLI: hot-seat and random play, `--validate`, `--verify`,
|
|
25
77
|
`--random-deck`, save and load.
|
|
26
78
|
|
|
27
|
-
[Unreleased]: https://github.com/thisiscetin/enjine/compare/v0.
|
|
79
|
+
[Unreleased]: https://github.com/thisiscetin/enjine/compare/v0.3.0...HEAD
|
|
80
|
+
[0.3.0]: https://github.com/thisiscetin/enjine/compare/v0.2.0...v0.3.0
|
|
81
|
+
[0.2.0]: https://github.com/thisiscetin/enjine/compare/v0.1.0...v0.2.0
|
|
28
82
|
[0.1.0]: https://github.com/thisiscetin/enjine/releases/tag/v0.1.0
|
data/README.md
CHANGED
|
@@ -12,7 +12,8 @@ simulations, bots and reinforcement learning, or for a game client.
|
|
|
12
12
|
current Standard-legal sets. Mechanics found only outside Standard (morph,
|
|
13
13
|
madness, infect, ...) are out of scope until a Standard card needs them. The
|
|
14
14
|
[mechanics coverage](docs/MECHANICS_COVERAGE.md) page has the details and the
|
|
15
|
-
numbers.
|
|
15
|
+
numbers. Games are constructed by default; two-player **Duel Commander** (CR 903)
|
|
16
|
+
is a `format:` away (`--format duel_commander` in the CLI).
|
|
16
17
|
|
|
17
18
|
- **Strict rules.** Turn structure, priority, the stack, layers, replacement
|
|
18
19
|
effects, combat, state-based actions, London mulligan. Code and tests cite rule
|
data/SUPPORTED.md
CHANGED
|
@@ -95,7 +95,7 @@ Rules version: Comprehensive Rules effective 2026-11-06.
|
|
|
95
95
|
| [`activated`](docs/reference/abilities.md#activated) | 602.1, 602.2, 602.5b, 602.5d, 702.177a, 702.193a, 702.193b, 702.142a | An activated ability: announce it, choose targets, pay its costs, then it goes on the stack. `timing: "sorcery"` restricts it to sorcery speed, `"your_turn"` to your turns; `limit: "once_each_turn"` to one activation per turn, `"once"` to one activation for as long as the object exists; `only_if` to when a condition holds. `zone` ("exile", "graveyard" or "hand") makes it function only while its card is in that zone ("activate only if this card is exiled"). `exhaust: true` makes it an exhaust ability: it can be activated only once (CR 702.177a). `power_up: true` makes it a power-up ability: activate only once, and if the permanent entered this turn its cost is reduced by the permanent's mana cost (CR 702.193). `boast: true`: activate only if this creature attacked this turn and only once each turn (CR 702.142a). |
|
|
96
96
|
| [`additional_cost`](docs/reference/abilities.md#additional_cost) | 601.2b, 601.2f, 601.2h, 118.8, 118.8b | As an additional cost to cast this spell, pay `cost` too (mana and/or chosen costs such as `sacrifice_permanent`). The spell can't be cast without it. `optional: true`: you may pay it (announced with the `choose_kicker` decision); the condition `{"cast_with": "additional_cost"}` then holds (the spell isn't kicked). |
|
|
97
97
|
| [`additional_land_plays`](docs/reference/abilities.md#additional_land_plays) | 305.2, 305.2a, 305.2b, 604.1 | Its controller may play an additional land on each of their turns. Each instance adds one land play (CR 305.2); lands put onto the battlefield by effects don't count. |
|
|
98
|
-
| [`additional_triggers`](docs/reference/abilities.md#additional_triggers) | 603.2d, 119.9 | While this permanent is on the battlefield, a triggered ability of a permanent its controller controls
|
|
98
|
+
| [`additional_triggers`](docs/reference/abilities.md#additional_triggers) | 603.2d, 119.9, 607.2d | While this permanent is on the battlefield, a triggered ability of a permanent its controller controls triggers an additional time if it triggers because of `cause` (you_gain_life: its controller gaining life) and/or its permanent matches `of` (a filter: "triggered abilities of Allies you control", {"creature": {"other": true, "subtypes": "chosen"}}). At least one of them. |
|
|
99
99
|
| [`beam_me_up`](docs/reference/abilities.md#beam_me_up) | 702.196a, 702.196b, 118.9, 601.2b, 601.2f, 601.2h | You may cast this instant or sorcery card from your graveyard for `cost` plus returning a creature you control to its owner's hand, instead of its mana cost. If you do, it's exiled whenever it would leave the stack. Offered as a cast option with `via: "beam:<ref>"`. |
|
|
100
100
|
| [`can_block_only`](docs/reference/abilities.md#can_block_only) | 509.1b, 509.1a | This creature can block only attacking creatures matching `filter` (checked as blockers are declared, with their current characteristics; controller-relative filter keys are seen from this creature's controller). |
|
|
101
101
|
| [`cant_be_blocked_by`](docs/reference/abilities.md#cant_be_blocked_by) | 509.1b, 509.1a | This creature can't be blocked by creatures matching `filter` (checked as blockers are declared, with their current characteristics). |
|
|
@@ -111,7 +111,7 @@ Rules version: Comprehensive Rules effective 2026-11-06.
|
|
|
111
111
|
| [`choose_number`](docs/reference/abilities.md#choose_number) | 614.12, 614.12a, 607.2 | As this permanent enters, its controller chooses a number from `min` to `max`; abilities of it that say "the chosen number" use it. |
|
|
112
112
|
| [`choose_option`](docs/reference/abilities.md#choose_option) | 614.12, 607.2f, 614.12b | As this permanent enters, its controller chooses one of the `options` (words with no rules meaning); a condition {"chosen": word} is true when that word was chosen. |
|
|
113
113
|
| [`class_level`](docs/reference/abilities.md#class_level) | 717.2a, 717.2b, 717.2d, 717.3, 602.5d | A class level bar: `cost` (a mana cost string or a list of costs): this permanent's level becomes `level`; activate only if its level is `level` - 1, as a sorcery. While its level is `level` or greater it has `keywords` and `abilities`. A permanent without a level is level 1. |
|
|
114
|
-
| [`cost_modifier`](docs/reference/abilities.md#cost_modifier) | 601.2f, 118.7a, 604.1, 601.2a | While on the battlefield: spells cast by `caster` (you, opponent or any; default you) whose card types match `spells` ({"any_of": [types], "not": [types]}, default all spells) cost `reduce` less or `increase` more generic mana. `from` / `not_from`: only spells cast from (not from) that zone (hand | graveyard | exile | library | outside). |
|
|
114
|
+
| [`cost_modifier`](docs/reference/abilities.md#cost_modifier) | 601.2f, 118.7a, 604.1, 601.2a | While on the battlefield: spells cast by `caster` (you, opponent or any; default you) whose card types match `spells` ({"any_of": [types], "not": [types]}, default all spells; `subtypes` and `colors` narrow it: "Dragon spells", "red spells") cost `reduce` less or `increase` more generic mana. `from` / `not_from`: only spells cast from (not from) that zone (hand | graveyard | exile | library | outside). |
|
|
115
115
|
| [`cost_reduction`](docs/reference/abilities.md#cost_reduction) | 601.2f, 118.7a, 702.41a | This spell costs `amount` generic mana less to cast, if the optional `if` condition holds when its total cost is determined (after targets are chosen). `amount` may be computed, e.g. {"count": {"each": "artifact", "controller": "you"}} for affinity for artifacts (CR 702.41a). It can't reduce colored mana or go below {0}. |
|
|
116
116
|
| [`crew`](docs/reference/abilities.md#crew) | 702.122a, 702.122b, 702.122e, 301.7, 301.7a, 301.7b, 208.3, 302.6 | Crew N: tap any number of other untapped creatures you control with total power N or more (chosen one at a time; `done` once the total is enough): this permanent becomes an artifact creature until end of turn. A Vehicle has its printed power and toughness only while it's a creature. |
|
|
117
117
|
| [`cycling`](docs/reference/abilities.md#cycling) | 702.29a, 702.29b, 702.29e, 702.29f, 113.6m, 602.2a | Cycling: pay `cost` and discard this card from your hand to draw a card. With `for` it is typecycling: instead search your library for a card matching `for`, reveal it, put it into your hand, then shuffle. |
|
|
@@ -147,13 +147,14 @@ Rules version: Comprehensive Rules effective 2026-11-06.
|
|
|
147
147
|
| [`kicker`](docs/reference/abilities.md#kicker) | 702.33a, 702.33d, 702.33g, 601.2b, 601.2f, 601.2h | Kicker: as you cast this spell you may also pay `cost` (mana and/or chosen costs such as `sacrifice_permanent`). The spell is then kicked: `{"kicked": true}` conditions hold and its `kicked_targets` are used. |
|
|
148
148
|
| [`look_at_top`](docs/reference/abilities.md#look_at_top) | 401.5, 604.1 | While this permanent is on the battlefield, its controller sees the top card of their library (the `library_top` of their view). |
|
|
149
149
|
| [`loyalty`](docs/reference/abilities.md#loyalty) | 606.3, 606.4, 606.5, 602.2b | A loyalty ability. Its cost adds (positive) or removes (negative) loyalty counters and is paid on activation. Sorcery speed, and only one loyalty ability per planeswalker per turn. |
|
|
150
|
-
| [`mana`](docs/reference/abilities.md#mana) | 605.1a, 605.3a, 605.3b, 106.1a, 106.4, 106.6, 607.2d, 602.5b | An activated mana ability: pay the cost, add the mana to your mana pool immediately. It does not use the stack and can be activated whenever you have priority. `produce`: the fixed mana (`amount` times). Or `color`: `amount` mana (default 1) of one color you choose as you activate it (`"any_one"`) or in any combination of colors (`"any"`); `colors` limits the choice. `"chosen"`: of the color chosen as this entered (choose_color). `spend_only` restricts how the mana can be spent. `only_if`: "Activate only if ...". |
|
|
150
|
+
| [`mana`](docs/reference/abilities.md#mana) | 605.1a, 605.3a, 605.3b, 106.1a, 106.4, 106.6, 607.2d, 602.5b | An activated mana ability: pay the cost, add the mana to your mana pool immediately. It does not use the stack and can be activated whenever you have priority. `produce`: the fixed mana (`amount` times). Or `color`: `amount` mana (default 1) of one color you choose as you activate it (`"any_one"`) or in any combination of colors (`"any"`); `colors` limits the choice. `"chosen"`: of the color chosen as this entered (choose_color). `spend_only` restricts how the mana can be spent. `only_if`: "Activate only if ...". `limit: "once_each_turn"`: "Activate only once each turn." |
|
|
151
151
|
| [`max_speed`](docs/reference/abilities.md#max_speed) | 702.178a, 702.178b, 702.179e, 113.6c | While your speed is 4 (max speed), this object has `keywords` and `abilities` (any kind: activated, triggered, static, mana; an ability with a graveyard cost works from your graveyard). |
|
|
152
152
|
| [`may_not_untap`](docs/reference/abilities.md#may_not_untap) | 502.3, 604.1 | Its controller may choose not to untap it during their untap step (decision `untap_choice`, asked only while it's tapped). |
|
|
153
153
|
| [`mayhem`](docs/reference/abilities.md#mayhem) | 702.187a, 702.187b, 702.187c, 118.9, 601.2b, 601.2f, 601.2h, 305.1 | Mayhem: as long as you discarded this card this turn, you may cast it from your graveyard by paying `cost` rather than its mana cost. Without `cost` (`"mayhem"`), you may play it from your graveyard (a land too) if you discarded it this turn. Cast option `via: "alt:<ref>"`. |
|
|
154
154
|
| [`mobilize`](docs/reference/abilities.md#mobilize) | 702.181a, 508.4 | Mobilize `amount`: whenever this creature attacks, create that many 1/1 red Warrior creature tokens tapped and attacking; sacrifice them at the beginning of the next end step. |
|
|
155
155
|
| [`play_from`](docs/reference/abilities.md#play_from) | 601.3, 113.6e, 113.6f, 305.1, 401.5, 122.1, 614.12, 400.11a, 400.11b, 108.3 | With `cards: "self"` (default): its owner may cast this card from `zone` (the ability functions there). With a card spec: while this permanent is on the battlefield, its controller may play their own matching cards from `zone`, or from any of `zones` ("outside": cards they own outside the game, the deck's `outside` list, CR 400.11a). `play`: "cast" (spells only, default) or "play" (lands too, using a land play). `once_each_turn`: once during each of your turns, one use shared by all its zones. `enters_with`: a permanent spell cast this way enters with these counters. Timing and costs are the usual ones. |
|
|
156
156
|
| [`player_rule`](docs/reference/abilities.md#player_rule) | 702.11c, 115.4, 508.1c, 402.2, 514.1, 615.1, 615.1a, 704.5a, 104.3b, 701.21a, 614.17b, 101.2, 601.3, 701.6a, 119.7, 602.5, 615.12, 702.16b, 702.16e, 702.16k, 604.1, 604.2, 611.3a | While this permanent is on the battlefield (and its `if` condition holds), `rule` applies to the players in `affects` (you | opponents | each; default you). Rules: hexproof, cant_attack, no_max_hand_size, prevent_all_damage, cant_lose_for_life, cant_sacrifice, cant_cast, cant_cast_except_from_hand, spells_cant_be_countered, abilities_cant_be_countered, cant_gain_life, cant_activate, damage_cant_be_prevented, combat_damage_cant_be_prevented, protection_from_opponents. `cant_sacrifice` takes a `filter` of the permanents that can't be sacrificed, `cant_activate` may take a `filter` of the sources whose abilities can't be activated (mana abilities still can), and `cant_cast` and `spells_cant_be_countered` may take a card spec of the `spells`. The damage rules apply to all damage whichever players they name. |
|
|
157
|
+
| [`plot`](docs/reference/abilities.md#plot) | 702.170a, 702.170b, 702.170d, 116.2k | Plot `cost`: during your main phase, while the stack is empty, you may pay `cost` and exile this card from your hand (special action `{type: "special_action"}`). It becomes plotted: on a later turn you may cast it from exile without paying its mana cost, during your main phase while the stack is empty (cast option `via: "plotted"`). |
|
|
157
158
|
| [`prevent_damage`](docs/reference/abilities.md#prevent_damage) | 615.1, 615.1a, 615.5, 615.6 | While this permanent is on the battlefield, all damage from sources in `by` to recipients in `to` (damage scopes as in damage_replacement, both optional; `combat`: combat | noncombat) is prevented. "To and by this creature" is two of them. `then`: effects right after it prevents damage ("prevent that damage and put that many +1/+1 counters on him"), reading {"triggering": "amount"} (the damage prevented), "object" (the source) and "player" (its controller). |
|
|
158
159
|
| [`protection_from`](docs/reference/abilities.md#protection_from) | 702.16a, 702.16b, 702.16c, 702.16d, 702.16e, 702.16f, 702.16g, 702.16h, 702.16i, 702.16j, 702.16k, 704.5m, 704.5n | Protection from the quality (a card spec, "everything", "each_opponent": from each of your opponents, or "its_colors"): damage from sources with the quality is prevented, and this permanent can't be enchanted or equipped by, blocked by or targeted by anything with the quality (Auras and Equipment already attached fall off as a state-based action). |
|
|
159
160
|
| [`saddle`](docs/reference/abilities.md#saddle) | 702.171a, 702.171b, 702.171c | Saddle N: tap any number of other untapped creatures you control with total power N or more (chosen one at a time; `done` once the total is enough): this permanent becomes saddled until end of turn. Activate only as a sorcery. |
|
|
@@ -177,7 +178,7 @@ Rules version: Comprehensive Rules effective 2026-11-06.
|
|
|
177
178
|
| Name | Rules | Description |
|
|
178
179
|
| --- | --- | --- |
|
|
179
180
|
| [`ability_triggers`](docs/reference/triggers.md#ability_triggers) | 603.2, 603.3b, 508.1, 707.10 | A triggered ability of the subject triggers. `cause: "attacks"` (required): its trigger event was the subject attacking. {"triggering": "ability"} is that triggered ability while it's on the stack. |
|
|
180
|
-
| [`activates_ability`](docs/reference/triggers.md#activates_ability) | 602.2, 605.1a, 603.2, 201.4, 702.177a, 702.142b | A player (`controller`: you (default) | opponent | any) activates an ability that isn't a mana ability. `source`: optional filter on the source's card; `name: "chosen"`: only a source with the name chosen as this permanent entered. `exhaust: true`: only an exhaust ability ("whenever you activate an exhaust ability", CR 702.177). `boast: true`: only a boast ability ("whenever a creature you control boasts", CR 702.142b). |
|
|
181
|
+
| [`activates_ability`](docs/reference/triggers.md#activates_ability) | 602.2, 605.1a, 603.2, 201.4, 702.177a, 702.142b, 606.1 | A player (`controller`: you (default) | opponent | any) activates an ability that isn't a mana ability. `source`: optional filter on the source's card; `name: "chosen"`: only a source with the name chosen as this permanent entered. `exhaust: true`: only an exhaust ability ("whenever you activate an exhaust ability", CR 702.177). `boast: true`: only a boast ability ("whenever a creature you control boasts", CR 702.142b). `loyalty: true`: only a loyalty ability (CR 606). |
|
|
181
182
|
| [`airbends`](docs/reference/triggers.md#airbends) | 701.65b | A player (`controller`: you (default) | opponent | any) airbends. |
|
|
182
183
|
| [`any_of`](docs/reference/triggers.md#any_of) | 603.2, 603.2c | Triggers when any of the listed trigger conditions is met. |
|
|
183
184
|
| [`attacks`](docs/reference/triggers.md#attacks) | 508.3a, 603.2 | The subject is declared as an attacker. `first_time_this_turn: true`: only the first time that creature attacks this turn (later combats of the turn don't trigger it). |
|
|
@@ -229,6 +230,7 @@ Rules version: Comprehensive Rules effective 2026-11-06.
|
|
|
229
230
|
| [`exert`](docs/reference/costs.md#exert) | 701.43a, 701.43b, 701.43c | Exert this permanent: it doesn't untap during your next untap step. |
|
|
230
231
|
| [`exile_from_graveyard`](docs/reference/costs.md#exile_from_graveyard) | 406.1, 601.2h, 602.2b, 118.3 | Exile `count` cards from your graveyard (default 1), never this card, chosen while casting or activating and exiled as the spell or ability becomes cast. `card` (a card spec) restricts which. |
|
|
231
232
|
| [`exile_from_hand`](docs/reference/costs.md#exile_from_hand) | 406.1, 601.2h, 602.2b, 118.3 | Exile `count` cards from your hand (default 1), chosen while casting or activating, exiled as the spell or ability becomes cast. `card` (a card spec) restricts which. |
|
|
233
|
+
| [`exile_self`](docs/reference/costs.md#exile_self) | 406.1, 602.2b, 118.3 | Exile the permanent the ability belongs to ("Exile this enchantment: ..."). |
|
|
232
234
|
| [`exile_self_from_graveyard`](docs/reference/costs.md#exile_self_from_graveyard) | 406.1, 113.6m, 602.2b, 118.3 | Exile this card from your graveyard. An ability with this cost is activated from your graveyard. |
|
|
233
235
|
| [`get_counters`](docs/reference/costs.md#get_counters) | 118.1, 122.1, 704.5c | You get `amount` counters of the kind `counter` (e.g. poison). It can always be paid. |
|
|
234
236
|
| [`mana`](docs/reference/costs.md#mana) | 601.2g, 601.2h, 602.2b | Pay mana as part of an activation. Paid during the activation by spending mana from your pool, tapping sources one at a time. |
|
|
@@ -236,7 +238,7 @@ Rules version: Comprehensive Rules effective 2026-11-06.
|
|
|
236
238
|
| [`pay_life`](docs/reference/costs.md#pay_life) | 119.4, 119.4b, 118.3b, 601.2b, 107.3a | Pay that much life (you lose it). Only possible while your life total is at least that much. `"X"` pays the X announced for the spell or ability (at most your life total); it may be a spell's additional cost. |
|
|
237
239
|
| [`remove_counters`](docs/reference/costs.md#remove_counters) | 602.2b, 601.2h, 118.3, 122.1 | Remove `count` counters (of kind `counter`, or any kind) from among permanents you control matching `filter` (default creature), one counter per choice. Removed as it becomes cast. |
|
|
238
240
|
| [`sacrifice`](docs/reference/costs.md#sacrifice) | 701.21a, 602.2b, 118.3 | Sacrifice the permanent the ability belongs to (it goes to its owner's graveyard). |
|
|
239
|
-
| [`sacrifice_permanent`](docs/reference/costs.md#sacrifice_permanent) | 701.21a, 601.2h, 602.2b, 118.3, 608.2h | Sacrifice `count` permanents you control matching `filter` (`other: true`: not the source). Chosen while casting or activating, sacrificed as it becomes cast; the sacrificed permanent's last known types and subtypes are remembered (condition `sacrificed`). |
|
|
241
|
+
| [`sacrifice_permanent`](docs/reference/costs.md#sacrifice_permanent) | 701.21a, 601.2h, 602.2b, 118.3, 608.2h | Sacrifice `count` permanents you control matching `filter` (`other: true`: not the source). Chosen while casting or activating, sacrificed as it becomes cast; the sacrificed permanent's last known types and subtypes are remembered (condition `sacrificed`), and its power, toughness and mana value (amount `sacrificed`). |
|
|
240
242
|
| [`tap`](docs/reference/costs.md#tap) | 107.5, 602.5a | {T} — tap the permanent the ability belongs to. Requires it to be untapped. |
|
|
241
243
|
| [`tap_another_creature`](docs/reference/costs.md#tap_another_creature) | 702.184a, 601.2h, 602.2b, 302.6 | Tap another untapped creature you control, chosen while activating. A creature that came under your control this turn can be tapped this way. |
|
|
242
244
|
| [`tap_permanents`](docs/reference/costs.md#tap_permanents) | 601.2h, 602.2b, 302.6, 118.3 | Tap `count` untapped permanents you control matching `filter` (default: creature), chosen while casting or activating; `other: true` excludes the source. They are tapped as they are chosen; cancelling untaps them. |
|
|
@@ -256,7 +258,7 @@ Rules version: Comprehensive Rules effective 2026-11-06.
|
|
|
256
258
|
| [`another_counter`](docs/reference/effects.md#another_counter) | 122.1, 122.6 | For each referenced permanent, the controller chooses a kind of counter already on it (asked only when there are several kinds) and puts one more counter of that kind on it. |
|
|
257
259
|
| [`assimilate`](docs/reference/effects.md#assimilate) | 701.72a, 701.72b, 701.72c, 607.2a, 205.1b, 613.1b, 613.1d, 614.12a | Assimilate each referenced permanent or permanent card: you gain control of it (or put it onto the battlefield under your control) with a +1/+1 counter, and it becomes a Borg artifact creature while it stays on the battlefield. `for`: only cards matching a card spec; `choose: true`: you choose one of them. |
|
|
258
260
|
| [`attach`](docs/reference/effects.md#attach) | 701.3a, 701.3b, 701.3c, 301.5c | Attach this Aura or Equipment (the ability's source), or the `attachment` (e.g. a token an earlier effect created, {"result": n}), to the referenced permanent. Nothing happens if it can't legally be attached to it, if it's already attached to it, or if the attachment has left the battlefield. |
|
|
259
|
-
| [`become`](docs/reference/effects.md#become) | 611.2a, 611.2b, 611.2c, 613.1d, 613.1e, 613.1f, 613.4b, 613.7b, 205.1a, 205.1b, 301.7b, 514.2 | Each referenced permanent becomes what the parameters say, for `duration` (end_of_turn, default; indefinite: as long as it stays on the battlefield; while_source_on_battlefield: for as long as this effect's source remains on the battlefield; while_you_control_source: for as long as you control it): it has the card `types`, `supertypes` and `subtypes` in addition to its other types (layer 4, "becomes an artifact creature"), its creature types are exactly `creature_types` (layer 4), its colors are `colors` (layer 5), with `loses_abilities: true` it loses all the abilities it had (layer 6; abilities granted later, keyword counters put on it later and this effect's own `keywords` and `abilities` stay, CR 613.7), it has the `keywords` and `abilities` (layer 6: triggered, activated, mana, play_from or additional_land_plays abilities) and its base power and toughness are `base_power_toughness` (layer 7b). A permanent that becomes a creature has its printed power and toughness (a Vehicle's), or 0/0. |
|
|
261
|
+
| [`become`](docs/reference/effects.md#become) | 611.2a, 611.2b, 611.2c, 613.1d, 613.1e, 613.1f, 613.4b, 613.7b, 205.1a, 205.1b, 301.7b, 514.2 | Each referenced permanent becomes what the parameters say, for `duration` (end_of_turn, default; until_your_next_turn: until your next turn begins; indefinite: as long as it stays on the battlefield; while_source_on_battlefield: for as long as this effect's source remains on the battlefield; while_you_control_source: for as long as you control it): it has the card `types`, `supertypes` and `subtypes` in addition to its other types (layer 4, "becomes an artifact creature"), its creature types are exactly `creature_types` (layer 4), its colors are `colors` (layer 5), with `loses_abilities: true` it loses all the abilities it had (layer 6; abilities granted later, keyword counters put on it later and this effect's own `keywords` and `abilities` stay, CR 613.7), it has the `keywords` and `abilities` (layer 6: triggered, activated, mana, play_from or additional_land_plays abilities) and its base power and toughness are `base_power_toughness` (layer 7b). A permanent that becomes a creature has its printed power and toughness (a Vehicle's), or 0/0. |
|
|
260
262
|
| [`become_copy`](docs/reference/effects.md#become_copy) | 707.2, 707.4, 613.2a, 613.7, 611.2a, 514.2 | Each referenced permanent becomes a copy of the (first) object `of` refers to, with the `except` modifications, until end of turn (default) or for as long as it stays on the battlefield (`duration: "permanent"`). It keeps its counters, status and other effects; nothing enters or leaves, so no enter or leave abilities trigger. Several copy effects apply in timestamp order. |
|
|
261
263
|
| [`become_saddled`](docs/reference/effects.md#become_saddled) | 702.171a, 702.171b | Each referenced permanent (default: this one) becomes saddled until end of turn (filters: `"saddled": true`). |
|
|
262
264
|
| [`behold`](docs/reference/effects.md#behold) | 701.4a, 701.4b, 118.3 | You behold an object matching the card spec `card`: reveal such a card from your hand or choose such a permanent you control. Under `may`, "yes" is offered only when there is one. |
|
|
@@ -265,7 +267,7 @@ Rules version: Comprehensive Rules effective 2026-11-06.
|
|
|
265
267
|
| [`cast`](docs/reference/effects.md#cast) | 608.2g, 707.12, 707.12a, 601.2a, 601.2f | The controller may cast referenced cards (or card copies) now, while this resolves, paying their costs; timing restrictions don't apply. `to`, `for`, `not_types`, `max_mana_value`, `count`, `exile_instead` and `any_mana_type` work as for `cast_free`. |
|
|
266
268
|
| [`cast_free`](docs/reference/effects.md#cast_free) | 608.2g, 118.9, 601.2a, 107.3b, 118.6a, 305.2a, 305.3, 406.3a | The controller may cast referenced cards without paying their mana costs while this resolves. `to` names the cards ({"result": n}), or a player for the cards in their hand (default: your hand). Only cards matching `for`/`not_types` with mana value up to `max_mana_value` (optional amount) that could be cast now (legal targets). `count`: 1 (default) or "any" (any number, one at a time). X is 0 (CR 107.3b). `play: true` ("you may play"): a land among them may be played, on your turn with a land play left (`{type: "play_land"}`). A face-down card is judged face up. |
|
|
267
269
|
| [`choose_card_type`](docs/reference/effects.md#choose_card_type) | 205.2a, 607.2d, 608.2c | The player (`to`, default you) chooses a card type; later effects of this spell or ability read it with "types": "chosen". |
|
|
268
|
-
| [`choose_cards`](docs/reference/effects.md#choose_cards) | 701.20a, 701.20e, 400.7j, 608.2c, 607.2a, 118.12, 701.9b | You choose `count` (default 1; "any": any number) cards matching `for` from `from`: a selector (e.g. {"result": 0}, the cards an earlier effect milled) or a player's zone, {"hand": selector} / {"graveyard": selector}. `optional`: you may choose fewer. Then they are put into `put` (`tapped` onto the battlefield, under your control; exiled cards `link`ed to the source). `look`: you look at the whole zone first; `reveal`: "chosen" reveals what you chose, "all" the whole set. `then` runs if a card was chosen, `otherwise` if none was ("if you can't"). `random: true`: the cards are picked at random (the game's random number generator) instead of chosen. |
|
|
270
|
+
| [`choose_cards`](docs/reference/effects.md#choose_cards) | 701.20a, 701.20e, 400.7j, 608.2c, 607.2a, 118.12, 701.9a, 701.9b | You choose `count` (default 1; "any": any number) cards matching `for` from `from`: a selector (e.g. {"result": 0}, the cards an earlier effect milled) or a player's zone, {"hand": selector} / {"graveyard": selector}. `optional`: you may choose fewer. Then they are put into `put` (`discard`: from a hand, its owner discards them; `tapped` onto the battlefield, under your control; exiled cards `link`ed to the source). `look`: you look at the whole zone first; `reveal`: "chosen" reveals what you chose, "all" the whole set. `then` runs if a card was chosen, `otherwise` if none was ("if you can't"). `random: true`: the cards are picked at random (the game's random number generator) instead of chosen. |
|
|
269
271
|
| [`choose_color`](docs/reference/effects.md#choose_color) | 105.4, 607.2d, 608.2c | The player (`to`, default you) chooses a color; later effects of this spell or ability read it with "colors": "chosen". |
|
|
270
272
|
| [`choose_creature_type`](docs/reference/effects.md#choose_creature_type) | 205.3m, 607.2d, 608.2c | The player (`to`, default you) chooses a creature type; later effects of this spell or ability read it with "subtypes": "chosen". |
|
|
271
273
|
| [`choose_new_targets`](docs/reference/effects.md#choose_new_targets) | 115.7, 115.7d, 115.7e | You may choose new targets for each spell or ability on the stack `of` refers to (e.g. {"triggering": "object"}: "that spell"): for each target, keep it or pick another legal target for that spell. |
|
|
@@ -307,7 +309,7 @@ Rules version: Comprehensive Rules effective 2026-11-06.
|
|
|
307
309
|
| [`flip_coins`](docs/reference/effects.md#flip_coins) | 705.1, 705.2, 705.3, 608.2c | You flip `amount` coins (default 1), each coming up heads or tails at random (the game's random number generator). `count`: "wins" (default; you call each flip and win it if the call matches) or "heads" (no one wins or loses). How many were counted is this effect's amount: {"this_way": n} in later effects and conditions. |
|
|
308
310
|
| [`gain_control`](docs/reference/effects.md#gain_control) | 613.1b, 108.4, 506.4, 302.6, 514.2, 611.2b | The player referenced by `gains` (default you) gains control of each referenced permanent: indefinitely (`duration: "permanent"`, default), until end of turn, or for as long as this effect's source remains on the battlefield / tapped / under your control (it does nothing if that is already over). A permanent that changes control leaves combat and is newly under its controller's control (it can't attack or {T} without haste). |
|
|
309
311
|
| [`gain_life`](docs/reference/effects.md#gain_life) | 119.3 | Each referenced player gains `amount` life (default: you). |
|
|
310
|
-
| [`grant`](docs/reference/effects.md#grant) | 611.2a, 611.2c, 613.1f, 514.2 | Each referenced permanent (or spell on the stack) gains the `keywords` until end of turn. |
|
|
312
|
+
| [`grant`](docs/reference/effects.md#grant) | 611.2a, 611.2c, 613.1f, 514.2, 500.1 | Each referenced permanent (or spell on the stack) gains the `keywords` until end of turn (`duration: "until_your_next_turn"`: until its controller's next turn begins). |
|
|
311
313
|
| [`grant_ability`](docs/reference/effects.md#grant_ability) | 113.6b, 611.2a, 613.1f | Each referenced object (a permanent, or a card in any zone, e.g. an exiled card) gains `ability` (any ability entry) for as long as it stays in its zone (default) or until end of turn. `for` (a card spec) keeps only matching objects ("that nonland card"). An activated ability with `zone` works from that zone ("activate only if this card is exiled"). |
|
|
312
314
|
| [`look_at_hand`](docs/reference/effects.md#look_at_hand) | 701.20e | You look at each referenced player's hand (other players don't see the cards). |
|
|
313
315
|
| [`lose_game`](docs/reference/effects.md#lose_game) | 104.3e, 104.4a | Each referenced player (default you) loses the game. |
|
|
@@ -319,6 +321,7 @@ Rules version: Comprehensive Rules effective 2026-11-06.
|
|
|
319
321
|
| [`phase_out`](docs/reference/effects.md#phase_out) | 702.26a, 702.26b, 702.26d, 702.26g, 702.26h, 502.1, 506.4 | Each referenced permanent phases out, with the Auras and Equipment attached to it (indirectly). It phases in during the untap step of the player who controlled it as it phased out. Phasing isn't a zone change: no enters or leaves triggers. |
|
|
320
322
|
| [`play_permission`](docs/reference/effects.md#play_permission) | 611.2a, 601.3, 305.1, 400.7, 514.2, 601.2f, 108.3, 406.3b, 609.4b | A player may play (`play: "play"`, default) or cast (`"cast"`) each referenced exiled card matching `for`/`not_types`, paying its costs and following timing rules, for `duration`: end_of_turn (default), end_of_your_next_turn or while_exiled. With `choose: "one_per_owner"` only one chosen card per owner. `to_player`: who may play it, "controller" (default, the effect's controller), "owner" (the card's owner) or a player selector (a face-down card: only someone who may look at it). `cost_increase`: spells cast this way cost that much generic mana more. `any_mana_type: true`: mana of any type can be spent to cast those spells. |
|
|
321
323
|
| [`player_rule`](docs/reference/effects.md#player_rule) | 702.11c, 115.4, 508.1c, 402.2, 514.1, 615.1, 615.1a, 704.5a, 104.3b, 701.21a, 614.17b, 101.2, 601.3, 701.6a, 119.7, 602.5, 615.12, 702.16b, 702.16e, 702.16k, 611.2a, 514.2 | Each referenced player (default you) gets `rule` for the `duration`: end_of_turn (default) or until_your_next_turn (until the controller's next turn begins). Rules: hexproof, cant_attack, no_max_hand_size, prevent_all_damage, cant_lose_for_life, cant_cast, cant_cast_except_from_hand, spells_cant_be_countered, abilities_cant_be_countered, cant_gain_life, cant_activate, damage_cant_be_prevented, combat_damage_cant_be_prevented, protection_from_opponents. |
|
|
324
|
+
| [`plot`](docs/reference/effects.md#plot) | 702.170c, 702.170d, 406.1 | Each referenced card or spell is exiled (if it isn't already) and becomes plotted: its owner may cast it from exile without paying its mana cost during their main phase while the stack is empty, on any later turn (cast option `via: "plotted"`). |
|
|
322
325
|
| [`prepare`](docs/reference/effects.md#prepare) | 723.3a, 723.3c | Each referenced permanent (default: this one) becomes prepared, if it has a prepare spell and isn't prepared already: its controller creates a copy of the prepare spell in exile and may cast that copy while the permanent stays prepared. Casting it unprepares the permanent. |
|
|
323
326
|
| [`prevent_damage`](docs/reference/effects.md#prevent_damage) | 615.1, 615.3, 615.5, 615.7, 615.8, 609.7a, 611.2a, 611.2b, 611.2c | For the `duration` (end_of_turn by default, until_your_next_turn, or while_source_on_battlefield: for as long as this effect's source remains on the battlefield), damage that would be dealt to the referenced players and permanents (`to`, fixed as it resolves) or to those matching `to_each` as the damage is dealt (a damage scope seen from the controller, e.g. {"each": "creature", "controller": "you"}), and/or by the referenced sources (`by`; "chosen_source": a source the controller chooses as it resolves) is prevented (`combat`: combat | noncombat only). With `next`, it is a shield that prevents only the next that much damage; with `next_time: true` it prevents only the next damage event it applies to. `then`: effects right after it prevents damage, reading {"triggering": "amount"} (the damage prevented), "object" (the source) and "player" (its controller). |
|
|
324
327
|
| [`proliferate`](docs/reference/effects.md#proliferate) | 701.34a, 122.1, 122.6 | You choose any number of permanents and/or players that have counters (one at a time, then done); each gets one more counter of each kind already on it. `amount` (default 1): how many times to proliferate. |
|
|
@@ -337,7 +340,7 @@ Rules version: Comprehensive Rules effective 2026-11-06.
|
|
|
337
340
|
| [`sacrifice`](docs/reference/effects.md#sacrifice) | 701.21a | The controller sacrifices each referenced permanent they control (it goes to its owner's graveyard; it isn't destroyed, so indestructible doesn't stop it). |
|
|
338
341
|
| [`sacrifice_choice`](docs/reference/effects.md#sacrifice_choice) | 701.21a, 101.4, 118.3 | Each referenced player (default: you) sacrifices `count` (default 1; "any": any number) permanents they control matching `filter`, chosen by them in turn order starting with the active player; all are sacrificed at once. The `filter`'s `controller` and `other` restrictions are relative to the effect's controller and source. |
|
|
339
342
|
| [`scry`](docs/reference/effects.md#scry) | 701.22a | Look at the top `amount` cards of your library; put any number on the bottom and the rest on top in any order. |
|
|
340
|
-
| [`search_library`](docs/reference/effects.md#search_library) | 701.23a, 701.23b, 701.23d, 701.23e, 701.20a, 701.24a, 701.24b, 118.12, 110.2a | Search your library for up to `count` cards matching `for`, then put them into your hand (or onto the battlefield, tapped if `tapped`, with `counters
|
|
343
|
+
| [`search_library`](docs/reference/effects.md#search_library) | 701.23a, 701.23b, 701.23d, 701.23e, 701.20a, 701.24a, 701.24b, 118.12, 110.2a | Search your library for up to `count` cards matching `for`, then put them into your hand (or onto the battlefield, tapped if `tapped`, with `counters`; or into your graveyard) and shuffle. `put: library_top`: shuffle, then put the found card (one) on top. Computed bounds in `for` are worked out as the effect resolves. With a stated quality you may find fewer (or none); a search for just "a card" must find one if it can. `reveal` shows the found cards to every player. `searcher` names another player who searches their own library (e.g. {"controller_of": {"target": 0}}); `may: true` lets the searcher decline (then nothing is shuffled). `different_names: true`: the cards found must all have different names ("basic land cards with different names"). |
|
|
341
344
|
| [`set_base_power_toughness`](docs/reference/effects.md#set_base_power_toughness) | 613.4b, 611.2a, 611.2b, 611.2c | Each referenced creature's base power and toughness become `power`/`toughness` (layer 7b; counters and pumps still apply), until end of turn or, with `duration: "indefinite"`, for as long as it stays on the battlefield. |
|
|
342
345
|
| [`set_creature_types`](docs/reference/effects.md#set_creature_types) | 205.1a, 613.1d, 611.2c, 514.2 | Until end of turn, each referenced creature's creature types are exactly `types` (its other subtypes, such as artifact types, stay). The affected set is locked in. |
|
|
343
346
|
| [`set_life`](docs/reference/effects.md#set_life) | 119.5, 119.7 | Each referenced player's life total becomes `amount` (default: you): they gain or lose the difference (so "can't gain life" and life-gain triggers apply). |
|
data/docs/ARCHITECTURE.md
CHANGED
|
@@ -19,6 +19,7 @@ lib/enjine/
|
|
|
19
19
|
card_definition.rb # immutable, validated blueprint built from a data Hash
|
|
20
20
|
catalog.rb # id -> CardDefinition, conflict detection
|
|
21
21
|
deck.rb player.rb setup.rb # decklists, players, compiled pairings
|
|
22
|
+
format.rb color_identity.rb # game formats (constructed, duel_commander); CR 903.4 color identity
|
|
22
23
|
|
|
23
24
|
mechanics/ # ONE PLACE PER MECHANIC: <category>/<mechanic>.rb, all registered primitives
|
|
24
25
|
types/ supertypes/ subtypes/ card types, supertypes, subtypes (permanent_types spell_types land saga auras_and_equipment ...)
|
|
@@ -50,6 +51,7 @@ lib/enjine/
|
|
|
50
51
|
state_based_actions.rb # CR 704 and game end (CR 104)
|
|
51
52
|
characteristics.rb # CR 613 layer pipeline for P/T, continuous effects, cleanup
|
|
52
53
|
rules.rb copies.rb faces.rb ... # player rules and control; copies (CR 707); faces; sagas, phasing, speed ...
|
|
54
|
+
commander.rb # CR 903 (Duel Commander): command zone, tax, 903.9 returns, commander damage
|
|
53
55
|
steps.rb # 12 step objects with turn-based actions
|
|
54
56
|
events.rb # typed, serializable events + per-viewer redaction
|
|
55
57
|
decisions/ # one class per decision kind
|
data/docs/DESIGN.md
CHANGED
|
@@ -9,11 +9,18 @@ agents in a separate project later) drive it through an atomic decision API.
|
|
|
9
9
|
|
|
10
10
|
- **Standard.** The target is every mechanic on the cards of the current
|
|
11
11
|
Standard-legal sets, plus the core rules (CR 1–6) every game needs. Mechanics
|
|
12
|
-
found only on cards outside Standard
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- Two-player constructed: 20 life, deck ≥ 60 cards, max 4 copies of a
|
|
16
|
-
(basic lands and "any number" cards exempt). No sideboard tracking.
|
|
12
|
+
found only on cards outside Standard and multiplayer variants are out of scope
|
|
13
|
+
until a Standard card needs them. New Standard sets add mechanics; rotated sets
|
|
14
|
+
keep theirs.
|
|
15
|
+
- Two-player constructed by default: 20 life, deck ≥ 60 cards, max 4 copies of a
|
|
16
|
+
card (basic lands and "any number" cards exempt). No sideboard tracking.
|
|
17
|
+
- **Duel Commander** (CR 903, two players) is in scope as a game-setup variant,
|
|
18
|
+
chosen with `Setup.new(..., format: :duel_commander)` (`Enjine::Format`): 40
|
|
19
|
+
life, 100-card singleton decks led by a commander, the command zone, commander
|
|
20
|
+
tax, returning to the command zone and 21 commander damage. Which *card*
|
|
21
|
+
mechanics exist is still decided by Standard; partner, companion and cards that
|
|
22
|
+
refer to "your commander" wait for a card that needs them. See
|
|
23
|
+
[plans/commander.md](plans/commander.md).
|
|
17
24
|
- Single games, start to finish. No best-of-3 / match object.
|
|
18
25
|
- The engine knows **no cards**: every card arrives as data, in a deck document or a
|
|
19
26
|
`DeckBuilder` pool. The test and fuzz cards live in `spec/fixtures/cards/`.
|
data/docs/MECHANICS_COVERAGE.md
CHANGED
|
@@ -30,8 +30,9 @@ Comprehensive Rules (measured by the rule numbers the code implements and cites,
|
|
|
30
30
|
face-down cards (CR 708), madness, delve, persist, undying, infect, toxic,
|
|
31
31
|
ninjutsu, cumulative upkeep, echo, bestow, mutate, split and flip cards,
|
|
32
32
|
levelers, Prototype, Cases, day/night, the monarch and the initiative.
|
|
33
|
-
- Battles and dungeons; multiplayer and casual variants (Commander,
|
|
34
|
-
Archenemy, Conspiracy); ante; matches and sideboarding.
|
|
33
|
+
- Battles and dungeons; multiplayer and casual variants (multiplayer Commander,
|
|
34
|
+
Planechase, Archenemy, Conspiracy); ante; matches and sideboarding. Two-player
|
|
35
|
+
**Duel Commander** is supported (CR 903, see below).
|
|
35
36
|
|
|
36
37
|
A card that uses an unsupported mechanic can't be written: validation rejects it
|
|
37
38
|
with an error naming the unknown key. Some older keywords can still be written
|
|
@@ -343,7 +344,8 @@ These rules cut across every mechanic. All numbers follow the 2026-11-06 text.
|
|
|
343
344
|
| 704.5y | A battle with an illegal protector is reassigned or goes to the graveyard | M5 |
|
|
344
345
|
| 704.5z | Multiple Roles from the same controller on one permanent: only the newest stays | M5 |
|
|
345
346
|
| 704.5aa | A controller of a start-your-engines! permanent who has no speed gets speed 1 | M5 |
|
|
346
|
-
| 704.
|
|
347
|
+
| 704.6c | Commander: 21 or more combat damage from one commander loses the game (903.10a) | ✓ |
|
|
348
|
+
| 704.6a–b, d–f | Other variant SBAs (Two-Headed Giant, Archenemy, Planechase) | OOS |
|
|
347
349
|
|
|
348
350
|
---
|
|
349
351
|
|
|
@@ -648,10 +650,36 @@ replacement/prevention (614–616), "dies" and leaves-the-battlefield triggers
|
|
|
648
650
|
|
|
649
651
|
---
|
|
650
652
|
|
|
653
|
+
## Commander (903)
|
|
654
|
+
|
|
655
|
+
Two-player Duel Commander, chosen with `format: :duel_commander` (`Enjine::Format`, `Engine::Commander`).
|
|
656
|
+
|
|
657
|
+
| CR | Rule | Status |
|
|
658
|
+
| --- | --- | --- |
|
|
659
|
+
| 903.3 | A commander is a legendary creature, Vehicle or Spacecraft with P/T; the designation belongs to the card (copies and tokens aren't commanders) | ✓ |
|
|
660
|
+
| 903.3 | Cards that say "can be your commander" | OOS until a card needs it |
|
|
661
|
+
| 903.4, 903.4c–e | Color identity from the card's data (never its text), every face included; `color_identity` overrides | ✓ |
|
|
662
|
+
| 903.4b | Choosing a commander's color before the game | OOS |
|
|
663
|
+
| 903.5a–d | Exactly 100 cards, singleton (basic lands exempt), color identity, basic land types | ✓ |
|
|
664
|
+
| 903.6 | Commanders start in the command zone; their abilities don't function there (113.6) | ✓ |
|
|
665
|
+
| 903.7 | 40 starting life | ✓ |
|
|
666
|
+
| 903.8 | Casting a commander from the command zone, {2} more per earlier cast | ✓ |
|
|
667
|
+
| 903.9a | A commander put into a graveyard or exile may go to the command zone (state-based action, a choice) | ✓ |
|
|
668
|
+
| 903.9b | A commander that would go to its owner's hand or library may go to the command zone instead | ✓ (offered right after the move, see below) |
|
|
669
|
+
| 903.9c | Melded or merged commanders | OOS |
|
|
670
|
+
| 903.10a | 21 combat damage from one commander loses the game | ✓ |
|
|
671
|
+
| 702.124 | Partner and Background (two commanders); commander ninjutsu; cards that refer to "your commander" | OOS until a card needs them |
|
|
672
|
+
|
|
673
|
+
903.9b is a replacement effect, but replacement effects in the engine can't stop to ask a player. The
|
|
674
|
+
commander moves to its owner's hand or library, and before anyone gets priority its owner chooses whether to
|
|
675
|
+
put it into the command zone (the same `commander_zone` decision as 903.9a). The difference shows only if the
|
|
676
|
+
rest of the effect that moved it acts on that hand or library.
|
|
677
|
+
|
|
651
678
|
## Out of scope (listed for completeness)
|
|
652
679
|
|
|
653
680
|
- **Section 8, Multiplayer Rules (800–811)**: range of influence, attack multiple players, Two-Headed Giant, Emperor, and the other team variants.
|
|
654
|
-
- **Section 9, Casual Variants (900–905)**: Planechase, Vanguard,
|
|
681
|
+
- **Section 9, Casual Variants (900–905)**: Planechase, Vanguard, Archenemy, Conspiracy Draft, and multiplayer
|
|
682
|
+
Commander. Two-player Duel Commander is supported (see "Commander (903)").
|
|
655
683
|
- Variant-only card types (311–315), ante (407), stickers (123), Attractions (718, 701.51–52, 702.159), Contraptions (701.45), Space Sculptor (702.158, 704.5u), and the variant SBAs and turn-based actions (704.6, 703.4e, 703.4h).
|
|
656
684
|
- Mechanics that are legal in two-player games but rare (goad, vote, monarch, initiative, companion, dethrone) are kept as **M5**, not OOS.
|
|
657
685
|
|
|
@@ -666,5 +694,5 @@ replacement/prevention (614–616), "dies" and leaves-the-battlefield triggers
|
|
|
666
694
|
|
|
667
695
|
- **613 layers.** The layer pass runs in three stages over the whole battlefield (layers 1–4, 5–6, 7), so a later layer sees earlier results: 7a characteristic-defining power/toughness (604.3, card data `"power": <amount>`), 7b setting effects (`set_base_power_toughness`, 613.4b), 7c counters, static bonuses (fixed or computed) and pumps. Layer 4 sets creature types (205.1a: `creature_types` statics, `set_creature_types` until end of turn). Layer 6 adds keywords and granted triggered/mana abilities (613.1f; refs `granted:<card>:<ref>`). Statics may be conditional (`if`, 604.2) and `affects: "self"`. 613.8 is enforced at build time: statics and characteristic-defining amounts can't read power, toughness or combat status.
|
|
668
696
|
- **"This turn" history.** Per-player turn and game logs (spells cast, permanents that entered/died/returned to hand, life gained/lost, dilemmas faced) and per-object "attacked" and "resolved N times" counts, recorded from events in one hook (a cancelled cast never counts, 601.2i).
|
|
669
|
-
- **608.2h last known information.** A source that leaves the battlefield is remembered by its abilities (power, toughness, counters, controller); "its controller" of a destroyed target uses the controller it last had.
|
|
697
|
+
- **608.2h last known information.** A source that leaves the battlefield is remembered by its abilities (power, toughness, mana value, counters, controller); "its controller" of a destroyed target uses the controller it last had, and its power, toughness and mana value are read as it last existed, as are those of a permanent an earlier effect of the same list sacrificed (`{"result": n}`, a token included) and of one sacrificed to pay the cost (`{"sacrificed": ...}`, 601.2h); a reflexive "when you do" trigger reads what its parent moved the same way (603.12).
|
|
670
698
|
- **202.2 / 204 colors.** Cards have colors from their mana cost or an explicit `colors` list (color indicator, token colors, 111.3); filters take `colors`.
|
data/docs/guides/api.md
CHANGED
|
@@ -138,6 +138,9 @@ A **deck document** carries the cards it uses, so it is self-contained:
|
|
|
138
138
|
- `outside` (optional): cards the player owns outside the game — the sideboard
|
|
139
139
|
that "from outside the game" effects use (CR 400.11). At most 15 (CR 100.4a);
|
|
140
140
|
the copy limit counts both lists.
|
|
141
|
+
- `commander` (optional): the name of the card that leads a Commander deck
|
|
142
|
+
(CR 903.3). It is one of `cards` but not part of `main`, which then holds the
|
|
143
|
+
other 99. See "Commander" below.
|
|
141
144
|
|
|
142
145
|
```ruby
|
|
143
146
|
player = Enjine::Player.new(name: "alice", deck: doc) # doc: Hash or Enjine::Deck
|
|
@@ -155,6 +158,20 @@ reference) raises `Enjine::InvalidDeck`.
|
|
|
155
158
|
While a player is seated in an unfinished game, editing their deck raises
|
|
156
159
|
`Enjine::DeckLocked`.
|
|
157
160
|
|
|
161
|
+
**Commander.** Whether a deck is legal depends on the format the game uses
|
|
162
|
+
(`Enjine::Format`). `deck.errors(format)` and `player.ready?(format)` take it;
|
|
163
|
+
both default to constructed. A Duel Commander deck (`Enjine::Format::DUEL_COMMANDER`)
|
|
164
|
+
has exactly 100 cards with its commander, one copy of each card but basic lands
|
|
165
|
+
(CR 903.5b: "any number" cards are limited to one too), and only cards whose color
|
|
166
|
+
identity is inside the commander's (CR 903.5c). `CardDefinition#color_identity` is
|
|
167
|
+
derived from the card's data, never its text (see the card data format). The engine
|
|
168
|
+
knows no banlist: that is the caller's business.
|
|
169
|
+
|
|
170
|
+
```ruby
|
|
171
|
+
doc = { "cards" => [...], "main" => [{ "card" => "Forest", "count" => 40 }, ...], "commander" => "Wort, the Raidmother" }
|
|
172
|
+
Enjine::Player.new(name: "alice", deck: doc).ready?(:duel_commander) # => true
|
|
173
|
+
```
|
|
174
|
+
|
|
158
175
|
## 4. Setups and games
|
|
159
176
|
|
|
160
177
|
```ruby
|
|
@@ -169,6 +186,34 @@ games from it is cheap, so keep one `Setup` per matchup and create games from it
|
|
|
169
186
|
game = setup.new_game(seed: 42) # Integer seed; drives every random event of the game
|
|
170
187
|
```
|
|
171
188
|
|
|
189
|
+
`format:` picks the rules: `Enjine::Setup.new(alice, bob, format: :duel_commander)`
|
|
190
|
+
plays Duel Commander (CR 903). Each commander starts in the command zone and both
|
|
191
|
+
players start at 40 life. Leaving `format:` out plays constructed, exactly as before.
|
|
192
|
+
In a Commander game:
|
|
193
|
+
|
|
194
|
+
- A commander in the command zone is cast with `{type: "cast", object: id, via: "command"}`.
|
|
195
|
+
Its cost includes the commander tax, {2} for each earlier cast from the command zone (CR 903.8).
|
|
196
|
+
- When a commander goes to a graveyard, exile, hand or library, its owner gets a
|
|
197
|
+
`commander_zone` decision before anyone gets priority: put it into the command zone or leave it (CR 903.9).
|
|
198
|
+
- 21 combat damage from one commander loses the game, with the result reason `"commander_damage"` (CR 903.10a).
|
|
199
|
+
|
|
200
|
+
```ruby
|
|
201
|
+
alice = Enjine::Player.new(name: "alice", deck: alice_doc) # each doc names its "commander"
|
|
202
|
+
bob = Enjine::Player.new(name: "bob", deck: bob_doc)
|
|
203
|
+
game = Enjine::Setup.new(alice, bob, format: :duel_commander).new_game(seed: 1)
|
|
204
|
+
|
|
205
|
+
game.state.command # ids of both commanders, waiting in the command zone
|
|
206
|
+
game.legal_options # at sorcery speed, with enough mana for cost + tax:
|
|
207
|
+
# => [..., {type: "cast", object: "wort_the_raidmother#3", via: "command"}, ...]
|
|
208
|
+
|
|
209
|
+
# After the commander dies (or is exiled, bounced, tucked) its owner decides:
|
|
210
|
+
game.pending_decision.kind # => "commander_zone"
|
|
211
|
+
game.submit(type: "command", object: id) # back to the command zone ({type: "stay", ...} leaves it)
|
|
212
|
+
|
|
213
|
+
game.view_for("alice")["players"][0].slice("commander", "commander_tax", "commander_damage")
|
|
214
|
+
# => {"commander" => "Wort, the Raidmother", "commander_tax" => 2, "commander_damage" => {}}
|
|
215
|
+
```
|
|
216
|
+
|
|
172
217
|
The game starts at its very first decision: the die-roll winner chooses to play
|
|
173
218
|
or draw (CR 103.1), then each player decides on a mulligan.
|
|
174
219
|
|
|
@@ -291,6 +336,7 @@ then `{type: "done"}`. `done` is only offered when the declaration is legal
|
|
|
291
336
|
| `enter_choice` | as a permanent enters ("choose a color", "pay 2 life or enters tapped", "behold or enters tapped") | `color`, `creature_type`, `number`, `name`, `option`, `pay_life`, `behold`, `enter_tapped`, ... |
|
|
292
337
|
| `untap_choice` | "you may choose not to untap" | `untap`, `keep_tapped` |
|
|
293
338
|
| `legend_rule` | two legends with one name | `{type: "keep", object:}` |
|
|
339
|
+
| `commander_zone` | Commander: your commander went to a graveyard, exile, hand or library (CR 903.9) | `{type: "command", object:}`, `{type: "stay", object:}` |
|
|
294
340
|
| `declare_attackers` | your combat | `attack`, `withdraw`, `done` |
|
|
295
341
|
| `declare_blockers` | opponent's combat | `block`, `unblock`, `done` |
|
|
296
342
|
| `assign_damage` | splitting combat damage | `{type: "assign", object:}` |
|
|
@@ -345,6 +391,11 @@ A player entry:
|
|
|
345
391
|
"hand":[ ... ], "outside":[ ... ]}
|
|
346
392
|
```
|
|
347
393
|
|
|
394
|
+
In a Commander game, a player entry also has `"commander"` (the card's name),
|
|
395
|
+
`"commander_tax"` (the extra generic mana their next cast from the command zone
|
|
396
|
+
costs) and `"commander_damage"` (`{commander name => combat damage it dealt them}`).
|
|
397
|
+
The view's `"command"` list holds emblems and the commanders waiting there.
|
|
398
|
+
|
|
348
399
|
`hand` and `outside` appear only for their owner (and the observer); `library`
|
|
349
400
|
(in order, top first) only for the observer; `speed` once the player has one.
|
|
350
401
|
|