enjine 0.4.1 → 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 (90) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +50 -0
  3. data/SUPPORTED.md +31 -23
  4. data/docs/guides/card-data-format.md +106 -1
  5. data/docs/plans/dsl-gaps.md +23 -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 +108 -18
  10. data/docs/reference/filters.md +19 -2
  11. data/docs/reference/keywords.md +16 -2
  12. data/docs/reference/triggers.md +25 -6
  13. data/lib/enjine/actions/play_land.rb +3 -1
  14. data/lib/enjine/card_definition.rb +4 -3
  15. data/lib/enjine/cli/text.rb +10 -3
  16. data/lib/enjine/decisions/combat.rb +4 -2
  17. data/lib/enjine/decisions/damage_order.rb +18 -0
  18. data/lib/enjine/engine/ability_layers.rb +6 -1
  19. data/lib/enjine/engine/casting/alt_casting.rb +36 -4
  20. data/lib/enjine/engine/casting/cast_choices.rb +13 -1
  21. data/lib/enjine/engine/casting/casting.rb +24 -7
  22. data/lib/enjine/engine/casting/cost_options.rb +3 -1
  23. data/lib/enjine/engine/casting/permissions.rb +13 -14
  24. data/lib/enjine/engine/casting/target_counts.rb +14 -3
  25. data/lib/enjine/engine/casting/waterbend.rb +22 -2
  26. data/lib/enjine/engine/characteristics.rb +3 -2
  27. data/lib/enjine/engine/combat.rb +26 -7
  28. data/lib/enjine/engine/copies.rb +10 -3
  29. data/lib/enjine/engine/damage.rb +49 -0
  30. data/lib/enjine/engine/entering.rb +36 -2
  31. data/lib/enjine/engine/face_down.rb +12 -3
  32. data/lib/enjine/engine/faces.rb +14 -2
  33. data/lib/enjine/engine/follow_ups.rb +4 -1
  34. data/lib/enjine/engine/resolution.rb +46 -1
  35. data/lib/enjine/engine/rules.rb +4 -3
  36. data/lib/enjine/engine/triggers.rb +5 -15
  37. data/lib/enjine/engine/turn_history.rb +16 -1
  38. data/lib/enjine/engine/turn_structure.rb +1 -0
  39. data/lib/enjine/engine/zones.rb +5 -2
  40. data/lib/enjine/events.rb +2 -0
  41. data/lib/enjine/frames.rb +2 -2
  42. data/lib/enjine/mana.rb +3 -0
  43. data/lib/enjine/mechanics/abilities/chosen_values.rb +49 -6
  44. data/lib/enjine/mechanics/abilities/damage_replacements.rb +136 -64
  45. data/lib/enjine/mechanics/abilities/entering_choices.rb +40 -21
  46. data/lib/enjine/mechanics/abilities/play_permissions.rb +52 -20
  47. data/lib/enjine/mechanics/abilities/player_rules.rb +30 -13
  48. data/lib/enjine/mechanics/abilities/static.rb +1 -1
  49. data/lib/enjine/mechanics/card_spec.rb +54 -11
  50. data/lib/enjine/mechanics/costs/base.rb +67 -9
  51. data/lib/enjine/mechanics/costs/behold.rb +21 -5
  52. data/lib/enjine/mechanics/costs/choose_creature_type.rb +43 -0
  53. data/lib/enjine/mechanics/costs/one_of.rb +3 -0
  54. data/lib/enjine/mechanics/costs/pay_life.rb +27 -8
  55. data/lib/enjine/mechanics/costs/remove_counters.rb +8 -5
  56. data/lib/enjine/mechanics/costs/tap.rb +44 -3
  57. data/lib/enjine/mechanics/effects/base.rb +10 -2
  58. data/lib/enjine/mechanics/effects/become.rb +29 -12
  59. data/lib/enjine/mechanics/effects/copy.rb +56 -19
  60. data/lib/enjine/mechanics/effects/counters.rb +8 -2
  61. data/lib/enjine/mechanics/effects/damage.rb +11 -0
  62. data/lib/enjine/mechanics/effects/earthbend.rb +2 -1
  63. data/lib/enjine/mechanics/effects/fight.rb +11 -0
  64. data/lib/enjine/mechanics/effects/library.rb +76 -18
  65. data/lib/enjine/mechanics/effects/pay.rb +7 -4
  66. data/lib/enjine/mechanics/effects/repeat.rb +92 -0
  67. data/lib/enjine/mechanics/effects/search.rb +34 -6
  68. data/lib/enjine/mechanics/effects/tokens.rb +42 -10
  69. data/lib/enjine/mechanics/filters/base.rb +22 -12
  70. data/lib/enjine/mechanics/filters/exile.rb +27 -0
  71. data/lib/enjine/mechanics/filters/stack.rb +14 -8
  72. data/lib/enjine/mechanics/keywords/alternative_costs.rb +10 -6
  73. data/lib/enjine/mechanics/keywords/cards_have.rb +65 -0
  74. data/lib/enjine/mechanics/keywords/flags.rb +3 -1
  75. data/lib/enjine/mechanics/keywords/hideaway.rb +6 -5
  76. data/lib/enjine/mechanics/keywords/kicker.rb +24 -6
  77. data/lib/enjine/mechanics/keywords/protection.rb +24 -8
  78. data/lib/enjine/mechanics/keywords/riot.rb +13 -10
  79. data/lib/enjine/mechanics/linked.rb +32 -2
  80. data/lib/enjine/mechanics/selector.rb +32 -9
  81. data/lib/enjine/mechanics/triggers/casting.rb +15 -9
  82. data/lib/enjine/mechanics/triggers/combat.rb +32 -12
  83. data/lib/enjine/mechanics/triggers/keyword_actions.rb +17 -0
  84. data/lib/enjine/mechanics/triggers/tap_and_counters.rb +20 -9
  85. data/lib/enjine/mechanics/values.rb +10 -3
  86. data/lib/enjine/replacements.rb +3 -2
  87. data/lib/enjine/rules_monitor.rb +13 -2
  88. data/lib/enjine/version.rb +1 -1
  89. data/lib/enjine/view.rb +1 -1
  90. metadata +6 -1
