enjine 0.5.0 → 0.6.1

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 (120) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +156 -1
  3. data/README.md +12 -3
  4. data/SUPPORTED.md +44 -17
  5. data/docs/ARCHITECTURE.md +7 -2
  6. data/docs/MECHANICS_COVERAGE.md +10 -8
  7. data/docs/guides/api.md +2 -1
  8. data/docs/guides/card-data-format.md +40 -8
  9. data/docs/reference/abilities.md +254 -13
  10. data/docs/reference/costs.md +36 -0
  11. data/docs/reference/decisions.md +3 -1
  12. data/docs/reference/effects.md +93 -10
  13. data/docs/reference/filters.md +11 -1
  14. data/docs/reference/keywords.md +42 -0
  15. data/docs/reference/subtypes.md +18 -0
  16. data/docs/reference/triggers.md +69 -8
  17. data/docs/reference/types.md +20 -0
  18. data/lib/enjine/actions/special_action.rb +4 -0
  19. data/lib/enjine/actions/turn_face_up.rb +25 -0
  20. data/lib/enjine/actions/unlock.rb +23 -0
  21. data/lib/enjine/card_definition.rb +50 -12
  22. data/lib/enjine/card_face_down.rb +31 -0
  23. data/lib/enjine/card_faces.rb +4 -2
  24. data/lib/enjine/card_rooms.rb +86 -0
  25. data/lib/enjine/catalog.rb +9 -3
  26. data/lib/enjine/cli/text.rb +1 -0
  27. data/lib/enjine/color_identity.rb +34 -1
  28. data/lib/enjine/decisions/casting.rb +6 -3
  29. data/lib/enjine/engine/ability_layers.rb +8 -0
  30. data/lib/enjine/engine/casting/alt_casting.rb +12 -4
  31. data/lib/enjine/engine/casting/cast_choices.rb +8 -1
  32. data/lib/enjine/engine/casting/casting.rb +18 -22
  33. data/lib/enjine/engine/casting/costs.rb +8 -1
  34. data/lib/enjine/engine/casting/payment.rb +47 -9
  35. data/lib/enjine/engine/casting/permissions.rb +6 -3
  36. data/lib/enjine/engine/characteristics.rb +8 -9
  37. data/lib/enjine/engine/combat.rb +19 -7
  38. data/lib/enjine/engine/copies.rb +2 -1
  39. data/lib/enjine/engine/crimes.rb +46 -0
  40. data/lib/enjine/engine/damage.rb +36 -1
  41. data/lib/enjine/engine/face_down_permanents.rb +108 -0
  42. data/lib/enjine/engine/faces.rb +6 -3
  43. data/lib/enjine/engine/mana_sources.rb +18 -3
  44. data/lib/enjine/engine/options_memo.rb +140 -0
  45. data/lib/enjine/engine/permanent_designations.rb +29 -0
  46. data/lib/enjine/engine/resolution.rb +25 -5
  47. data/lib/enjine/engine/rooms.rb +86 -0
  48. data/lib/enjine/engine/rules.rb +2 -1
  49. data/lib/enjine/engine/state_based_actions.rb +25 -4
  50. data/lib/enjine/engine/triggers.rb +20 -5
  51. data/lib/enjine/engine/turn_history.rb +28 -5
  52. data/lib/enjine/engine/zones.rb +32 -6
  53. data/lib/enjine/engine.rb +9 -1
  54. data/lib/enjine/events.rb +9 -0
  55. data/lib/enjine/frames.rb +3 -0
  56. data/lib/enjine/fuzz.rb +3 -0
  57. data/lib/enjine/game.rb +3 -1
  58. data/lib/enjine/mechanics/abilities/cost_changes.rb +32 -10
  59. data/lib/enjine/mechanics/abilities/damage_replacements.rb +1 -1
  60. data/lib/enjine/mechanics/abilities/designated.rb +57 -0
  61. data/lib/enjine/mechanics/abilities/life_replacements.rb +74 -0
  62. data/lib/enjine/mechanics/abilities/mana_ability.rb +10 -4
  63. data/lib/enjine/mechanics/abilities/player_rules.rb +1 -1
  64. data/lib/enjine/mechanics/abilities/stack_abilities.rb +12 -7
  65. data/lib/enjine/mechanics/abilities/static.rb +18 -5
  66. data/lib/enjine/mechanics/card_spec.rb +12 -3
  67. data/lib/enjine/mechanics/costs/base.rb +3 -2
  68. data/lib/enjine/mechanics/costs/behold.rb +10 -3
  69. data/lib/enjine/mechanics/costs/choose_creature_type.rb +3 -3
  70. data/lib/enjine/mechanics/costs/collect_evidence.rb +60 -0
  71. data/lib/enjine/mechanics/costs/exile_permanent.rb +41 -0
  72. data/lib/enjine/mechanics/effects/base.rb +26 -5
  73. data/lib/enjine/mechanics/effects/choose_cards.rb +44 -14
  74. data/lib/enjine/mechanics/effects/copy.rb +2 -2
  75. data/lib/enjine/mechanics/effects/counters.rb +12 -6
  76. data/lib/enjine/mechanics/effects/delayed_triggers.rb +13 -6
  77. data/lib/enjine/mechanics/effects/may.rb +4 -2
  78. data/lib/enjine/mechanics/effects/pay.rb +20 -6
  79. data/lib/enjine/mechanics/filters/any_target.rb +6 -3
  80. data/lib/enjine/mechanics/filters/base.rb +14 -5
  81. data/lib/enjine/mechanics/filters/permanents.rb +7 -0
  82. data/lib/enjine/mechanics/keywords/alternative_costs.rb +70 -16
  83. data/lib/enjine/mechanics/keywords/cards_have.rb +4 -2
  84. data/lib/enjine/mechanics/keywords/craft.rb +132 -0
  85. data/lib/enjine/mechanics/keywords/cycling.rb +46 -7
  86. data/lib/enjine/mechanics/keywords/extort.rb +2 -0
  87. data/lib/enjine/mechanics/keywords/face_down.rb +165 -0
  88. data/lib/enjine/mechanics/keywords/impending.rb +75 -0
  89. data/lib/enjine/mechanics/keywords/increment.rb +2 -0
  90. data/lib/enjine/mechanics/keywords/infinity.rb +46 -0
  91. data/lib/enjine/mechanics/keywords/miracle.rb +142 -0
  92. data/lib/enjine/mechanics/keywords/ninjutsu.rb +101 -0
  93. data/lib/enjine/mechanics/keywords/offspring.rb +48 -0
  94. data/lib/enjine/mechanics/keywords/persist_and_undying.rb +42 -0
  95. data/lib/enjine/mechanics/keywords/split_second.rb +29 -0
  96. data/lib/enjine/mechanics/keywords/storm_and_cascade.rb +5 -0
  97. data/lib/enjine/mechanics/keywords/void.rb +34 -0
  98. data/lib/enjine/mechanics/linked.rb +2 -2
  99. data/lib/enjine/mechanics/mana_spent.rb +1 -1
  100. data/lib/enjine/mechanics/selector.rb +30 -9
  101. data/lib/enjine/mechanics/subtypes/case.rb +68 -0
  102. data/lib/enjine/mechanics/triggers/base.rb +13 -4
  103. data/lib/enjine/mechanics/triggers/crime.rb +28 -0
  104. data/lib/enjine/mechanics/triggers/damage.rb +33 -18
  105. data/lib/enjine/mechanics/triggers/draw_and_discard.rb +19 -6
  106. data/lib/enjine/mechanics/triggers/rooms.rb +49 -0
  107. data/lib/enjine/mechanics/triggers/zone_changes.rb +24 -9
  108. data/lib/enjine/mechanics/types/battle.rb +130 -0
  109. data/lib/enjine/mechanics/values.rb +74 -27
  110. data/lib/enjine/replacements.rb +18 -0
  111. data/lib/enjine/rules_monitor.rb +49 -75
  112. data/lib/enjine/snapshot/deep_copy.rb +23 -0
  113. data/lib/enjine/snapshot/player_checks.rb +10 -2
  114. data/lib/enjine/snapshot.rb +2 -1
  115. data/lib/enjine/state.rb +2 -2
  116. data/lib/enjine/verify.rb +10 -3
  117. data/lib/enjine/version.rb +1 -1
  118. data/lib/enjine/view.rb +49 -13
  119. data/lib/enjine.rb +1 -1
  120. metadata +29 -1
