enjine 0.3.0 → 0.5.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.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +91 -1
  3. data/SUPPORTED.md +34 -26
  4. data/docs/guides/card-data-format.md +143 -1
  5. data/docs/plans/dsl-gaps.md +99 -0
  6. data/docs/reference/abilities.md +46 -13
  7. data/docs/reference/costs.md +23 -6
  8. data/docs/reference/decisions.md +4 -0
  9. data/docs/reference/effects.md +118 -25
  10. data/docs/reference/filters.md +19 -2
  11. data/docs/reference/keywords.md +16 -2
  12. data/docs/reference/triggers.md +28 -7
  13. data/lib/enjine/actions/cast.rb +10 -3
  14. data/lib/enjine/actions/play_land.rb +3 -1
  15. data/lib/enjine/card_definition.rb +19 -3
  16. data/lib/enjine/cli/text.rb +10 -3
  17. data/lib/enjine/decisions/combat.rb +4 -2
  18. data/lib/enjine/decisions/damage_order.rb +18 -0
  19. data/lib/enjine/engine/ability_layers.rb +6 -1
  20. data/lib/enjine/engine/casting/alt_casting.rb +44 -4
  21. data/lib/enjine/engine/casting/cast_choices.rb +13 -1
  22. data/lib/enjine/engine/casting/casting.rb +43 -7
  23. data/lib/enjine/engine/casting/cost_options.rb +3 -1
  24. data/lib/enjine/engine/casting/permissions.rb +27 -23
  25. data/lib/enjine/engine/casting/target_counts.rb +14 -3
  26. data/lib/enjine/engine/casting/waterbend.rb +22 -2
  27. data/lib/enjine/engine/characteristics.rb +32 -14
  28. data/lib/enjine/engine/combat.rb +26 -7
  29. data/lib/enjine/engine/copies.rb +26 -12
  30. data/lib/enjine/engine/damage.rb +51 -1
  31. data/lib/enjine/engine/durations.rb +47 -0
  32. data/lib/enjine/engine/entering.rb +36 -2
  33. data/lib/enjine/engine/face_down.rb +12 -3
  34. data/lib/enjine/engine/faces.rb +16 -2
  35. data/lib/enjine/engine/follow_ups.rb +4 -1
  36. data/lib/enjine/engine/resolution.rb +46 -1
  37. data/lib/enjine/engine/rules.rb +6 -4
  38. data/lib/enjine/engine/state_based_actions.rb +8 -0
  39. data/lib/enjine/engine/triggers.rb +18 -21
  40. data/lib/enjine/engine/turn_history.rb +16 -1
  41. data/lib/enjine/engine/turn_structure.rb +1 -0
  42. data/lib/enjine/engine/zones.rb +23 -4
  43. data/lib/enjine/events.rb +6 -1
  44. data/lib/enjine/frames.rb +2 -2
  45. data/lib/enjine/mana.rb +3 -0
  46. data/lib/enjine/mechanics/abilities/chosen_values.rb +49 -6
  47. data/lib/enjine/mechanics/abilities/damage_replacements.rb +136 -64
  48. data/lib/enjine/mechanics/abilities/double_counters.rb +1 -1
  49. data/lib/enjine/mechanics/abilities/entering_choices.rb +40 -21
  50. data/lib/enjine/mechanics/abilities/play_permissions.rb +52 -19
  51. data/lib/enjine/mechanics/abilities/player_rules.rb +30 -13
  52. data/lib/enjine/mechanics/abilities/replacement_effects.rb +2 -1
  53. data/lib/enjine/mechanics/abilities/static.rb +8 -1
  54. data/lib/enjine/mechanics/card_spec.rb +99 -14
  55. data/lib/enjine/mechanics/costs/base.rb +67 -9
  56. data/lib/enjine/mechanics/costs/behold.rb +21 -5
  57. data/lib/enjine/mechanics/costs/choose_creature_type.rb +43 -0
  58. data/lib/enjine/mechanics/costs/one_of.rb +3 -0
  59. data/lib/enjine/mechanics/costs/pay_life.rb +27 -8
  60. data/lib/enjine/mechanics/costs/remove_counters.rb +8 -5
  61. data/lib/enjine/mechanics/costs/tap.rb +44 -3
  62. data/lib/enjine/mechanics/effects/base.rb +10 -2
  63. data/lib/enjine/mechanics/effects/become.rb +60 -21
  64. data/lib/enjine/mechanics/effects/copy.rb +63 -23
  65. data/lib/enjine/mechanics/effects/counters.rb +8 -2
  66. data/lib/enjine/mechanics/effects/damage.rb +11 -0
  67. data/lib/enjine/mechanics/effects/earthbend.rb +2 -1
  68. data/lib/enjine/mechanics/effects/fight.rb +11 -0
  69. data/lib/enjine/mechanics/effects/gain_control.rb +6 -3
  70. data/lib/enjine/mechanics/effects/library.rb +76 -18
  71. data/lib/enjine/mechanics/effects/pay.rb +7 -4
  72. data/lib/enjine/mechanics/effects/repeat.rb +92 -0
  73. data/lib/enjine/mechanics/effects/return_to_battlefield.rb +25 -6
  74. data/lib/enjine/mechanics/effects/search.rb +34 -6
  75. data/lib/enjine/mechanics/effects/tokens.rb +42 -10
  76. data/lib/enjine/mechanics/filters/base.rb +40 -13
  77. data/lib/enjine/mechanics/filters/exile.rb +27 -0
  78. data/lib/enjine/mechanics/filters/stack.rb +15 -9
  79. data/lib/enjine/mechanics/keywords/alternative_costs.rb +10 -6
  80. data/lib/enjine/mechanics/keywords/cards_have.rb +65 -0
  81. data/lib/enjine/mechanics/keywords/flags.rb +3 -1
  82. data/lib/enjine/mechanics/keywords/hideaway.rb +6 -5
  83. data/lib/enjine/mechanics/keywords/kicker.rb +24 -6
  84. data/lib/enjine/mechanics/keywords/protection.rb +24 -8
  85. data/lib/enjine/mechanics/keywords/riot.rb +13 -10
  86. data/lib/enjine/mechanics/linked.rb +32 -2
  87. data/lib/enjine/mechanics/selector.rb +32 -9
  88. data/lib/enjine/mechanics/triggers/base.rb +14 -3
  89. data/lib/enjine/mechanics/triggers/casting.rb +16 -10
  90. data/lib/enjine/mechanics/triggers/combat.rb +32 -12
  91. data/lib/enjine/mechanics/triggers/keyword_actions.rb +17 -0
  92. data/lib/enjine/mechanics/triggers/tap_and_counters.rb +38 -11
  93. data/lib/enjine/mechanics/triggers/zone_changes.rb +1 -1
  94. data/lib/enjine/mechanics/values.rb +20 -10
  95. data/lib/enjine/mechanics.rb +5 -0
  96. data/lib/enjine/replacements.rb +3 -2
  97. data/lib/enjine/rules_monitor.rb +17 -4
  98. data/lib/enjine/steps.rb +10 -1
  99. data/lib/enjine/version.rb +1 -1
  100. data/lib/enjine/view.rb +1 -1
  101. metadata +7 -1
@@ -235,6 +235,7 @@ have '[−2]: …'" is `{ "static": { "affects": { "each": "planeswalker", "cont
235
235
  | Oracle words | Data |
236
236
  | --- | --- |
237
237
  | "you control" / "an opponent controls" | `{ "creature": { "controller": "you" } }` |