@@ -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).
@@ -236,7 +236,7 @@ Rules: CR 611.2a, CR 611.2b, CR 611.2c, CR 613.1d, CR 613.1e, CR 613.1f, CR 613.
236
236
  | `subtypes` | subtypes it also has ("in addition to its other types") |
237
237
  | `creature_types` | list of creature types (replaces the others; [] removes them all) |
238
238
  | `all_creature_types` | true: it has every creature type |
239
- | `colors` | list of W, U, B, R, G (replaces its colors) |
239
+ | `colors` | list of W, U, B, R, G (replaces its colors), or "chosen": the color chosen earlier while this resolved (choose_color); abilities it grants that say "chosen_color" keep that color |
240
240
  | `loses_abilities` | true: it loses all abilities ("loses all abilities") |
241
241
  | `keywords` | list of keywords it gains |
242
242
  | `base_power_toughness` | {"power": n, "toughness": n} |
@@ -392,17 +392,18 @@ Rules: CR 701.68a, CR 701.68b, CR 701.68c
392
392
 
393
393
  ## cast
394
394
 
395
- 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`.
395
+ The controller may cast referenced cards (or card copies) now, while this resolves, paying their costs; timing restrictions don't apply. `to`, `from`, `for`, `not_types`, `max_mana_value`, `count`, `exile_instead` and `any_mana_type` work as for `cast_free` ("you may cast an artifact spell from your graveyard": `from: "graveyard"`).
396
396
 
397
397
  Rules: CR 608.2g, CR 707.12, CR 707.12a, CR 601.2a, CR 601.2f
398
398
 
399
399
  | Parameter | Description |
400
400
  | --- | --- |
401
401
  | `to` | selector |
402
+ | `from` | hand | graveyard |
402
403
  | `for` | card spec |
403
404
  | `not_types` | list of card types |
404
405
  | `max_mana_value` | amount |
405
- | `count` | 1 or "any" |
406
+ | `count` | integer >= 1 (default 1) or "any" |
406
407
  | `exile_instead` | true or a card spec (as for cast_free) |
407
408
  | `any_mana_type` | boolean: mana of any type can be spent to cast it (CR 609.4b) |
408
409
 
@@ -418,7 +419,7 @@ Rules: CR 608.2g, CR 707.12, CR 707.12a, CR 601.2a, CR 601.2f
418
419
 
419
420
  ## cast_free
420
421
 
421
- 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.
422
+ 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), or in the zone `from` (hand | graveyard). 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), up to N (an integer), 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.
422
423
 
423
424
  Rules: CR 608.2g, CR 118.9, CR 601.2a, CR 107.3b, CR 118.6a, CR 305.2a, CR 305.3, CR 406.3a
424
425
 
@@ -428,7 +429,8 @@ Rules: CR 608.2g, CR 118.9, CR 601.2a, CR 107.3b, CR 118.6a, CR 305.2a, CR 305.3
428
429
  | `for` | card spec |
429
430
  | `not_types` | list of card types |
430
431
  | `max_mana_value` | amount |
431
- | `count` | 1 or "any" |
432
+ | `count` | integer >= 1 (default 1) or "any" |
433
+ | `from` | hand | graveyard |
432
434
  | `play` | boolean |
433
435
  | `exile_instead` | true or a card spec: if a spell cast this way (matching it) would be put into a graveyard, it's exiled instead (CR 614.1a) |
434
436
  | `any_mana_type` | boolean: mana of any type can be spent to cast it (CR 609.4b) |
@@ -445,6 +447,50 @@ Rules: CR 608.2g, CR 118.9, CR 601.2a, CR 107.3b, CR 118.6a, CR 305.2a, CR 305.3
445
447
  }
446
448
  ```