@@ -509,15 +509,15 @@ Rules: CR 205.2a, CR 607.2d, CR 608.2c
509
509
 
510
510
  ## choose_cards
511
511
 
512
- You choose `count` (default 1; "any": any number) cards matching `for` from `from`: a selector (e.g. {"result": 0}, the cards an earlier effect milled) or a player's zone, {"hand": selector} / {"graveyard": selector}. `optional`: you may choose fewer. Then they are put into `put` (`discard`: from a hand, its owner discards them; `tapped` onto the battlefield, under your control; exiled cards `link`ed to the source). `look`: you look at the whole zone first; `reveal`: "chosen" reveals what you chose, "all" the whole set. `then` runs if a card was chosen, `otherwise` if none was ("if you can't"). `random: true`: the cards are picked at random (the game's random number generator) instead of chosen.
512
+ You choose `count` (default 1; "any": any number; "all": every matching card, no choice) cards matching `for` from `from`: a selector (e.g. {"result": 0}, the cards an earlier effect milled) or a player's zone, {"hand": selector} / {"graveyard": selector}. `optional`: you may choose fewer. Then they are put into `put` (`discard`: from a hand, its owner discards them; `tapped` onto the battlefield, under your control; exiled cards `link`ed to the source). `look`: you look at the whole zone first; `reveal`: "chosen" reveals what you chose, "all" the whole set. `then` runs if a card was chosen, `otherwise` if none was ("if you can't"). `random: true`: the cards are picked at random (the game's random number generator) instead of chosen. `chooser`: the player who chooses (a player selector, default "you"; e.g. "each_opponent" or {"target": 0}: "target opponent chooses a card from among them"); they look at the cards they choose from, and the cards still go where `put` says under your control.
513
513
 