238
+ | "you own" / "an opponent owns", "you control but don't own" | `{ "creature": { "owner": "you" } }`, `{ "creature": { "controller": "you", "owner": "opponent" } }` (CR 108.3; also in a `static`'s `affects.each`) |
238
239
  | "another" | `{ "creature": { "other": true } }` |
239
240
  | "nonland", "artifact or creature" | `{ "permanent": { "not": ["land"] } }`, `{ "permanent": { "any_of": ["artifact", "creature"] } }` |
240
241
  | "artifact creature" | `{ "creature": { "types": ["artifact"] } }` |
@@ -252,6 +253,21 @@ have '[−2]: …'" is `{ "static": { "affects": { "each": "planeswalker", "cont
252
253
  | "with flying", "with flying or reach", "without flying" | `{ "creature": { "keywords": ["flying"] } }`, `{ "creature": { "keywords": ["flying", "reach"] } }`, `{ "creature": { "not_keywords": ["flying"] } }` (current keywords: granted ones count, CR 702.1) |
253
254
  | "of the chosen color / creature type / card type", "not of the chosen type" | `{ "creature": { "subtypes": "chosen" } }`, `{ "spell": { "colors": "chosen" } }`, `{ "permanent": { "types": "chosen" } }`, `{ "creature": { "not_subtypes": "chosen" } }` (see 4.15) |
254
255
 
256
+ **Card specs.** Effects that look at cards in any zone (graveyard, hand, library, exile; `for`,
257
+ `card`, `cards`, `spells`) describe the card with a card spec: `"card"` (any card) or an object
258
+ whose qualities must all match:
259
+
260
+ | Card words | Card spec |
261
+ | --- | --- |
262
+ | "a basic land card", "a Swamp card", "a card named X" | `{ "types": ["land"], "supertypes": ["basic"] }`, `{ "subtypes": ["swamp"] }`, `{ "name": "X" }` |
263
+ | "a noncreature, nonland card", "a permanent card" | `{ "not_types": ["creature", "land"] }`, `{ "permanent": true }` |
264
+ | "a non-Avatar creature card" | `{ "types": ["creature"], "not_subtypes": ["avatar"] }` |
265
+ | "a creature card with flying" | `{ "types": ["creature"], "keywords": ["flying"] }` (any listed keyword) |
266
+ | "with mana value 3 or less", "with power or toughness 1 or less" | `{ "mana_value": { "at_most": 3 } }`, `{ "any_of": [{ "power": { "at_most": 1 } }, { "toughness": { "at_most": 1 } }] }` |
267
+ | "a black card", "a monocolored card" | `{ "colors": ["B"] }`, `{ "color_count": { "equal": 1 } }` |
268
+ | "a card that has an Adventure" | `{ "layout": "adventure" }` (any card layout: adventure, omen, prepare, transform, modal, meld) |
269
+ | "an instant or sorcery card" | `{ "any_of": [{ "types": ["instant"] }, { "types": ["sorcery"] }] }` |
270
+
255
271
  ### 4.5 Who an effect applies to: the `to` selector
256
272
 
257
273
  | Selector | Oracle words |
@@ -298,6 +314,7 @@ is a flicker ("exile …, then return it to the battlefield under its owner's co
298
314
  | --- | --- |
299
315
  | "Whenever ~ becomes tapped" | `{ "becomes_tapped": {} }` |
300
316
  | "Whenever one or more +1/+1 counters are put on ~" | `{ "counters_placed": { "counter": "+1/+1" } }` |
317
+ | "Whenever you put one or more +1/+1 counters on a creature you control" | `{ "counters_placed": { "subject": { "each": "creature", "controller": "you" }, "counter": "+1/+1", "by": "you" } }` (who put them, CR 122.6a; a permanent's controller puts the counters it enters with) |
301
318
  | one of your creatures is targeted by an opponent's spell or ability | `{ "becomes_target": { "subject": { "each": "creature", "controller": "you" }, "by": "opponent" } }` |
302
319
  | "Whenever a card leaves your graveyard" / "one or more cards leave" | `{ "leaves_graveyard": {} }` / `{ "leaves_graveyard": { "batched": true } }` |
303
320
  | "Whenever an opponent activates an ability" (not mana abilities) | `{ "activates_ability": { "controller": "opponent" } }` |
@@ -357,6 +374,9 @@ See `docs/reference/effects.md` for the generated list. Currently:
357
374
  | `pump` | "gets +X/+Y until end of turn" | `{ "pump": { "power": X, "toughness": Y, "to": … } }` |
358
375
  | `pump` | "get -1/-0 until your next turn" | `{ "pump": { "power": -1, "toughness": 0, "duration": "until_your_next_turn", "to": … } }` (ends as your next turn begins, CR 611.2a) |
359
376
  | `grant`, `become` | "gain flying until your next turn", "until your next turn, it becomes a land" | `"duration": "until_your_next_turn"` on `grant` or `become` |
377
+ | `become_copy` | "it becomes a copy of that creature until your next turn" | `"duration": "until_your_next_turn"` |
378
+ | `gain_control` | "gain control of it until the end of your next turn" | `"duration": "end_of_your_next_turn"` (control returns at that turn's cleanup) |
379
+ | `play_permission` | "you may play that card until your next end step" | `"duration": "until_your_next_end_step"` (ends as your next end step begins; made during your own end step, it lasts until next turn's) |
360
380
  | `add_counters` | "put N +1/+1 counters on …" | `{ "add_counters": { "counter": "+1/+1", "amount": N, "to": … } }` (any counter name: `+1/+1`, `stun`, `shield`, `oil`, a keyword; see `docs/reference/counters.md`) |
361
381
  | `gain_life` | "you gain N life" | `{ "gain_life": { "amount": N } }` (`to` defaults to `"you"`) |
362
382
  | `lose_life` | "each opponent loses N life" | `{ "lose_life": { "amount": N, "to": "each_opponent" } }` |
@@ -793,6 +813,23 @@ Elemental creature with haste until end of turn. It's still a land.":
793
813
  "becomes a legendary Spider Hero in addition to its other types" is `"supertypes": ["legendary"],
794
814
  "subtypes": ["spider", "hero"]`. Static abilities take `types` the same way.
795
815
 
816
+ **Setting card types and creature types** (CR 205.1a, 205.3d). `set_types` replaces the card types
817
+ (in timestamp order with the types other resolved effects add, CR 613.7a; static abilities that change
818
+ types apply after resolved effects for now); subtypes correlated with a
819
+ card type it no longer has are lost (creature types without creature, Treasure without artifact), and
820
+ a permanent that is no longer a creature has no power or toughness. `"creature_types": []` removes
821
+ every creature type; `"all_creature_types": true` gives them all (not the changeling ability).
822
+ `return_to_battlefield` takes the same changes as `as`: what the card is from the moment it enters, so
823
+ abilities that trigger on it entering see it so (CR 614.1c).
824
+
825
+ | Card text | Script |
826
+ |---|---|
827
+ | "When this dies, if it was a creature, return it to the battlefield under its owner's control. It's an enchantment. (It's not a creature.)" | trigger `{ "dies": {} }` with `"if": { "triggering": "creature" }` (past tense: the card types it last had on the battlefield, CR 603.10a) and `{ "return_to_battlefield": { "to": { "triggering": "object" }, "as": { "set_types": ["enchantment"] } } }` |
828
+ | "the chosen permanents become Treasure artifacts with '…' and lose all other abilities" | `{ "become": { "set_types": ["artifact"], "subtypes": ["treasure"], "loses_abilities": true, "abilities": [ … ], "to": { "target": 0 } } }` |
829
+ | "Until your next turn, he becomes a land and gains '{T}: Add {U}.' (He's not a creature during that time.)" | `become` with `"set_types": ["land"]`, `"duration": "until_your_next_turn"` |
830
+ | "gets +3/-3 and loses all creature types until end of turn" | `pump`, then `{ "become": { "creature_types": [], "to": { "target": 0 } } }` |
831
+ | "becomes a 3/3 creature with vigilance and all creature types" | `become` with `"types": ["creature"]`, `"all_creature_types": true`, `"keywords": ["vigilance"]`, `base_power_toughness` |
832
+
796
833
  **Exhaust** (CR 702.177). "Exhaust — {2}{G}: …" is an activated ability with `"exhaust": true`: it
797
834
  can be activated only once for as long as the permanent stays. "Whenever you activate an exhaust
798
835
  ability" is `{ "activates_ability": { "exhaust": true } }`.
@@ -1335,7 +1372,7 @@ grants its abilities.
1335
1372
  | "Suspend 3—{2}{W}" (CR 702.62a) | ability `{ "suspend": { "amount": 3, "cost": "{2}{W}" } }`: the special action exiles it with three time counters whenever you could begin to cast it |
1336
1373
  | "exile it with four time counters on it. If it doesn't have suspend, it gains suspend" | effect `{ "suspend": { "to": …, "amount": 4 } }` (a spell, a card or a permanent); a card that has suspend from the start is `"keywords": ["suspend"]` |
1337
1374
  | suspended cards (CR 702.62b) | automatic: at the beginning of its owner's upkeep a time counter is removed; when the last is removed they may play it without paying its mana cost (`effect_choice` `{type: "cast"}` / `{type: "play_land"}`), and a creature spell cast this way has haste while they control it |
1338
- | "Hideaway 4" (CR 702.75a) | ability `{ "hideaway": { "amount": 4 } }`: the exiled card is `"exiled_with"` the permanent, face down, and only its controller may look at it |
1375
+ | "Hideaway 4" (CR 702.75a) | ability `{ "hideaway": { "amount": 4 } }`: the exiled card is `"exiled_with"` the permanent, face down, and only the player who controls the permanent may look at it |
1339
1376
  | "You may play the exiled card without paying its mana cost" | `{ "cast_free": { "to": "exiled_with", "play": true } }` (`play: true` also plays a land, on your turn with a land play left, CR 305.2a, 305.3) |
1340
1377
  | "look at the top N cards, exile one face down" | `{ "dig": { "amount": N, "put": "exile", "face_down": true, "link": true } }` (`link`: exiled with the source) |
1341
1378
  | "Devour land 3" (CR 702.82c) / "Devour 2" | ability `{ "devour": { "amount": 3, "each": "land" } }` / `{ "devour": { "amount": 2 } }`: as it enters, `enter_choice` `{type: "devour", object: id}` picks permanents one at a time, then `{type: "done"}`; it enters with N +1/+1 counters for each and remembers how many it devoured |
@@ -1352,6 +1389,111 @@ grants its abilities.
1352
1389
  { "foretell": { "cost": "{1}{R}" } }] }
1353
1390
  ```
1354
1391
 
1392
+ ### 4.30 Casting permissions: "for as long as you control", flash by a cost, granted sneak, costs that read the board
1393
+
1394
+ | Oracle text | Data |
1395
+ | --- | --- |
1396
+ | "You may play that card for as long as you control this creature" (CR 611.2b) | `{ "play_permission": { "to": { "result": 0 }, "duration": "while_you_control_source" } }` (ends when the source leaves or changes control; never starts if that already happened) |
1397
+ | "For as long as you control Hama, you may cast the exiled card during your turn by waterbending {X} rather than paying its mana cost, where X is its mana value" (CR 701.67a, 118.9) | the same with `"play": "cast", "during": "your_turn", "waterbend": "mana_value"` (pay_cost `{type: "waterbend", object: id}` taps an artifact or creature for {1}) |
1398
+ | "You may cast this spell as though it had flash if you behold a Dragon as an additional cost" (CR 601.3c) | `{ "additional_cost": { "cost": [{ "behold": { "card": { "subtypes": ["dragon"] } } }], "optional": true, "flash": true } }`: at instant speed only `kick` is offered |
1399
+ | "As an additional cost to cast this spell, you may choose a creature type and behold two creatures of that type" (CR 601.2b, 607.2d) | `"cost": [{ "choose_creature_type": {} }, { "behold": { "card": { "types": ["creature"], "subtypes": "chosen" }, "count": 2 } }]` with `"optional": true` (`choose_cost` option `{type: "cost", creature_type: "elf"}`; the spell remembers the type) |
1400
+ | "If this spell's additional cost was paid and the revealed card is the chosen type, put that card onto the battlefield instead" | `search_library` with `"battlefield_instead": { "if": { "cast_with": "additional_cost" }, "for": { "subtypes": "chosen" } }` |
1401
+ | "Discard a legendary card with the same name as a legendary permanent you control" (CR 201.2a) | `{ "discard": { "card": { "supertypes": ["legendary"], "same_name_as": { "permanent": { "supertypes": ["legendary"], "controller": "you" } } } } }` (a card spec relation, read for whoever pays) |
1402
+ | "Exile any number of black cards from your graveyard with fifteen or more black mana symbols among their mana costs: Copy those exiled cards. You may cast up to three of the copies without paying their mana costs." (CR 107.4e, 707.12) | cost `{ "exile_from_graveyard": { "count": "any", "card": { "colors": ["B"] }, "symbols": { "color": "B", "at_least": 15 } } }` (choose cards, `done` once enough symbols are chosen); effects `{ "copy_card": { "of": "exiled_for_cost" } }`, `{ "cast_free": { "to": { "result": 0 }, "count": 3 } }` |
1403
+ | "Whenever Bilbo attacks, you may cast an artifact, instant, or sorcery spell from your graveyard. If an instant or sorcery spell cast this way would be put into your graveyard, exile it instead." (CR 608.2g) | `{ "cast": { "from": "graveyard", "for": { "any_of": [...] }, "exile_instead": { "any_of": [{ "types": ["instant"] }, { "types": ["sorcery"] }] } } }` (`from` also on `cast_free`; `count` takes an integer: "up to N") |
1404
+ | "Creature cards in your graveyard have sneak {3}{B}. You may cast creature spells from your graveyard using their sneak abilities." (CR 611.3a) | `{ "cards_have": { "zone": "graveyard", "cards": { "types": ["creature"] }, "ability": { "sneak": { "cost": "{3}{B}" } } } }` (flashback, harmonize, mayhem, web-slinging or sneak; cast option `via: "alt:cards_have:<permanent>:<ref>"`) |
1405
+ | "Whenever you cast a spell you don't own" (CR 108.3) | trigger `{ "cast": { "owner": "not_you" } }` (`"you"`: one you own) |
1406
+ | "Ward—Pay life equal to Raubahn's power" (CR 702.21a) | `{ "ward": { "cost": [{ "pay_life": { "power": "self" } }] } }` (`pay_life` takes an amount, computed as it's paid) |
1407
+ | "Whenever you give a gift" (CR 702.174c) | trigger `{ "gives_gift": {} }`: a gift-promised instant or sorcery you control resolves, or a permanent's gift trigger (`"if": { "cast_with": "gift" }`) resolves |
1408
+ | "Remove two counters from Ghost-Spider" | `{ "remove_counters": { "count": 2, "self": true } }` |
1409
+
1410
+ A card's colors include those of its hybrid symbols (CR 202.2d), so a `{U/B}` card is a black card for `"colors": ["B"]`.
1411
+
1412
+ ```json
1413
+ { "name": "Example Bloodwater Adept", "mana_cost": "{2}{U}{B}", "types": ["creature"], "subtypes": ["human", "warlock"],
1414
+ "power": 3, "toughness": 3,
1415
+ "abilities": [{ "triggered": { "when": { "enters": {} },
1416
+ "effects": [{ "exile_top": { "amount": 1 } },
1417
+ { "play_permission": { "to": { "result": 0 }, "play": "cast",
1418
+ "duration": "while_you_control_source",
1419
+ "during": "your_turn", "waterbend": "mana_value" } }] } }] }
1420
+ ```
1421
+
1422
+ ### 4.31 Rules correctness: ordering damage effects, new targets, chosen sources, entering attacking
1423
+
1424
+ These need no new data: the shapes above play by these rules.
1425
+
1426
+ | Rule | How the engine applies it |
1427
+ | --- | --- |
1428
+ | Several replacement and prevention effects apply to one damage event (CR 616.1, 616.1e-f) | Redirections (`redirect`) apply first. When the order of the others changes the result (the damage dealt, a shield left, a `then` amount), the affected player (the player dealt damage, or the permanent's controller) gets a `damage_order` decision before the damage is dealt: options `{type: "order", order: [keys], steps: [labels], amount: n}`, one per distinct result, asked in APNAP order for combat damage. Otherwise nothing is asked and the order is prevention, multiplying, adding (statics before resolved effects). Each effect applies once; after each, the others are rechecked |
1429
+ | "Damage can't be prevented" against a prevention effect with `then` (CR 615.12) | The prevention effect still applies once: nothing is prevented, a shield (`next`, `next_time`) isn't used up, and its `then` happens with `{"triggering": "amount"}` 0, except a `reflexive_trigger` ("when damage is prevented this way") |
1430
+ | `choose_new_targets`, `copy_spell` (CR 115.7, 707.10, 702.21a) | Each new target, and each target of a copy, becomes a target of that spell or ability: ward and `becomes_target` trigger (for the spell's controller) |
1431
+ | New targets for a divided spell (CR 115.7f, 601.2d) | Each target's share of the division goes to the target that replaced it; a new target can't be another target of the same spell |
1432
+ | `prevent_damage` with `"by": "chosen_source"` (CR 609.7a-b) | The choice includes permanents, spells and abilities on the stack, objects they refer to (targets, an ability's source) and objects in the command zone. A chosen permanent spell's damage is prevented also once it is a permanent |
1433
+ | `create_token` with `attacking: true` (CR 508.4) | When the defending player controls a planeswalker, the controller chooses for each token what it attacks: an `effect_choice` of `{type: "attack", target: ref}` |
1434
+ | `copy_spell` of `{"triggering": "ability"}` after that ability left the stack (CR 707.10, 608.2h) | The engine's reading for "copy that ability" (Firebender Ascension): it is copied as it last existed on the stack, with its targets, modes and X |
1435
+
1436
+ ### 4.32 Statics, grants and combat: granted costs, bound choices, chosen names, riot grants, attacking alone
1437
+
1438
+ | Oracle text | Data |
1439
+ | --- | --- |
1440
+ | "Equipped creature has '{1}, {T}, Tap Fishing Pole: Put a bait counter on Fishing Pole.'" (CR 602.2b, 607.1a) | granted `activated` with `"cost": [{ "mana": "{1}" }, "tap", { "tap": "granter" }]` and `"to": "granter"` (the cost taps the permanent that granted this ability; not {T}, so summoning sickness doesn't matter) |
1441
+ | "remove a bait counter from this Equipment. If you do, create …" | `remove_counters`, then the effect with `"if": { "amount": { "this_way": 0 }, "at_least": 1 }` (how many were removed) |
1442
+ | "Until end of turn, ~ becomes the color of your choice and gains hexproof from that color" (CR 607.2d) | `{ "choose_color": {} }`, then `{ "become": { "colors": "chosen", "abilities": [{ "hexproof_from": "chosen_color" }], "to": "self" } }`: the color is bound into the granted ability as it resolves, so a second activation with another color adds a second hexproof (`"chosen_color"` on a permanent that chose as it entered reads its own choice) |
1443
+ | "That creature can't become untapped for as long as you control ~" (CR 701.26b) | `{ "become": { "keywords": ["cant_become_untapped"], "duration": "while_you_control_source", "to": { "target": 0 } } }` (neither the untap step nor "untap it" untaps it; `doesnt_untap` only stops the untap step); "Enchanted creature can't become untapped" is a `static` handing out the same keyword |
1444
+ | "As this artifact enters, look at an opponent's hand, then choose any card name" | `{ "choose_card_name": { "look_at_hand": "opponent" } }` (`types`: `["land"]` for "a land card name") |
1445
+ | "When this land enters, choose a land card name." (a triggered ability, linked to the land's other abilities) | effect `{ "choose_card_name": { "types": ["land"], "remember": "source" } }` (`remember: "source"` works for every resolving `choose_*`) |
1446
+ | "Activated abilities of sources with the chosen name can't be activated unless they're mana abilities" (CR 201.4, 602.5) | `{ "player_rule": { "rule": "cant_activate", "affects": "each", "name": "chosen" } }` (sources in any zone: cycling from a hand is stopped too) |
1447
+ | "Lands with the chosen name have '{T}: Add {C}.'" | `static` with `"affects": { "each": { "land": { "name": "chosen" } } }` (filter key `"name": "chosen"`) |
1448
+ | "Other Spiders you control have riot" (CR 614.12, 702.136b) | `static` with `"keywords": ["riot"]`: a Spider entering while it applies makes riot's choice as it enters (a Spider with its own riot chooses twice); haste chosen this way stays after the riot is gone |
1449
+ | "Whenever a creature you control attacks alone, it gains double strike until end of turn" (CR 506.5) | trigger `{ "attacks": { "subject": { "each": "creature", "controller": "you" }, "alone": true } }` (once attackers are declared), effect `grant` to `{ "triggering": "object" }` |
1450
+ | "Creatures with flying can't attack you" (CR 508.1c) | `{ "player_rule": { "rule": "cant_be_attacked", "filter": { "creature": { "keywords": ["flying"] } } } }` (your planeswalkers can still be attacked) |
1451
+ | "… or block creatures you control" | `static` granting creatures you control `{ "cant_be_blocked_by": { "filter": { "creature": { "keywords": ["flying"] } } } }` |
1452
+ | "Create an X/X white Spirit creature token, where X is the greatest toughness among creatures you control" | `create_token` with `"size": { "greatest_toughness": { "each": "creature", "controller": "you" } }` (the token data says 0/0) |
1453
+ | "Each creature you control with toughness greater than its power assigns combat damage equal to its toughness" (CR 510.1a) | `static` handing out `assigns_damage_by_toughness` (attacking and blocking) |
1454
+ | "This creature saddles Mounts and crews Vehicles using its toughness" gained by an effect | `become` with `"abilities": [{ "tapping_power": … }]` |
1455
+
1456
+ ```json
1457
+ { "name": "Example Lure Angler", "mana_cost": "{1}", "types": ["artifact"], "subtypes": ["equipment"],
1458
+ "abilities": [{ "static": { "affects": "attached", "abilities": [
1459
+ { "activated": { "cost": ["tap", { "tap": "granter" }],
1460
+ "effects": [{ "add_counters": { "counter": "bait", "amount": 1, "to": "granter" } }] } }] } },
1461
+ { "equip": { "cost": [{ "mana": "{1}" }] } }] }
1462
+
1463
+ ### 4.33 Loops, exiling until, cards exiled with a permanent, changing targets and the Nth counter
1464
+
1465
+ | Oracle text | Data |
1466
+ | --- | --- |
1467
+ | "[effects]. If the exiled card is a land card, repeat this process." (CR 608.2c) | `{ "repeat": { "effects": [...], "while": condition } }`: the effects run, then run again while `while` holds. Each pass has results of its own: `{ "result": n }` in the list and in `while` is what effect n did during this pass (at most 100 passes) |
1468
+ | "the exiled card is a land card" | selector `{ "result": 0, "for": { "types": ["land"] } }` (only the results matching a card spec), e.g. `"while": { "amount": { "count": { "result": 0, "for": { "types": ["land"] } } }, "at_least": 1 }` |
1469
+ | "exile a permanent card from your graveyard at random" | `{ "choose_cards": { "from": { "graveyard": "you" }, "for": { "permanent": true }, "random": true, "put": "exile" } }` |
1470
+ | "Exile cards from the top of your library until you exile cards with total mana value 4 or greater" (CR 406.1) | `{ "exile_top": { "until": { "total_mana_value": 4 } } }` (`until` replaces `amount`; the cards are the effect's result) |
1471
+ | "… until they exile a nonland card" | `{ "exile_top": { "to": "each_opponent", "until": { "card": { "not_types": ["land"] } } } }` |
1472
+ | "You may cast any number of spells from among them without paying their mana costs" | `{ "cast_free": { "to": { "result": 0 }, "count": "any" } }` |
1473
+ | "target creature card exiled with [this]" (CR 607.2a) | target filter `{ "exiled_with": { "any_of": ["creature"] } }`: a card in exile that one of this object's abilities exiled (`link: true` on `exile`, `choose_cards`, `dig`, `exile_top`; `exile_if_dies`) |
1474
+ | "Black spells you cast cost {1} less" | `{ "cost_modifier": { "spells": { "colors": ["B"] }, "reduce": 1 } }` |
1475
+ | "If it was attacking, …" (CR 608.2h) | condition `{ "attacking": { "target": 0 } }`: it's attacking, or, if it left the battlefield during this resolution, it was as it last existed |
1476
+ | "When the fourth plan counter is put on this enchantment" (CR 122.6) | trigger `{ "counters_placed": { "counter": "plan", "nth": 4 } }`: the event that takes it from fewer than four plan counters to four or more |
1477
+ | "sacrifice it. When you do, it deals 7 damage divided as you choose among one or two targets" | `[{ "sacrifice": { "to": "self" } }, { "reflexive_trigger": { "if": { "amount": { "count": { "result": 0 } }, "at_least": 1 }, "targets": [{ "filter": "any_target", "count": 2, "optional": true }], "divide": 7, "effects": [{ "distribute_damage": {} }] } }]` |
1478
+ | "target spell or ability with a single target" | `{ "one_of": [{ "spell": { "single_target": true } }, { "stack_ability": { "single_target": true } }] }` |
1479
+ | "Change the target of target spell or ability" (CR 115.7a) | `{ "change_target": { "of": { "target": 0 } } }`: you choose another legal target for each of its targets (`effect_choice` `{type: "target"}`); a target with no other legal target stays, and then none change. "You may choose new targets" is `choose_new_targets` (CR 115.7d) |
1480
+ | "Assimilate a creature card exiled with it. If you can't, exile up to one target creature." (CR 701.72b, 607.2a) | `[{ "assimilate": { "to": "exiled_with", "for": { "types": ["creature"] }, "choose": true } }, { "exile": { "to": { "target": 0 }, "link": true, "if": { "amount": { "count": { "result": 0 } }, "at_most": 0 } } }]`, with the target `{ "filter": "creature", "optional": true }` |
1481
+
1482
+ Also automatic:
1483
+ - A melded permanent's mana value is the total of its two front faces' (CR 713.5c). As the pair is melded, the second
1484
+ card's move from exile is an event of its own (`zone_changed` with `new_id: null`).
1485
+ - A hidden-away card (hideaway, CR 702.75a) may be looked at, and played, by whoever controls the permanent now
1486
+ (`dig` with `looker: "source_controller"`).
1487
+ - Earthbend's "when that land dies or is put into exile" ends when the land leaves the battlefield for any other zone.
1488
+
1489
+ ```json
1490
+ { "name": "Example Echo of the Depths", "mana_cost": "{3}{B}", "types": ["sorcery"],
1491
+ "abilities": [{ "spell": { "effects": [{ "repeat": {
1492
+ "effects": [{ "mill": { "amount": 1 } },
1493
+ { "return_to_battlefield": { "to": { "result": 0, "for": { "types": ["land"] } }, "tapped": true } }],
1494
+ "while": { "amount": { "count": { "result": 0, "for": { "types": ["land"] } } }, "at_least": 1 } } }] } }] }
1495
+ ```
1496
+
1355
1497
  ---
1356
1498
 
1357
1499
  ## 5. Worked examples
@@ -1,5 +1,104 @@
1
1
  # DSL gaps: mechanics missing for FAIL and PARTIAL cards
2
2
 
3
+ ## Ranking of 2026-11-20 (enjine 0.3.0)
4
+
5
+ Source: deckfinder `card_scripts`, all 303 PARTIAL and 60 FAIL scripts (365 cards with the
6
+ "missing" note of each). Every card was tagged by hand with **every** gap its note names, so a card
7
+ counts as made exact only when all of its gaps are closed. The order is greedy: at each step, the change
8
+ that makes the most cards exact per unit of effort (S = 1, M = 2, L = 3+, from a skim of `lib/`).
9
+
10
+ - **Batch 1 done (Unreleased), verified:** `counters_placed by`, filter `owner`, card-spec keywords/
11
+ not_subtypes/power/toughness/layout, and the turn-counted durations. Re-scripted and passing
12
+ `enjine --verify` (10–12 rules-monitored games each): Ant-Man, Exemplar of Light, Inspired Tethermage,
13
+ Knight of Wundagore, Mikey & Leo, The Great Goblin, Charming Prince, Get Out, Northampton Farm,
14
+ The Eagles Are Coming!, Laughing Jasper Flint, Steamcore Scholar, Absorbing Man, Haste Magic, Inti
15
+ (**15 exact**, against the 30 the tag count promised). Still blocked by a second gap: Beast and Kid
16
+ Loki (a live static), Invisible Woman (batching across permanents), Terrasymbiosis (once-each-turn
17
+ may), Boiling Rock Rioter and Starfall Invocation (owner on exiled/destroyed card specs), Clash of
18
+ Elements (the owner decides and is dealt the damage), Iroh (computed enters-with counters), April
19
+ O'Neil and Codie (kindred / prepared spell filters), Hearth Elemental (the graveyard count uses a
20
+ permanent-style filter, not a card spec), Leonardo (play_from has no "during your turn"),
21
+ Evil's Thrall (mana-value comparison condition), Dragonhawk ("still exiled").
22
+ - **Batch 2 done (Unreleased), verified:** `become` `set_types`, `"creature_types": []`,
23
+ `all_creature_types`, `return_to_battlefield` `as`, and `{"triggering": filter}` reading last-known card
24
+ types. Re-scripted and passing `enjine --verify` (seeds 0 and 7): Enduring Courage, Enduring Curiosity,
25
+ Enduring Innocence, Tom, Bert, and William, Kitesail Larcenist, Hydro-Man, Nameless Inversion, Soulstone
26
+ Sanctuary (**8 exact**, of the 10 change 5 promised). Still blocked: The Irencrag (become a named
27
+ Equipment with equip), Brilliance Unleashed (its own return effect, not yet re-scripted with `as`).
28
+ Known gap: layer 4 applies resolved type effects (in timestamp order) before statics that change types,
29
+ whatever their timestamps (CR 613.7a wants one order for both).
30
+ - **Batch 3 done (0.5.0), engine side:** each gap is covered by real-card specs
31
+ (`spec/integration/real_cards/known_gaps_*_spec.rb`) and invented fuzz cards; the cards still need re-scripting in
32
+ deckfinder and an `enjine --verify` run before they count as exact.
33
+ - Casting and permissions (change 24 in part, cluster 2): `play_permission` `while_you_control_source`, `during`,
34
+ `waterbend` (Hama); flash by an optional additional cost (Molten Exhale); `choose_creature_type` cost and
35
+ `battlefield_instead` (Celestial Reunion); card spec `same_name_as` (Key to the Side-Door); `exile_from_graveyard`
36
+ by mana symbols and `copy_card` (Baron Helmut Zemo); `cast` from the graveyard with `exile_instead` (Bilbo);
37
+ `cards_have` (Ninja Teen level 3); `cast` trigger `owner` (Nita); computed `pay_life` in ward (Raubahn);
38
+ `remove_counters` `self`/`count` (Gwen Stacy // Ghost-Spider); `gives_gift`.
39
+ - Effects, zones and loops (changes 9 and 10): `repeat` (Sin, Spira's Punishment); `exile_top` `until`
40
+ (Improvisation Capstone); `exiled_with` targets (The Darkness Crystal, Borg Cube); `attacking` condition
41
+ (Desculpting Blast); `counters_placed` `nth` (Death to Our Enemies); `change_target` and `single_target`
42
+ (Redirect Lightning); meld mana value, hideaway under another controller, earthbend's return ending.
43
+ - Statics, grants and combat (change 30, change 27 in part, change 24): `{"tap": "granter"}` (Fishing Pole);
44
+ `colors: "chosen"` with bound `hexproof_from` (Mondo Gecko); `cant_become_untapped` (Spider-Woman);
45
+ `choose_card_name` and `"name": "chosen"` (Sorcerous Spyglass, Petrified Hamlet); granted riot (Spider-Punk);
46
+ `attacks` `alone` (Seifer Almasy); `cant_be_attacked` by filter and grantable `cant_be_blocked_by` (Storm,
47
+ Windrider); `create_token` `size` (Abzan Monument); `assigns_damage_by_toughness` (Ghalta); `tapping_power`
48
+ granted by `become`.
49
+ - Rules correctness (no new data): the `damage_order` decision (CR 616.1), unpreventable damage against prevention
50
+ with `then` (CR 615.12), new targets and copy targets becoming targets (ward, `becomes_target`), divided new
51
+ targets, chosen sources on the stack, tokens entering attacking a planeswalker, "copy that ability" by last
52
+ known information.
53
+ - 81 cards have only a one-off gap (no change below helps them); 284 share at least one listed gap.
54
+ - The first 4 changes (all S) make **30** cards exact; the first 20 make about **95**; the first 30
55
+ about **150**.
56
+ - Notes that look stale (written before 0.2.0, worth re-scripting first, no engine work): The Wind Crystal
57
+ (cost_modifier colors exist), Armor Wars chapter III (`greatest_mana_value`), Fblthp (`library_size`),
58
+ Dina's Guidance (`search_library put: graveyard`), Terror of the Peaks and Bolg of the North (0.2.0
59
+ last-known-information work; check in a game).
60
+
61
+ | # | Change | Effort | Cards made exact | Cumulative effort → exact | Examples |
62
+ |---|---|---|---|---|---|
63
+ | 1 | `counters_placed` `by: you`; a "you put counters on it this turn" filter (CountersChanged carries who put them) | S | 9 | 1 → 9 | Ant-Man, Beast, Exemplar of Light, Inspired Tethermage |
64
+ | 2 | `owner: you/opponent` on permanent filters and selectors ("creature you own") | S | 9 | 2 → 18 | Boiling Rock Rioter, Charming Prince, Clash of Elements, Get Out |
65
+ | 3 | card-spec filters: keyword, Adventure/prepared layout, kindred, non-subtype, power/toughness in `play_from` | S | 6 | 3 → 24 | April O'Neil, Bandit's Talent, Codie, Hearth Elemental |
66
+ | 4 | `until_your_next_turn` / until-your-next-end-step on `become_copy`, `gain_control`, permissions | S | 6 | 4 → 30 | Absorbing Man, Dragonhawk, Evil's Thrall, Haste Magic |
67
+ | 5 | `become` `set_types` (and lose creature types/add supertype/set name); fix the monitor's CR 613.4c recompute | M | 10 | 6 → 40 | Brilliance Unleashed, Enduring Courage, Enduring Curiosity, Enduring Innocence |
68
+ | 6 | cost_modifier: condition, first spell each turn, one-turn effect, keyword or chosen-type spells | M | 6 | 8 → 46 | Arachne, Armor Wars, Don & Raph, Eluge |
69
+ | 7 | last-known counters and combat status of a creature that left; move every counter kind | M | 6 | 10 → 52 | Aerith Gainsborough, Ares, Donatello, Essence Channeler |
70
+ | 8 | "descended this turn" (a permanent card put into your graveyard from anywhere) | S | 3 | 11 → 55 | Corpses of the Lost, Molten Collapse, Stalactite Stalker |
71
+ | 9 | "one or two targets": a minimum target count | S | 3 | 12 → 58 | Atlantis Attacks, Heroes' Hangout, Leonardo's Technique |
72
+ | 10 | must-change form of `choose_new_targets`; single-target stack filter | S | 4 | 13 → 62 | Bolt Bend, Redirect Lightning, Return the Favor, Untimely Malfunction |
73
+ | 11 | offspring keyword (CR 702.175) | S | 3 | 14 → 65 | Coruscation Mage, Iridescent Vinelasher, Starscape Cleric |
74
+ | 12 | attack triggers know whether a player or a planeswalker is attacked | S | 3 | 15 → 68 | Attuma, Garruk, Preacher of the Schism |
75
+ | 13 | `remove_counters` cost from this permanent | S | 3 | 16 → 71 | Drake Hatcher, Flitterwing Nuisance, Leatherhead |
76
+ | 14 | `enters_with_counters` with a condition or computed count for others | M | 6 | 18 → 77 | Dust Animus, Gev, Giada, Myojin of Night's Reach |
77
+ | 15 | `add_mana` `until: end_of_turn` (mana not lost as steps end) | S | 3 | 19 → 80 | Electro, Raphael, The Last Agni Kai |
78
+ | 16 | "you've scried or surveilled this turn" condition | S | 3 | 20 → 83 | Desperate Futurescribe, Proctor of Potential, Surveillance Phantasm |
79
+ | 17 | `deal_damage` with a `source` selector | S | 3 | 21 → 86 | Compel Brutality, Hawkeye's Bow, Ingris Stingerquill |
80
+ | 18 | one-turn / conditional additional land plays as an effect | S | 3 | 22 → 89 | Beorn, Thranduil's Company, Way of the Paradox |
81
+ | 19 | static "that many plus one" counter replacement | S | 3 | 23 → 92 | Doc Samson, Michelangelo, Yoshimaru |
82
+ | 20 | "put into a graveyard from the battlefield / library this turn" filters and amounts | S | 3 | 24 → 95 | Bringer of the Last Gift, Cruel Calculations, Supper for Spiders |
83
+ | 21 | equip: once each turn, creature filter, cost reduction by target, alternative cost | M | 5 | 26 → 100 | Dark Knight's Greatsword, Dragonfire Blade, Kíli the Resourceful, Shredder's Armor |
84
+ | 22 | search destinations: choose per card (hand or graveyard, battlefield and hand), exile | M | 5 | 28 → 105 | Dina's Guidance, Part in Friendship, Roads Go Ever, Town Greeter |
85
+ | 23 | attach to the entering / enchanted / triggering creature without targeting | M | 5 | 30 → 110 | Doc Ock's Tentacles, Quintessential Katana, Super-Soldier Serum, Thorin |
86
+ | 24 | choose a card name; same-name filters across zones | L | 7 | 33 → 117 | Ancestral Anger, Ancient Vendetta, Key to the Side-Door, Maelstrom Pulse |
87
+ | 25 | cost modifiers for activated abilities of other permanents (equip, power-up, plot) | M | 5 | 35 → 122 | Doc Aurlock, Dwarven Mauler, Hulk, Mutagen Man |
88
+ | 26 | costs: put stun/page counter, exile a permanent, return a tapped creature, sacrifice the Aura, computed life, variable count | L | 7 | 38 → 129 | Jessica Jones, Madame Null, Mazemind Tome, Rottenmouth Viper |
89
+ | 27 | attack tax, can't be attacked, max attackers, block-count limits | L | 7 | 41 → 136 | Archangel of Tithes, Dáin, Meltstrider's Resolve, Storm |
90
+ | 28 | simultaneous per-player actions (wheel, mass discard/return/sacrifice) | L | 9 | 45 → 145 | Deadly Brew, Garruk, Raphael's Technique, Rush of Dread |
91
+ | 29 | copy exceptions that add abilities or types | M | 4 | 47 → 149 | Ardyn, Electroduplicate, Face Yourself, Likeness Looter |
92
+ | 30 | "attacks alone" trigger | M | 4 | 49 → 153 | Black Widow, Jiang Yanggu, Luke Cage, Spider-Man Noir |
93
+
94
+ Further down (2–4 cards each): Cases, total-mana-value limits on chosen cards, entering attacking from a
95
+ return or reveal, impending, token-type replacements, draw/life replacements, counter doubling, "once each
96
+ turn" on may-abilities, hone counters, attacks-alone triggers. Large, low-yield: face-down permanents
97
+ (manifest dread, disguise; 4 cards, L), split and Room layouts (3, L), another player choosing (End of the
98
+ Hunt, Taster of Wares; 9 cards but L).
99
+
100
+ ## Snapshot of 2026-11-11 (history)
101
+
3
102
  Snapshot of 2026-11-11, taken from deckfinder through its MCP connection (`dsl_status scope: all`).
4
103
  Of 1,025 cards in scope (the user's collection, decks and imported opponent decklists), 192 are
5
104
  DSL FAIL (no script possible yet) and 87 are DSL PARTIAL (a best-effort script that leaves something out).
@@ -47,14 +47,15 @@ Rules: CR 602.1, CR 602.2, CR 602.5b, CR 602.5d, CR 702.177a, CR 702.193a, CR 70
47
47
 
48
48
  ## additional_cost
49
49
 
50
- 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).
50
+ 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). With `flash: true` (optional only) you may cast it from your hand as though it had flash if you pay it: cast that way, only paying it is offered.
51
51
 
52
- Rules: CR 601.2b, CR 601.2f, CR 601.2h, CR 118.8, CR 118.8b
52
+ Rules: CR 601.2b, CR 601.2f, CR 601.2h, CR 118.8, CR 118.8b, CR 601.3c
53
53
 
54
54
  | Parameter | Description |
55
55
  | --- | --- |
56
56
  | `cost` | list of costs |
57
57
  | `optional` | true: you may pay it |
58
+ | `flash` | true: as though it had flash if you pay it |
58
59
 
59
60
  ```json
60
61
  {
@@ -203,6 +204,35 @@ Rules: CR 702.26a, CR 502.1, CR 604.1
203
204
  "cant_phase_in"
204
205
  ```
205
206
 
207
+ ## cards_have
208
+
209
+ While this permanent is on the battlefield, cards you own in `zone` (graveyard (default), hand or exile) matching `cards` have the keyword alternative cost `ability` (flashback, harmonize, mayhem, web_slinging or sneak) and may be cast with it from that zone. Cast option `via: "alt:cards_have:<permanent>:<ref>"`.
210
+
211
+ Rules: CR 611.3a, CR 604.1, CR 118.9, CR 601.2b, CR 702.190a
212
+
213
+ | Parameter | Description |
214
+ | --- | --- |
215
+ | `zone` | graveyard | hand | exile |
216
+ | `cards` | card spec |
217
+ | `ability` | a keyword alternative cost, e.g. {"sneak": {"cost": "{3}{B}"}} |
218
+
219
+ ```json
220
+ {
221
+ "cards_have": {
222
+ "cards": {
223
+ "types": [
224
+ "creature"
225
+ ]
226
+ },
227
+ "ability": {
228
+ "sneak": {
229
+ "cost": "{3}{B}"
230
+ }
231
+ }
232
+ }
233
+ }
234
+ ```
235
+
206
236
  ## cast_restriction
207
237
 
208
238
  This card can be cast only while `only_if` (a condition, checked for the player who would cast it) holds, whatever lets them cast it.
@@ -268,13 +298,15 @@ Rules: CR 614.12, CR 305.6, CR 607.2d
268
298
 
269
299
  ## choose_card_name
270
300
 
271
- As this permanent enters, its controller chooses a card name among the cards in the game (`not`: card types the named card mustn't have, e.g. ["land"]); abilities of it that say "the chosen name" use it.
301
+ As this permanent enters, its controller chooses a card name among the cards in the game (`not`: card types the named card mustn't have, e.g. ["land"]; `types`: it must have one of these, ["land"] for "a land card name"); abilities of it that say "the chosen name" use it. `look_at_hand: "opponent"`: first they look at an opponent's hand.
272
302
 
273
- Rules: CR 614.12, CR 614.12a, CR 201.4, CR 201.4a, CR 607.2
303
+ Rules: CR 614.12, CR 614.12a, CR 201.4, CR 201.4a, CR 607.2, CR 701.20e
274
304
 
275
305
  | Parameter | Description |
276
306
  | --- | --- |
277
307
  | `not` | list of card types |
308
+ | `types` | list of card types |
309
+ | `look_at_hand` | "opponent" |
278
310
 
279
311
  ```json
280
312
  {
@@ -499,7 +531,7 @@ Rules: CR 702.29a, CR 702.29b, CR 702.29e, CR 702.29f, CR 113.6m, CR 602.2a
499
531
 
500
532
  ## damage_replacement
501
533
 
502
- While this permanent is on the battlefield, damage from sources in `by` to recipients in `to` (both optional; `combat`: combat | noncombat) is changed: `multiply` (2 = "double that damage"), `plus` an amount ("that much damage plus 1"), or `redirect` ("self" | "attached": dealt to this permanent or the one it's attached to instead). A scope is "self", "attached" or {"each": filter, "controller": you|opponent|any, "other": bool}; `each` is optional and players match too, so {"controller": "opponent"} is "an opponent or a permanent an opponent controls". Several apply in the order the affected player would pick: redirections, then prevention, then multiplying, then adding.
534
+ While this permanent is on the battlefield, damage from sources in `by` to recipients in `to` (both optional; `combat`: combat | noncombat) is changed: `multiply` (2 = "double that damage"), `plus` an amount ("that much damage plus 1"), or `redirect` ("self" | "attached": dealt to this permanent or the one it's attached to instead). A scope is "self", "attached" or {"each": filter, "controller": you|opponent|any, "other": bool}; `each` is optional and players match too, so {"controller": "opponent"} is "an opponent or a permanent an opponent controls". Redirections apply first; when the order of the others changes the result, the affected player chooses it (a damage_order decision), else prevention, then multiplying, then adding.
503
535
 
504
536
  Rules: CR 614.1a, CR 614.5, CR 614.9, CR 616.1, CR 616.1e, CR 616.1f, CR 120.2b
505
537
 
@@ -1011,13 +1043,13 @@ Rules: CR 702.180a, CR 702.180b, CR 118.9, CR 601.2b, CR 601.2f, CR 601.2h
1011
1043
 
1012
1044
  ## hexproof_from
1013
1045
 
1014
- Hexproof from the quality: this permanent can't be the target of spells with the quality, or abilities from sources with it, that its controller's opponents control. The quality is a card spec (`{"colors": ["B"]}`, `{"types": ["instant"]}`, `{"color_count": {"equal": 1}}` for monocolored), or "its_colors" (hexproof from each of its colors: whatever shares a color with it).
1046
+ Hexproof from the quality: this permanent can't be the target of spells with the quality, or abilities from sources with it, that its controller's opponents control. The quality is a card spec (`{"colors": ["B"]}`, `{"types": ["instant"]}`, `{"color_count": {"equal": 1}}` for monocolored), or "its_colors" (hexproof from each of its colors: whatever shares a color with it), or "chosen_color" (the chosen color; granted by `become`, the color chosen as it resolved).
1015
1047
 
1016
- Rules: CR 702.11d, CR 702.11f, CR 702.11g, CR 115.4
1048
+ Rules: CR 702.11d, CR 702.11f, CR 702.11g, CR 115.4, CR 607.2d
1017
1049
 
1018
1050
  | Parameter | Description |
1019
1051
  | --- | --- |
1020
- | `(value)` | card spec of the quality, or "its_colors" |
1052
+ | `(value)` | card spec of the quality, "its_colors" or "chosen_color" |
1021
1053
 
1022
1054
  ```json
1023
1055
  {
@@ -1248,16 +1280,17 @@ Rules: CR 601.3, CR 113.6e, CR 113.6f, CR 305.1, CR 401.5, CR 122.1, CR 614.12,
1248
1280
 
1249
1281
  ## player_rule
1250
1282
 
1251
- 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.
1283
+ 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_be_attacked. `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) or `name: "chosen"` (sources with the name this permanent chose, in any zone), `cant_be_attacked` takes a `filter` of the creatures that can't attack them, 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.
1252
1284
 
1253
- Rules: CR 702.11c, CR 115.4, CR 508.1c, CR 402.2, CR 514.1, CR 615.1, CR 615.1a, CR 704.5a, CR 104.3b, CR 701.21a, CR 614.17b, CR 101.2, CR 601.3, CR 701.6a, CR 119.7, CR 602.5, CR 615.12, CR 702.16b, CR 702.16e, CR 702.16k, CR 604.1, CR 604.2, CR 611.3a
1285
+ Rules: CR 702.11c, CR 115.4, CR 508.1c, CR 402.2, CR 514.1, CR 615.1, CR 615.1a, CR 704.5a, CR 104.3b, CR 701.21a, CR 614.17b, CR 101.2, CR 601.3, CR 701.6a, CR 119.7, CR 602.5, CR 615.12, CR 702.16b, CR 702.16e, CR 702.16k, CR 506.3, CR 604.1, CR 604.2, CR 611.3a
1254
1286
 
1255
1287
  | Parameter | Description |
1256
1288
  | --- | --- |
1257
- | `rule` | 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 |
1289
+ | `rule` | 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_be_attacked |
1258
1290
  | `affects` | you | opponents | each |
1259
- | `filter` | permanent filter (cant_sacrifice, cant_activate) |
1291
+ | `filter` | permanent filter (cant_sacrifice, cant_activate, cant_be_attacked) |
1260
1292
  | `spells` | card spec of the spells (cant_cast, spells_cant_be_countered) |
1293
+ | `name` | "chosen" (cant_activate: sources with the chosen name) |
1261
1294
  | `if` | condition ("during your turn": {"your_turn": true}) |
1262
1295
 
1263
1296
  ```json
@@ -1324,7 +1357,7 @@ Rules: CR 702.16a, CR 702.16b, CR 702.16c, CR 702.16d, CR 702.16e, CR 702.16f, C
1324
1357
 
1325
1358
  | Parameter | Description |
1326
1359
  | --- | --- |
1327
- | `(value)` | card spec of the quality, "everything", "each_opponent" or "its_colors" |
1360
+ | `(value)` | card spec of the quality, "everything", "each_opponent", "its_colors" or "chosen_color" |
1328
1361
 
1329
1362
  ```json
1330
1363
  {
@@ -55,6 +55,18 @@ Rules: CR 401.1, CR 113.6m, CR 602.2b, CR 118.3
55
55
  "bottom_self_from_graveyard"
56
56
  ```
57
57
 
58
+ ## choose_creature_type
59
+
60
+ Choose a creature type as part of the cost (a `choose_cost` decision with options `{type: "cost", creature_type: t}`). The spell remembers it as its chosen type: later costs and its effects read it with `"subtypes": "chosen"`.
61
+
62
+ Rules: CR 601.2b, CR 205.3m, CR 607.2d
63
+
64
+ ```json
65
+ {
66
+ "choose_creature_type": {}
67
+ }
68
+ ```
69
+
58
70
  ## discard
59
71
 
60
72
  Discard `count` cards (default 1) from your hand, never this card, matching the card spec `card` if given: chosen while casting or activating and discarded as the spell or ability becomes cast. `random: true` discards them at random instead.
@@ -220,13 +232,13 @@ Rules: CR 118.3, CR 601.2b, CR 601.2f, CR 602.2b, CR 118.12
220
232
 
221
233
  ## pay_life
222
234
 
223
- 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.
235
+ 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. An amount (e.g. {"power": "self"}, "pay life equal to its power") is computed as the cost is paid.
224
236
 
225
- Rules: CR 119.4, CR 119.4b, CR 118.3b, CR 601.2b, CR 107.3a
237
+ Rules: CR 119.4, CR 119.4b, CR 118.3b, CR 601.2b, CR 107.3a, CR 702.21a
226
238
 
227
239
  | Parameter | Description |
228
240
  | --- | --- |
229
- | `(value)` | integer >= 1, or "X" |
241
+ | `(value)` | integer >= 1, "X", or an amount |
230
242
 
231
243
  ```json
232
244
  {
@@ -236,7 +248,7 @@ Rules: CR 119.4, CR 119.4b, CR 118.3b, CR 601.2b, CR 107.3a
236
248
 
237
249
  ## remove_counters
238
250
 
239
- 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.
251
+ 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. `self: true`: only from this permanent ("Remove two counters from Ghost-Spider").
240
252
 
241
253
  Rules: CR 602.2b, CR 601.2h, CR 118.3, CR 122.1
242
254
 
@@ -245,6 +257,7 @@ Rules: CR 602.2b, CR 601.2h, CR 118.3, CR 122.1
245
257
  | `count` | integer |
246
258
  | `filter` | filter (default creature) |
247
259
  | `counter` | counter name (optional) |
260
+ | `self` | true: from this permanent only |
248
261
 
249
262
  ```json
250
263
  {
@@ -287,9 +300,13 @@ Rules: CR 701.21a, CR 601.2h, CR 602.2b, CR 118.3, CR 608.2h
287
300
 
288
301
  ## tap
289
302
 
290
- {T} — tap the permanent the ability belongs to. Requires it to be untapped.
303
+ {T} — tap the permanent the ability belongs to. Requires it to be untapped. `{"tap": "granter"}` instead taps the permanent whose static ability granted this ability ("Tap Fishing Pole"; not {T}, so summoning sickness doesn't matter).
304
+
305
+ Rules: CR 107.5, CR 602.5a, CR 602.2b, CR 607.1a, CR 302.6
291
306
 
292
- Rules: CR 107.5, CR 602.5a
307
+ | Parameter | Description |
308
+ | --- | --- |
309
+ | `(value)` | "granter": tap the granting permanent instead |
293
310
 
294
311
  ```json
295
312
  "tap"
@@ -44,6 +44,10 @@ While casting/activating a spell or ability with {X} in its cost: `{type: "x", v
44
44
 
45
45
  Your commander is in a graveyard, exile, hand or library: `{type: "command", object: id}` puts it into the command zone, `{type: "stay", object: id}` leaves it where it is (CR 903.9).
46
46
 
47
+ ## damage_order
48
+
49
+ Order the effects that apply to damage dealt to you or a permanent you control (CR 616.1): submit one of `{type: "order", order: [effect keys], steps: [labels], amount: final damage}` exactly as listed.
50
+
47
51
  ## declare_attackers
48
52
 
49
53
  Declare one attacker: `{type: "attack", object: id, target: ref}` (the defending player or one of their planeswalkers), or `{type: "done"}` (withheld while a creature that attacks each combat if able could still attack, CR 508.1d, or while a creature that can't attack alone attacks alone, CR 506.5; then `{type: "withdraw", object: id}` undoes an attack).