447
449
 
450
+ ## change_target
451
+
452
+ Change the target(s) of each spell or ability on the stack `of` refers to: each target becomes another legal target you choose for that spell; if one can't, none change.
453
+
454
+ Rules: CR 115.7, CR 115.7a, CR 115.7e
455
+
456
+ | Parameter | Description |
457
+ | --- | --- |
458
+ | `of` | selector (spells or abilities on the stack) |
459
+
460
+ ```json
461
+ {
462
+ "change_target": {
463
+ "of": {
464
+ "target": 0
465
+ }
466
+ }
467
+ }
468
+ ```
469
+
470
+ ## choose_card_name
471
+
472
+ The player (`to`, default you) chooses a card name among the cards in the game (`types`: the named card has one of these; `not`: it has none of these); "the chosen name" (`name: "chosen"` in filters) reads it. `remember: "source"`: the source permanent remembers it for its other abilities.
473
+
474
+ Rules: CR 201.4, CR 607.2d, CR 608.2c
475
+
476
+ | Parameter | Description |
477
+ | --- | --- |
478
+ | `types` | list of card types |
479
+ | `not` | list of card types |
480
+ | `remember` | "source" |
481
+ | `to` | player selector (default you) |
482
+
483
+ ```json
484
+ {
485
+ "choose_card_name": {
486
+ "types": [
487
+ "land"
488
+ ],
489
+ "remember": "source"
490
+ }
491
+ }
492
+ ```
493
+
448
494
  ## choose_card_type
449
495
 
450
496
  The player (`to`, default you) chooses a card type; later effects of this spell or ability read it with "types": "chosen".
@@ -730,9 +776,9 @@ Rules: CR 114.1, CR 114.2, CR 114.3, CR 114.4, CR 113.6p
730
776
 
731
777
  ## create_token
732
778
 
733
- Create `amount` tokens under the referenced player's control (default: you). `token` is a predefined token name (Treasure, Clue, Food) or an inline card definition. `tapped: true` creates them tapped; `attacking: true` attacking (only for the attacking player during combat, CR 506.3b).
779
+ Create `amount` tokens under the referenced player's control (default: you). `token` is a predefined token name (Treasure, Clue, Food) or an inline card definition. `tapped: true` creates them tapped; `attacking: true` attacking (only for the attacking player during combat, CR 506.3b); when the defending player controls a planeswalker, the controller chooses for each token whether it attacks that player or one of their planeswalkers (CR 508.4). `size` (an amount, fixed as the effect starts) makes them N/N ("an X/X Spirit token, where X is ..."; part of their copiable values).
734
780
 