514
- Rules: CR 701.20a, CR 701.20e, CR 400.7j, CR 608.2c, CR 607.2a, CR 118.12, CR 701.9a, CR 701.9b
514
+ Rules: CR 701.20a, CR 701.20e, CR 400.7j, CR 608.2c, CR 607.2a, CR 118.12, CR 701.9a, CR 701.9b, CR 608.2d
515
515
 
516
516
  | Parameter | Description |
517
517
  | --- | --- |
518
518
  | `from` | selector or {"hand"|"graveyard": player selector} |
519
519
  | `for` | card spec |
520
- | `count` | integer or "any" |
520
+ | `count` | integer, "any" or "all" |
521
521
  | `optional` | boolean |
522
522
  | `put` | hand | graveyard | exile | battlefield | library_top | library_bottom | discard |
523
523
  | `tapped` | boolean |
@@ -527,6 +527,7 @@ Rules: CR 701.20a, CR 701.20e, CR 400.7j, CR 608.2c, CR 607.2a, CR 118.12, CR 70
527
527
  | `reveal` | chosen | all |
528
528
  | `then` | list of effects |
529
529
  | `otherwise` | list of effects |
530
+ | `chooser` | player selector (default "you") |
530
531
 
531
532
  ```json
532
533
  {
@@ -617,6 +618,23 @@ Rules: CR 607.2f, CR 608.2c
617
618
  }
618
619
  ```
619
620
 
621
+ ## cloak
622
+
623
+ Each referenced player (default you) cloaks the top card of their library `amount` times (default 1): it enters face down as a nameless colorless 2/2 creature with ward {2}. Its controller may turn it face up for its mana cost if it's a creature card.
624
+
625
+ Rules: CR 701.58a, CR 701.58b, CR 701.58e, CR 701.58f, CR 701.58g, CR 708.2, CR 708.3
626
+
627
+ | Parameter | Description |
628
+ | --- | --- |
629
+ | `amount` | amount (default 1) |
630
+ | `to` | players (default you) |
631
+
632
+ ```json
633
+ {
634
+ "cloak": {}
635
+ }
636
+ ```
637
+
620
638
  ## connive
621
639
 
622
640
  Each referenced permanent (default: this one) connives `amount` (default 1): its controller draws that many cards, then discards that many, then it gets a +1/+1 counter for each nonland card discarded.
@@ -900,7 +918,7 @@ Rules: CR 120.3a, CR 120.3c, CR 120.3e, CR 120.6, CR 120.4a, CR 120.10
900
918
 
901
919
  ## delayed_trigger
902
920
 
903
- Creates a delayed triggered ability with the controller and source of the resolving spell or ability. It triggers only once, the next time `when` happens (e.g. {"step_begins": {"step": "end", "whose": "each"}} for the next end step). Its `effects` may use {"result": n} for what earlier effects of the creating list moved or created; those objects are affected only if they are still where they were put.
921
+ Creates a delayed triggered ability with the controller and source of the resolving spell or ability. It triggers only once, the next time `when` happens (e.g. {"step_begins": {"step": "end", "whose": "each"}} for the next end step). Its `effects` may use {"result": n} for what earlier effects of the creating list moved or created (n below its position); those objects are affected only if they are still where they were put. Its own effects are numbered on from there.
904
922
 