735
- Rules: CR 111.1, CR 111.10, CR 701.7a, CR 704.5d, CR 508.4, CR 506.3b
781
+ Rules: CR 111.1, CR 111.10, CR 701.7a, CR 704.5d, CR 508.4, CR 506.3b, CR 707.2
736
782
 
737
783
  | Parameter | Description |
738
784
  | --- | --- |
@@ -741,6 +787,7 @@ Rules: CR 111.1, CR 111.10, CR 701.7a, CR 704.5d, CR 508.4, CR 506.3b
741
787
  | `tapped` | boolean |
742
788
  | `attacking` | boolean |
743
789
  | `to` | selector (default "you") |
790
+ | `size` | amount: the tokens are N/N |
744
791
 
745
792
  ```json
746
793
  {
@@ -908,9 +955,9 @@ Rules: CR 701.8a
908
955
 
909
956
  ## dig
910
957
 
911
- Look at the top `amount` cards of your library (`reveal: "all"`: reveal them). Take `count` (default 1; "all": every matching card, no choice; "any": any number) cards matching `for` and put them into `put` (`tapped` onto the battlefield); `optional`: you may take fewer. `reveal: "chosen"` reveals the cards taken. The rest go to `rest`: "bottom_random" (default), "bottom_any" (in an order you choose) or "graveyard". `put: "exile"` takes `face_down: true` (only you may look at them) and `link: true` (exiled with the source, CR 607.2a: hideaway).
958
+ Look at the top `amount` cards of your library (`reveal: "all"`: reveal them). Take `count` (default 1; "all": every matching card, no choice; "any": any number) cards matching `for` and put them into `put` (`tapped` onto the battlefield); `optional`: you may take fewer. `reveal: "chosen"` reveals the cards taken. The rest go to `rest`: "bottom_random" (default), "bottom_any" (in an order you choose) or "graveyard". `put: "exile"` takes `face_down: true` (only you may look at them) and `link: true` (exiled with the source, CR 607.2a); `looker: "source_controller"`: whoever controls the source may look at them instead of you (hideaway, CR 702.75a).
912
959
 
913
- Rules: CR 701.20a, CR 701.20e, CR 401.4, CR 400.7j, CR 406.3, CR 607.2a
960
+ Rules: CR 701.20a, CR 701.20e, CR 401.4, CR 400.7j, CR 406.3, CR 607.2a, CR 702.75a
914
961
 
915
962
  | Parameter | Description |
916
963
  | --- | --- |
@@ -924,6 +971,7 @@ Rules: CR 701.20a, CR 701.20e, CR 401.4, CR 400.7j, CR 406.3, CR 607.2a
924
971
  | `rest` | bottom_random | bottom_any | graveyard |
925
972
  | `face_down` | boolean (put exile) |
926
973
  | `link` | boolean (put exile) |
974
+ | `looker` | "source_controller" (face_down) |
927
975
 
928
976
  ```json