905
923
  Rules: CR 603.7a, CR 603.7b, CR 603.7c, CR 603.7d, CR 603.7e
906
924
 
@@ -1475,6 +1493,22 @@ Rules: CR 113.6b, CR 611.2a, CR 613.1f
1475
1493
  }
1476
1494
  ```
1477
1495
 
1496
+ ## harness
1497
+
1498
+ Each referenced permanent (default: this one) becomes harnessed if it isn't (a designation it keeps until it leaves the battlefield). Its `infinity` abilities work while it is.
1499
+
1500
+ Rules: CR 701.64a, CR 701.64b
1501
+
1502
+ | Parameter | Description |
1503
+ | --- | --- |
1504
+ | `to` | selector of permanents (default self) |
1505
+
1506
+ ```json
1507
+ {
1508
+ "harness": {}
1509
+ }
1510
+ ```
1511
+
1478
1512
  ## look_at_hand
1479
1513
 
1480
1514
  You look at each referenced player's hand (other players don't see the cards).
@@ -1529,9 +1563,42 @@ Rules: CR 119.3
1529
1563
  }
1530
1564
  ```
1531
1565
 
1566
+ ## manifest
1567
+
1568
+ Each referenced player (default you) manifests the top card of their library `amount` times (default 1): it enters face down as a nameless colorless 2/2 creature with no abilities. Its controller may turn it face up for its mana cost if it's a creature card (special action `turn_face_up`). The new permanents are this effect's results.
1569
+
1570
+ Rules: CR 701.40a, CR 701.40b, CR 701.40e, CR 701.40f, CR 701.40g, CR 708.2, CR 708.3
1571
+
1572
+ | Parameter | Description |
1573
+ | --- | --- |
1574
+ | `amount` | amount (default 1) |
1575
+ | `to` | players (default you) |
1576
+
1577
+ ```json
1578
+ {
1579
+ "manifest": {}
1580
+ }
1581
+ ```
1582
+
1583
+ ## manifest_dread
1584
+
1585
+ Each referenced player (default you) manifests dread: looks at the top two cards of their library, manifests one of them (decision `effect_choice`) and puts the other into their graveyard. Triggers on it (`keyword_action` "manifest_dread") see it after it's complete.
1586
+
1587
+ Rules: CR 701.62a, CR 701.62b, CR 701.40a, CR 701.20e
1588
+
1589
+ | Parameter | Description |
1590
+ | --- | --- |
1591
+ | `to` | players (default you) |
1592
+
1593
+ ```json
1594
+ {
1595
+ "manifest_dread": {}
1596
+ }
1597
+ ```
1598
+
1532
1599
  ## may
1533
1600
 
1534
- An optional effect. The controller chooses yes or no as it resolves; yes is offered only if every effect in `effects` can be done fully. On yes, `effects` then `then` ("if you do") happen; on no, `otherwise` ("if you don't"). Nested effects may name the results of earlier effects of the enclosing list.
1601
+ An optional effect. The controller chooses yes or no as it resolves; yes is offered only if every effect in `effects` can be done fully. On yes, `effects` then `then` ("if you do") happen; on no, `otherwise` ("if you don't"). Nested effects may name the results of earlier effects of the enclosing list ({"result": n} with n below this effect's position) and their own, numbered on from there: `effects` then `then` in one numbering, `otherwise` in its own ("if you do, ... the creature sacrificed this way").
1535
1602
 
1536
1603
  Rules: CR 118.12, CR 118.3, CR 608.2d, CR 608.2e
1537
1604
 
@@ -1858,7 +1925,7 @@ Rules: CR 701.70a
1858
1925
 
1859
1926
  ## reflexive_trigger
1860
1927
 
1861
- Creates a reflexive triggered ability ("when you do, ...") that triggers immediately, with the controller and source of the resolving spell or ability. Its `targets` are chosen as it's put on the stack; its `effects` may name the results of earlier effects of the creating list. With `if`, it triggers only when the condition holds ("when excess damage is dealt this way").
1928
+ Creates a reflexive triggered ability ("when you do, ...") that triggers immediately, with the controller and source of the resolving spell or ability. Its `targets` are chosen as it's put on the stack; its `effects` may name the results of earlier effects of the creating list ({"result": n} / {"this_way": n} with n below its position) and their own, numbered on from there. With `if`, it triggers only when the condition holds ("when excess damage is dealt this way").
1862
1929
 
1863
1930
  Rules: CR 603.12, CR 603.12a, CR 603.7d, CR 603.7e, CR 603.3d
1864
1931
 
@@ -1891,9 +1958,9 @@ Rules: CR 603.12, CR 603.12a, CR 603.7d, CR 603.7e, CR 603.3d
1891
1958
 
1892
1959
  ## remove_all_counters
1893
1960
 
1894
- Remove every counter named `counter` (every counter, if no `counter` is given) from each referenced permanent.
1961
+ Remove every counter named `counter` (every counter, if no `counter` is given) from each referenced permanent or player ("you lose all poison counters").
1895
1962
 
1896
- Rules: CR 122.8
1963
+ Rules: CR 122.8, CR 122.1
1897
1964
 
1898
1965
  | Parameter | Description |
1899
1966
  | --- | --- |
@@ -1913,9 +1980,9 @@ Rules: CR 122.8
1913
1980
 
1914
1981
  ## remove_counters
1915
1982
 
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, ...").
1983
+ Remove up to `amount` counters named `counter` from each referenced permanent or player (poison, experience, ...). How many were removed is {"this_way": n} ("remove a bait counter ... If you do, ...").
1917
1984
 
1918
- Rules: CR 122.8
1985
+ Rules: CR 122.8, CR 122.1
1919
1986
 
1920
1987
  | Parameter | Description |
1921
1988
  | --- | --- |
@@ -2325,6 +2392,22 @@ Rules: CR 614.1b, CR 614.10, CR 614.10a
2325
2392
  }
2326
2393
  ```
2327
2394
 
2395
+ ## solve
2396
+
2397
+ Each referenced permanent (default: this one) becomes solved if it isn't (a designation it keeps until it leaves the battlefield). Usually written through `to_solve`.
2398
+
2399
+ Rules: CR 720.3a, CR 720.3b
2400
+
2401
+ | Parameter | Description |
2402
+ | --- | --- |
2403
+ | `to` | selector of permanents (default self) |
2404
+
2405
+ ```json
2406
+ {
2407
+ "solve": {}
2408
+ }
2409
+ ```
2410
+
2328
2411
  ## surveil
2329
2412
 
2330
2413
  Look at the top `amount` cards of your library; put any number into your graveyard and the rest on top in any order.
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## any_target
6
6
 
7
- A creature, player or planeswalker (battles: later).
7
+ A creature, player, planeswalker or battle.
8
8
 
9
9
  Rules: CR 115.4
10
10
 
@@ -22,6 +22,16 @@ Rules: CR 115.1
22
22
  "artifact"
23
23
  ```
24
24
 
25
+ ## battle
26
+
27
+ A battle on the battlefield.
28
+
29
+ Rules: CR 310.5
30
+
31
+ ```json
32
+ "battle"
33
+ ```
34
+
25
35
  ## creature
26
36
 
27
37
  A creature on the battlefield.
@@ -478,6 +478,20 @@ Rules: CR 702.192a, CR 707.12, CR 603.7, CR 608.2g
478
478
  }
479
479
  ```
480
480
 
481
+ ## persist
482
+
483
+ When this permanent dies, if it had no -1/-1 counters on it, return it to the battlefield under its owner's control with a -1/-1 counter on it.
484
+
485
+ Rules: CR 702.79a, CR 603.10a, CR 603.4
486
+
487
+ ```json
488
+ {
489
+ "keywords": [
490
+ "persist"
491
+ ]
492
+ }
493
+ ```
494
+
481
495
  ## phasing
482
496
 
483
497
  During each of its controller's untap steps, before they untap, it phases out if it's phased in (and phases in if it phased out under their control).
@@ -534,6 +548,20 @@ Rules: CR 702.136a, CR 702.136b, CR 614.12
534
548
  }
535
549
  ```
536
550
 
551
+ ## split_second
552
+
553
+ As long as this spell is on the stack, players can't cast spells or activate abilities that aren't mana abilities (mana abilities, special actions and triggered abilities still work).
554
+
555
+ Rules: CR 702.61a, CR 702.61b, CR 702.61c
556
+
557
+ ```json
558
+ {
559
+ "keywords": [
560
+ "split second"
561
+ ]
562
+ }
563
+ ```
564
+
537
565
  ## start_your_engines
538
566
 
539
567
  If you control this permanent and have no speed, your speed becomes 1. Once you have speed, it increases by 1 (to at most 4) once on each of your turns when one or more opponents lose life. Pair with `max_speed` abilities and the `speed` amount.