929
977
  {
@@ -1198,9 +1246,9 @@ Rules: CR 608.2n, CR 406.1
1198
1246
 
1199
1247
  ## exile_top
1200
1248
 
1201
- Each referenced player (default: you) exiles the top `amount` cards of their library (face up). Later effects name them with {"result": n}; `link: true` exiles them with the source. `face_down: true` exiles them face down: only the `looker` players (default: you) may look at them.
1249
+ Each referenced player (default: you) exiles the top `amount` cards of their library (face up). Later effects name them with {"result": n}; `link: true` exiles them with the source. `face_down: true` exiles them face down: only the `looker` players (default: you) may look at them. `until` instead of `amount`: exile cards from the top one at a time until {"total_mana_value": N}: those cards have a total mana value of N or more, or {"card": card spec}: a matching card is exiled (or the library is empty).
1202
1250
 
1203
- Rules: CR 406.1, CR 400.7j, CR 607.2a, CR 406.3, CR 406.3a
1251
+ Rules: CR 406.1, CR 400.7j, CR 607.2a, CR 406.3, CR 406.3a, CR 202.3, CR 608.2c
1204
1252
 
1205
1253
  | Parameter | Description |
1206
1254
  | --- | --- |
@@ -1209,6 +1257,7 @@ Rules: CR 406.1, CR 400.7j, CR 607.2a, CR 406.3, CR 406.3a
1209
1257
  | `link` | boolean |
1210
1258
  | `face_down` | boolean |
1211
1259
  | `looker` | selector of players who may look (default "you") |
1260
+ | `until` | {"total_mana_value": amount} | {"card": card spec} |
1212
1261
 
1213
1262
  ```json
1214
1263
  {
@@ -1611,14 +1660,14 @@ Rules: CR 702.26a, CR 702.26b, CR 702.26d, CR 702.26g, CR 702.26h, CR 502.1, CR
1611
1660
 
1612
1661
  ## play_permission
1613
1662
 
1614
- 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, until_your_next_end_step 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.
1663
+ 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, until_your_next_end_step, while_exiled or while_you_control_source ("for as long as you control this creature"). 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. `during: "your_turn"`: only during your turn. `waterbend: "mana_value"`: cast it by waterbending {X} rather than paying its mana cost, where X is its mana value.
1615
1664
 
1616
- Rules: CR 611.2a, CR 601.3, CR 305.1, CR 400.7, CR 514.2, CR 601.2f, CR 108.3, CR 406.3b, CR 609.4b
1665
+ Rules: CR 611.2a, CR 611.2b, CR 601.3, CR 305.1, CR 400.7, CR 514.2, CR 601.2f, CR 108.3, CR 406.3b, CR 609.4b, CR 118.9, CR 701.67a
1617
1666
 
1618
1667
  | Parameter | Description |
1619
1668
  | --- | --- |
1620
1669
  | `to` | selector (usually {"result": n}) |
1621
- | `duration` | end_of_turn | end_of_your_next_turn | until_your_next_end_step | while_exiled |
1670
+ | `duration` | end_of_turn | end_of_your_next_turn | until_your_next_end_step | while_exiled | while_you_control_source |
1622
1671
  | `play` | play | cast |
1623
1672
  | `for` | card spec |
1624
1673
  | `not_types` | list of card types |
@@ -1627,6 +1676,8 @@ Rules: CR 611.2a, CR 601.3, CR 305.1, CR 400.7, CR 514.2, CR 601.2f, CR 108.3, C
1627
1676
  | `cost_increase` | integer >= 1 |
1628
1677
  | `any_mana_type` | boolean |
1629
1678
  | `exile_instead` | true or a card spec: if a spell cast this way (matching it) would be put into a graveyard, it's exiled instead (CR 614.1a) |
1679
+ | `during` | your_turn |
1680
+ | `waterbend` | mana_value |
1630
1681
 
1631
1682
  ```json
1632
1683
  {
@@ -1643,7 +1694,7 @@ Rules: CR 611.2a, CR 601.3, CR 305.1, CR 400.7, CR 514.2, CR 601.2f, CR 108.3, C
1643
1694
 
1644
1695
  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.
1645
1696
 
1646
- 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 611.2a, CR 514.2
1697
+ 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 611.2a, CR 514.2
1647
1698
 
1648
1699
  | Parameter | Description |
1649
1700
  | --- | --- |
@@ -1862,7 +1913,7 @@ Rules: CR 122.8
1862
1913
 
1863
1914
  ## remove_counters
1864
1915
 
1865
- Remove up to `amount` counters named `counter` from each referenced permanent.
1916
+ Remove up to `amount` counters named `counter` from each referenced permanent. How many were removed is {"this_way": n} ("remove a bait counter ... If you do, ...").
1866
1917
 
1867
1918
  Rules: CR 122.8
1868
1919
 
@@ -1904,6 +1955,44 @@ Rules: CR 120.6, CR 514.2
1904
1955
  }
1905
1956
  ```
1906
1957
 
1958
+ ## repeat
1959
+
1960
+ Run `effects`, then run them again for as long as `while` (a condition) holds after a pass ("if the exiled card is a land card, repeat this process"). {"result": n} in the list and in `while` names what effect n did during the current pass. At most 100 passes.
1961
+
1962
+ Rules: CR 608.2c, CR 400.7j, CR 104.4b
1963
+
1964
+ | Parameter | Description |
1965
+ | --- | --- |
1966
+ | `effects` | list of effects (one pass) |
1967
+ | `while` | condition, checked after each pass |
1968
+
1969
+ ```json
1970
+ {
1971
+ "repeat": {
1972
+ "effects": [
1973
+ {
1974
+ "mill": {
1975
+ "amount": 1
1976
+ }
1977
+ }
1978
+ ],
1979
+ "while": {
1980
+ "amount": {
1981
+ "count": {
1982
+ "result": 0,
1983
+ "for": {
1984
+ "types": [
1985
+ "land"
1986
+ ]
1987
+ }
1988
+ }
1989
+ },
1990
+ "at_least": 1
1991
+ }
1992
+ }
1993
+ }
1994
+ ```
1995
+
1907
1996
  ## return_choice
1908
1997
 
1909
1998
  Each referenced player (default: you) returns `count` (default 1; "any": any number) permanents they control matching `filter` to their owners' hands, chosen by them in turn order starting with the active player (not targeted); all move at once.
@@ -2078,9 +2167,9 @@ Rules: CR 701.22a
2078
2167
 
2079
2168
  ## search_library
2080
2169
 
2081
- 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").
2170
+ 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"). `battlefield_instead`: {"if": condition, "for": card spec}: a found card matching `for` goes onto the battlefield instead of into your hand while the condition holds.
2082
2171
 
2083
- Rules: CR 701.23a, CR 701.23b, CR 701.23d, CR 701.23e, CR 701.20a, CR 701.24a, CR 701.24b, CR 118.12, CR 110.2a
2172
+ Rules: CR 701.23a, CR 701.23b, CR 701.23d, CR 701.23e, CR 701.20a, CR 701.24a, CR 701.24b, CR 118.12, CR 110.2a, CR 614.1a
2084
2173
 
2085
2174
  | Parameter | Description |
2086
2175
  | --- | --- |
@@ -2093,6 +2182,7 @@ Rules: CR 701.23a, CR 701.23b, CR 701.23d, CR 701.23e, CR 701.20a, CR 701.24a, C
2093
2182
  | `searcher` | selector of the searching player (default "you") |
2094
2183
  | `may` | true: the searcher may choose not to search |
2095
2184
  | `different_names` | true: each card found has a different name |
2185
+ | `battlefield_instead` | {"if": condition, "for": card spec} (with put: hand) |
2096
2186
 
2097
2187
  ```json
2098
2188
  {
@@ -42,6 +42,22 @@ Rules: CR 115.1
42
42
  "creature_or_planeswalker"
43
43
  ```
44
44
 
45
+ ## exiled_with
46
+
47
+ A card in exile that one of this object's abilities exiled (linked abilities: "the cards exiled with it"); restrict with `any_of`/`not` for its card types.
48
+
49
+ Rules: CR 607.2a, CR 406.6, CR 115.1
50
+
51
+ ```json
52
+ {
53
+ "exiled_with": {
54
+ "any_of": [
55
+ "creature"
56
+ ]
57
+ }
58
+ }
59
+ ```
60
+
45
61
  ## graveyard_card
46
62
 
47
63
  A card in a graveyard (any player's, in seat order; restrict with `controller` for its owner and `any_of`/`not` for its card types).
@@ -152,15 +168,16 @@ Rules: CR 112.1, CR 115.1
152
168
 
153
169
  ## stack_ability
154
170
 
155
- An activated or triggered ability on the stack. `kind`: "activated" or "triggered" for only one of them; `controller`: you | opponent; `source`: a filter its source matches (e.g. "creature", "artifact").
171
+ An activated or triggered ability on the stack. `kind`: "activated" or "triggered" for only one of them; `controller`: you | opponent; `source`: a filter its source matches (e.g. "creature", "artifact"); `single_target: true`: one with a single target.
156
172
 
157
- Rules: CR 113.1b, CR 115.1, CR 605.3b, CR 113.7
173
+ Rules: CR 113.1b, CR 115.1, CR 605.3b, CR 113.7, CR 115.7
158
174
 
159
175
  | Parameter | Description |
160
176
  | --- | --- |
161
177
  | `kind` | activated | triggered |
162
178
  | `controller` | you | opponent |
163
179
  | `source` | filter |
180
+ | `single_target` | boolean |
164
181
 
165
182
  ```json
166
183
  {
@@ -128,6 +128,20 @@ Rules: CR 701.6a, CR 101.2
128
128
  }
129
129
  ```
130
130
 
131
+ ## cant_become_untapped
132
+
133
+ This permanent can't become untapped: not in its controller's untap step nor by an effect ("untap it" does nothing).
134
+
135
+ Rules: CR 701.26b, CR 502.3, CR 101.2
136
+
137
+ ```json
138
+ {
139
+ "keywords": [
140
+ "cant become untapped"
141
+ ]
142
+ }
143
+ ```
144
+
131
145
  ## cant_block
132
146
 
133
147
  Restriction: this creature can't block.
@@ -508,9 +522,9 @@ Rules: CR 702.17b
508
522
 
509
523
  ## riot
510
524
 
511
- As this permanent enters, its controller chooses an additional +1/+1 counter or haste (an enter_choice: `{type: "option", option: "counter" | "haste"}`).
525
+ As this permanent enters, its controller chooses an additional +1/+1 counter or haste (an enter_choice: `{type: "option", option: "counter" | "haste"}`). Riot granted by a static ability ("Other Spiders you control have riot") is chosen as it enters too, and haste chosen this way stays if it later loses riot.
512
526
 
513
- Rules: CR 702.136a, CR 614.12
527
+ Rules: CR 702.136a, CR 702.136b, CR 614.12
514
528
 
515
529
  ```json
516
530
  {
@@ -89,14 +89,15 @@ Rules: CR 603.2, CR 603.2c
89
89
 
90
90
  ## attacks
91
91
 
92
- 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).
92
+ 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). `alone: true`: only when it is the only creature declared as an attacker (it triggers as the declaration is complete).
93
93
 
94
- Rules: CR 508.3a, CR 603.2
94
+ Rules: CR 508.3a, CR 603.2, CR 506.5
95
95
 
96
96
  | Parameter | Description |
97
97
  | --- | --- |
98
98
  | `subject` | "self" (default) or {"each": filter, ...} |
99
99
  | `first_time_this_turn` | boolean |
100
+ | `alone` | boolean |
100
101
 
101
102
  ```json
102
103
  {
@@ -198,7 +199,7 @@ Rules: CR 603.2e, CR 701.26a, CR 702.194a
198
199
 
199
200
  The subject becomes the target of a spell or ability (controlled by `by`: opponent | you | any (default), relative to the source's controller). One trigger per matching object targeted.
200
201
 
201
- Rules: CR 115.1, CR 601.2c, CR 603.2, CR 603.2c
202
+ Rules: CR 115.1, CR 115.7, CR 601.2c, CR 603.2, CR 603.2c, CR 707.10
202
203
 
203
204
  | Parameter | Description |
204
205
  | --- | --- |
@@ -262,9 +263,9 @@ Rules: CR 509.3a, CR 509.3b, CR 509.3f, CR 603.2
262
263
 
263
264
  ## cast
264
265
 
265
- A player casts a spell. `controller`: you (default) | opponent | any; `spell`: creature | noncreature | instant_or_sorcery, or any spell filter, e.g. {"spell": {"subtypes": ["saga"]}} or {"one_of": [...]} for "creature or Spacecraft spell"; `name` / `mana_value`: "chosen" (the source's as-it-entered choice); `self: true`: "when you cast this spell" (it functions on the stack). `targets`: only a spell that targets something matching this filter ("self": this permanent), e.g. {"creature": {"controller": "you"}}. `from` / `not_from`: only a spell cast from (not from) that zone: hand | graveyard | exile | library | outside. `single_target: true`: only a spell with exactly one target.
266
+ A player casts a spell. `controller`: you (default) | opponent | any; `spell`: creature | noncreature | instant_or_sorcery, or any spell filter, e.g. {"spell": {"subtypes": ["saga"]}} or {"one_of": [...]} for "creature or Spacecraft spell"; `name` / `mana_value`: "chosen" (the source's as-it-entered choice); `self: true`: "when you cast this spell" (it functions on the stack). `targets`: only a spell that targets something matching this filter ("self": this permanent), e.g. {"creature": {"controller": "you"}}. `from` / `not_from`: only a spell cast from (not from) that zone: hand | graveyard | exile | library | outside. `single_target: true`: only a spell with exactly one target. `owner`: "not_you" only a spell you don't own, "you" only one you own.
266
267
 
267
- Rules: CR 603.2, CR 601.2i, CR 113.6, CR 202.3e, CR 201.4, CR 607.2, CR 115.1, CR 601.2a, CR 601.2c
268
+ Rules: CR 603.2, CR 601.2i, CR 113.6, CR 202.3e, CR 201.4, CR 607.2, CR 115.1, CR 601.2a, CR 601.2c, CR 108.3
268
269
 
269
270
  | Parameter | Description |
270
271
  | --- | --- |
@@ -277,6 +278,7 @@ Rules: CR 603.2, CR 601.2i, CR 113.6, CR 202.3e, CR 201.4, CR 607.2, CR 115.1, C
277
278
  | `from` | zone |
278
279
  | `not_from` | zone |
279
280
  | `single_target` | true |
281
+ | `owner` | you | not_you |
280
282
 
281
283
  ```json
282
284
  {
@@ -289,7 +291,7 @@ Rules: CR 603.2, CR 601.2i, CR 113.6, CR 202.3e, CR 201.4, CR 607.2, CR 115.1, C
289
291
 
290
292
  ## counters_placed
291
293
 
292
- One or more counters (only `counter`, if given) are put on the subject, including the counters it enters the battlefield with. Triggers once per event, however many counters.
294
+ One or more counters (only `counter`, if given) are put on the subject, including the counters it enters the battlefield with. Triggers once per event, however many counters. `nth` (needs `counter`): only when the Nth such counter is put on it (the event that takes it from fewer than N to N or more).
293
295
 
294
296
  Rules: CR 122.6, CR 603.2, CR 603.2c
295
297
 
@@ -299,6 +301,7 @@ Rules: CR 122.6, CR 603.2, CR 603.2c
299
301
  | `counter` | counter name |
300
302
  | `first_time_this_turn` | true: only the first time each turn such counters are put on that permanent (an earlier placement counts even if nothing could trigger then) |
301
303
  | `by` | you | opponent: only counters that player puts ("whenever you put ...", CR 122.6a; a permanent's controller puts the counters it enters with) |
304
+ | `nth` | positive integer |
302
305
 
303
306
  ```json
304
307
  {
@@ -536,6 +539,22 @@ Rules: CR 119.9, CR 120.3f
536
539
  }
537
540
  ```
538
541
 
542
+ ## gives_gift
543
+
544
+ A player (`controller`: you (default) | opponent | any) gives a gift: an instant or sorcery spell they control whose gift was promised resolves, or the gift triggered ability (an enters trigger under `{"cast_with": "gift"}`) of a permanent they control resolves.
545
+
546
+ Rules: CR 702.174c, CR 702.174b
547
+
548
+ | Parameter | Description |
549
+ | --- | --- |
550
+ | `controller` | you | opponent | any |
551
+
552
+ ```json
553
+ {
554
+ "gives_gift": {}
555
+ }
556
+ ```
557
+
539
558
  ## leaves_battlefield
540
559
 
541
560
  The subject leaves the battlefield (for any zone, or only `to` that zone). Looks back in time: the permanent is matched as it last existed (types, controller, counters).
@@ -38,7 +38,9 @@ module Enjine
38
38
  # The play_land frame: ask the "as this enters" choice, then put the land onto the battlefield.
39
39
  def self.step(engine, frame)
40
40
  land = engine.candidate_object(frame["player"], frame["object"])
41
- return engine.ask_enter_choice!(frame["object"], frame["player"]) if engine.entering_choice_pending?(land, frame["enter"])
41
+ if engine.entering_choice_pending?(land, frame["enter"])
42
+ return engine.ask_enter_choice!(frame["object"], frame["player"], frame["enter"])
43
+ end
42
44
 
43
45
  enters = engine.enters_from_answer(land, frame)
44
46
  engine.pay_entering_costs!(frame["player"], frame)