@@ -632,6 +660,20 @@ Rules: CR 702.19b, CR 702.19e
632
660
  }
633
661
  ```
634
662
 
663
+ ## undying
664
+
665
+ When this permanent dies, if it had no +1/+1 counters on it, return it to the battlefield under its owner's control with a +1/+1 counter on it.
666
+
667
+ Rules: CR 702.93a, CR 603.10a, CR 603.4
668
+
669
+ ```json
670
+ {
671
+ "keywords": [
672
+ "undying"
673
+ ]
674
+ }
675
+ ```
676
+
635
677
  ## vigilance
636
678
 
637
679
  Attacking doesn't cause this creature to tap.
@@ -151,6 +151,24 @@ Rules: CR 715.3a, CR 715.3c, CR 505.4, CR 715.4, CR 704.5s
151
151
  }
152
152
  ```
153
153
 
154
+ ## siege
155
+
156
+ Battle type. As it enters, an opponent of its controller becomes its protector. When the last defense counter is removed from it, its controller exiles it, then may cast it transformed (its back face) without paying its mana cost.
157
+
158
+ Rules: CR 310.12, CR 310.9, CR 712.10, CR 608.2g
159
+
160
+ ```json
161
+ {
162
+ "types": [
163
+ "battle"
164
+ ],
165
+ "subtypes": [
166
+ "siege"
167
+ ],
168
+ "defense": 3
169
+ }
170
+ ```
171
+
154
172
  ## swamp
155
173
 
156
174
  Basic land type. A land with this subtype has "{T}: Add {B}."
@@ -289,6 +289,22 @@ Rules: CR 603.2, CR 601.2i, CR 113.6, CR 202.3e, CR 201.4, CR 607.2, CR 115.1, C
289
289
  }
290
290
  ```
291
291
 
292
+ ## commits_crime
293
+
294
+ A player commits a crime: they cast a spell, activate an ability or put a triggered ability on the stack that targets an opponent, a permanent, spell or ability an opponent controls, or a card in an opponent's graveyard (once per spell or ability). `controller`: you (default) | opponent | any. {"triggering": "object"} is that spell or ability. Amount `{"crimes_this_turn": player}` counts them.
295
+
296
+ Rules: CR 700.13, CR 603.2
297
+
298
+ | Parameter | Description |
299
+ | --- | --- |
300
+ | `controller` | you | opponent | any |
301
+
302
+ ```json
303
+ {
304
+ "commits_crime": {}
305
+ }
306
+ ```
307
+
292
308
  ## counters_placed
293
309
 
294
310
  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).
@@ -332,14 +348,15 @@ Rules: CR 702.122b, CR 603.2
332
348
 
333
349
  ## cycles
334
350
 
335
- A player (`controller`: you (default) | opponent | any) cycles a card (activates its cycling or typecycling ability; optional `card` filter).
351
+ A player (`controller`: you (default) | opponent | any) cycles a card (activates its cycling or typecycling ability; optional `card` filter). `self: true`: "when you cycle this card", an ability of the card with `zone: "graveyard"` (where the cycled card is); its X is the cycling ability's X.
336
352
 
337
- Rules: CR 702.29a, CR 702.29e
353
+ Rules: CR 702.29a, CR 702.29c, CR 702.29e, CR 113.6k
338
354
 
339
355
  | Parameter | Description |
340
356
  | --- | --- |
341
357
  | `controller` | you | opponent | any |
342
358
  | `card` | card filter |
359
+ | `self` | true |
343
360
 
344
361
  ```json
345
362
  {
@@ -351,7 +368,7 @@ Rules: CR 702.29a, CR 702.29e
351
368
 
352
369
  ## deals_damage
353
370
 
354
- The subject deals damage. `combat: true` only counts combat damage, `noncombat: true` only noncombat damage; `to`: player | opponent (of the source's controller) | creature | any (default). Triggers once per damage event (each combat damage step is one, so double strike can trigger twice).
371
+ The subject deals damage. `combat: true` only counts combat damage, `noncombat: true` only noncombat damage; `to`: player | opponent | you (players, relative to the source's controller) | creature | planeswalker | battle | permanent | any (default), or a list of them ("a player or planeswalker"). Triggers once per damage event (each combat damage step is one, so double strike can trigger twice). `batched: true`: "one or more ... deal damage", once per event batch (a combat damage step); then {"triggering": "objects"} are the sources that dealt it and {"triggering": "amount"} the number of damage events.
355
372
 
356
373
  Rules: CR 510.2, CR 603.2, CR 603.2c, CR 120.2a, CR 120.2b, CR 120.3
357
374
 
@@ -360,7 +377,8 @@ Rules: CR 510.2, CR 603.2, CR 603.2c, CR 120.2a, CR 120.2b, CR 120.3
360
377
  | `subject` | "self" (default) or {"each": filter, ...} |
361
378
  | `combat` | true | false |
362
379
  | `noncombat` | true | false |
363
- | `to` | player | opponent | creature | any |
380
+ | `to` | player | opponent | you | creature | planeswalker | battle | permanent | any, or a list of them |
381
+ | `batched` | true | false |
364
382
 
365
383
  ```json
366
384
  {
@@ -395,13 +413,14 @@ Rules: CR 120.3, CR 603.2, CR 603.2c, CR 120.2a, CR 120.2b
395
413
 
396
414
  ## dies
397
415
 
398
- The subject is put into a graveyard from the battlefield. Looks back in time (CR 603.10a).
416
+ The subject is put into a graveyard from the battlefield. Looks back in time (CR 603.10a). `batched: true`: "whenever one or more ... die", once per event batch (creatures dying at the same time, e.g. to lethal combat damage); {"triggering": "objects"} are the cards put into graveyards and {"triggering": "amount"} how many.
399
417
 
400
- Rules: CR 603.6c, CR 603.10a, CR 700.4
418
+ Rules: CR 603.6c, CR 603.10a, CR 700.4, CR 603.2c
401
419
 
402
420
  | Parameter | Description |
403
421
  | --- | --- |
404
422
  | `subject` | "self" (default) or {"each": filter, ...} |
423
+ | `batched` | true | false |
405
424
 
406
425
  ```json
407
426
  {
@@ -468,15 +487,16 @@ Rules: CR 701.66b
468
487
 
469
488
  ## enters
470
489
 
471
- The subject enters the battlefield. `untapped: true`: only if it entered untapped. `from`: only if it entered from that zone ("enters from exile").
490
+ The subject enters the battlefield. `untapped: true`: only if it entered untapped. `from`: only if it entered from that zone ("enters from exile"). `batched: true`: "whenever one or more ... enter", once per event batch; {"triggering": "objects"} are the permanents that entered and {"triggering": "amount"} how many.
472
491
 
473
- Rules: CR 603.6a, CR 603.2, CR 614.12
492
+ Rules: CR 603.6a, CR 603.2, CR 603.2c, CR 614.12
474
493
 
475
494
  | Parameter | Description |
476
495
  | --- | --- |
477
496
  | `subject` | "self" (default) or {"each": filter, "controller": you|opponent|any, "other": true} |
478
497
  | `untapped` | true | false |
479
498
  | `from` | hand | graveyard | exile | library | stack | outside |
499
+ | `batched` | true | false |
480
500
 
481
501
  ```json
482
502
  {
@@ -802,6 +822,47 @@ Rules: CR 701.27f, CR 603.2
802
822
  }
803
823
  ```
804
824
 
825
+ ## turned_face_up
826
+
827
+ The subject (default this permanent) is turned face up. On a card with morph, disguise or that can be manifested, it's "when this creature is turned face up".
828
+
829
+ Rules: CR 708.8, CR 702.37e, CR 702.168d, CR 603.2
830
+
831
+ | Parameter | Description |
832
+ | --- | --- |
833
+ | `subject` | "self" (default) or {"each": filter, "controller": ...} |
834
+
835
+ ```json
836
+ {
837
+ "turned_face_up": {}
838
+ }
839
+ ```
840
+
841
+ ## unlocks_door
842
+
843
+ A Room permanent (the subject, default this one) gets an unlocked designation. On a Room's door, `{}` means "when you unlock this door". `door`: left | right | any; `fully: true`: only when it now has both doors unlocked ("whenever you fully unlock a Room").
844
+
845
+ Rules: CR 709.5h, CR 709.5i, CR 709.5j, CR 603.2
846
+
847
+ | Parameter | Description |
848
+ | --- | --- |
849
+ | `door` | left | right | any (set on a door's own trigger) |
850
+ | `fully` | true |
851
+ | `subject` | "self" (default) or {"each": filter, "controller": ...} |
852
+
853
+ ```json
854
+ {
855
+ "unlocks_door": {
856
+ "door": "any",
857
+ "fully": true,
858
+ "subject": {
859
+ "each": "permanent",
860
+ "controller": "you"
861
+ }
862
+ }
863
+ }
864
+ ```
865
+
805
866
  ## waterbends
806
867
 
807
868
  A player (`controller`: you (default) | opponent | any) waterbends.
@@ -18,6 +18,26 @@ Rules: CR 301.1
18
18
  }
19
19
  ```
20
20
 
21
+ ## battle
22
+
23
+ A permanent with a printed `defense`: it enters with that many defense counters. Each battle has a protector (a Siege's is an opponent of its controller, chosen as it enters); the protector's opponents can attack it and the protector can block for it. Damage dealt to it removes defense counters; with none left it's put into its owner's graveyard (unless it's the source of a triggered ability still waiting or on the stack). Every battle needs a battle type: siege (CR 205.3q).
24
+
25
+ Rules: CR 310.1, CR 310.4, CR 310.5, CR 310.6, CR 310.7, CR 310.9, CR 120.3h, CR 704.5v, CR 205.3q
26
+
27
+ ```json
28
+ {
29
+ "name": "Example Invasion",
30
+ "mana_cost": "{2}{R}",
31
+ "types": [
32
+ "battle"
33
+ ],
34
+ "subtypes": [
35
+ "siege"
36
+ ],
37
+ "defense": 4
38
+ }
39
+ ```
40
+
21
41
  ## creature
22
42
 
23
43
  A permanent with power and toughness that can attack and block. Cast at sorcery speed. It can't attack or use {T} abilities unless controlled continuously since its controller's most recent turn began (summoning sickness).
@@ -16,8 +16,12 @@ module Enjine
16
16
  end
17
17
 
18
18
  def self.options(engine, index)
19
+ own = engine.own_abilities_only?
19
20
  engine.player(index).hand.flat_map do |id|
20
21
  obj = engine.object(id)
22
+ # no face with a special action: a quick no (Engine::Casting#printed_faces_only?)
23
+ next [] if engine.printed_faces_only?(obj, own) && !engine.card_off_board(obj.card)[:special_actions]
24
+
21
25
  engine.chars(obj).abilities.filter_map do |inst|
22
26
  ability = inst.ability
23
27
  next unless ability.respond_to?(:special!) && ability.special_allowed?(engine, obj, index)
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Enjine
4
+ module Actions
5
+ # CR 116.2b, 708.7: turning a face-down permanent you control face up is a special action, taken any time you
6
+ # have priority: show its cost and pay it (a "pay" frame, which can be cancelled), then you get priority again
7
+ # (CR 116.3). `via`: "mana_cost" (a manifested or cloaked creature card, CR 701.40b, 701.58b), "morph" (CR 702.37e)
8
+ # or "disguise" (CR 702.168d).
9
+ class TurnFaceUp
10
+ def self.doc
11
+ '`{type: "turn_face_up", object: id, via: "mana_cost" | "morph" | "disguise"}` — turn a face-down permanent you ' \
12
+ "control face up by paying its mana cost (a manifested or cloaked creature card) or its morph or disguise " \
13
+ "cost (a special action, any time you have priority, CR 116.2b)."
14
+ end
15
+
16
+ def self.options(engine, index) = engine.face_up_options(index)
17
+
18
+ def self.perform(engine, index, option)
19
+ cost = engine.face_up_costs(engine.object(option[:object])).fetch(option[:via])
20
+ engine.begin_payment!(index, cost, option[:object], special: { "object" => option[:object], "face_up" => option[:via] })
21
+ end
22
+ end
23
+ register("turn_face_up", TurnFaceUp)
24
+ end
25
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Enjine
4
+ module Actions
5
+ # CR 116.2m, 709.5e: unlocking a locked door of a Room permanent you control is a special action, taken any time
6
+ # you have priority and the stack is empty during a main phase of your turn: you pay that door's mana cost (its
7
+ # unlock cost) in a "pay" frame, which can be cancelled, then get priority again (CR 116.3).
8
+ class Unlock
9
+ def self.doc
10
+ '`{type: "unlock", object: id, door: "left" | "right"}` — unlock a locked door of a Room you control by paying ' \
11
+ "that door's mana cost (a special action, during a main phase of your turn with an empty stack, CR 116.2m, 709.5e)."
12
+ end
13
+
14
+ def self.options(engine, index) = engine.unlock_options(index)
15
+
16
+ def self.perform(engine, index, option)
17
+ engine.begin_payment!(index, engine.door_cost(engine.object(option[:object]), option[:door]), option[:object],
18
+ special: { "object" => option[:object], "unlock" => option[:door] })
19
+ end
20
+ end
21
+ register("unlock", Unlock)
22
+ end
23
+ end