enjine 0.6.4 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 561a05c36e12fe1f8eca6f71d25c412c975d027bec6286ff49dce6ef94b95beb
4
- data.tar.gz: 01470fd337d6e3c71221db45b5104a3785c00d5bff3467c585d56ea7e35726d9
3
+ metadata.gz: 3012cc845c2796a139ce071514d69a5bfefeb10452b9c532645231e1b6028a24
4
+ data.tar.gz: e47ea9aa052adbe4df596909bb0970f828aa20a306b6cf5aebf74d30d0aae6ea
5
5
  SHA512:
6
- metadata.gz: a1e1dc78d50f99ba6db78b1e037c9391c2c4dff9ef79cb52f4843c7f42bf47dc8b1c563c0c7916a0c4198fc1327b126f59ea0ad139837f50f7a3bcccc9315835
7
- data.tar.gz: 47077067bafdfabe16fa200d3e775397fbbfe8e082a81af7c92d09e875e94bf045176feb3edf464a6614dfa98f3aa3b8ffc1a1a5804da13ba2d86ab155406844
6
+ metadata.gz: 0aee99ee4cf6d951533bf903b211cc4fc7caf2db52701a63295f4d8518ef15b6320fe58cbd70833a0775ee3e092cea7452035f66bbb57a3dcb9ca72d116189ea
7
+ data.tar.gz: 41fb58dfc13a72d73dd735bdd028cc61bfe755794216599b8bf22bb53f4cb4831b92401e35f5a1816850b7088b7c0b245434248d44262fc1c804b55f6b6976e0
data/CHANGELOG.md CHANGED
@@ -8,6 +8,46 @@ change the public API; the stable surface is described in
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [0.6.5] - 2026-12-05
12
+
13
+ ### Added
14
+ - `spend_only` reads the creature type chosen for the mana's source (`"subtypes": "chosen"` in its card spec), fixed as
15
+ the mana is made so pool mana keeps it after the source leaves (CR 607.2d, 106.6), and takes `"cant_be_countered":
16
+ true`: a spell cast with that mana can't be countered (CR 101.2; the spell remembers it, a copy doesn't). Cavern of
17
+ Souls is `{"mana": {"cost": ["tap"], "color": "any_one", "spend_only": {"spells": {"types": ["creature"], "subtypes":
18
+ "chosen"}, "cant_be_countered": true}}}` with `{"choose_creature_type": {}}`.
19
+ - The `each` selector's `controller` takes `{"target": n}`, a targeted player: "put a +1/+1 counter on each creature
20
+ target player controls" is `{"each": "creature", "controller": {"target": 0}}` (nothing if that player is an illegal
21
+ target, CR 608.2b). Practiced Offense.
22
+ - `choose_cards` `from` takes a `library` zone, and several zones at once as one choice (`{"graveyard": P, "hand": P,
23
+ "library": P}`, "search its owner's graveyard, hand, and library", CR 701.23a); its amount (`{"this_way": n}`) is how
24
+ many of the chosen cards came from a hand. Card specs take `{"same_name_as": {"result": n}}`: the name of a card an
25
+ earlier effect moved (CR 201.2). Deadly Cover-Up's "exile a card from an opponent's graveyard. Then search its
26
+ owner's graveyard, hand, and library for any number of cards with that name and exile them. That player shuffles,
27
+ then draws a card for each card exiled from their hand this way" plays as printed.
28
+ - A mana ability's cost may include `tap_permanents` (count 1): "{T}, Tap an untapped creature you control: Add one
29
+ mana of any color" (Springleaf Drum: `{"mana": {"cost": ["tap", {"tap_permanents": {"filter": "creature"}}], "color":
30
+ "any_one"}}`; Gene Pollinator taps any `"permanent"`). The permanent to tap is part of the activation, since a mana
31
+ ability is paid for at once (CR 605.3a, 602.2b): each `activate_mana` option names it with `tap: id` (one option per
32
+ permanent and mana choice; permanents that make no mana are listed first). It needn't be untapped since the turn began
33
+ (CR 302.6), the source can't tap itself for both costs (CR 601.2h), a permanent the spell or ability being paid for
34
+ still needs can't be tapped for it, and tapping it is rewound with the payment (CR 734.1). Affordability counts each
35
+ permanent once: tapping a land for the cost only changes the color of its mana.
36
+ - `cost_modifier` takes `first: "each_turn" | "each_of_your_turns"`: only the first matching spell its caster casts
37
+ each turn (or during each of their turns) is changed; spells cast earlier that turn count even if the permanent wasn't
38
+ there yet, and a cancelled cast never counts (CR 601.2f, 601.2i). Its `spells` also take `keywords` and `not_subtypes`.
39
+ Momo, Friendly Flier is `{"cost_modifier": {"spells": {"any_of": ["creature"], "keywords": ["flying"], "not_subtypes":
40
+ ["lemur"]}, "reduce": 1, "first": "each_of_your_turns"}}`. The turn log keeps each spell's types, subtypes, keywords
41
+ and colors as cast (`"spells_as_cast"`), so a changeling is a Lemur spell and the face cast is the one matched.
42
+ - Bargain (CR 702.166a-c): `"bargain"` in `abilities`, an optional additional cost (sacrifice an artifact, enchantment
43
+ or token) announced like kicker (`choose_kicker`, then `choose_cost`); the spell isn't kicked. `{"cast_with":
44
+ "bargain"}` holds if it was bargained.
45
+ - `deal_damage` takes `"exile_if_dies": true`: "if a permanent dealt damage this way would die this turn, exile it
46
+ instead" applies only to the permanents actually dealt damage (after prevention and redirection), until end of turn
47
+ (CR 614.1a, 700.4). Torch the Tower is `"bargain"` plus `{"deal_damage": {"amount": 2, "to": {"target": 0},
48
+ "exile_if_dies": true, "if": {"not": {"cast_with": "bargain"}}}}`, the same with 3 if bargained, and `{"scry":
49
+ {"amount": 1, "if": {"cast_with": "bargain"}}}`.
50
+
11
51
  ## [0.6.4] - 2026-12-04
12
52
 
13
53
  ### Added
@@ -373,7 +413,8 @@ Includes 0.4.0, which was tagged but never published to RubyGems.
373
413
  - `enjine` CLI: hot-seat and random play, `--validate`, `--verify`,
374
414
  `--random-deck`, save and load.
375
415
 
376
- [Unreleased]: https://github.com/thisiscetin/enjine/compare/v0.6.4...HEAD
416
+ [Unreleased]: https://github.com/thisiscetin/enjine/compare/v0.6.5...HEAD
417
+ [0.6.5]: https://github.com/thisiscetin/enjine/compare/v0.6.4...v0.6.5
377
418
  [0.6.4]: https://github.com/thisiscetin/enjine/compare/v0.6.3...v0.6.4
378
419
  [0.6.3]: https://github.com/thisiscetin/enjine/compare/v0.6.2...v0.6.3
379
420
  [0.6.2]: https://github.com/thisiscetin/enjine/compare/v0.6.1...v0.6.2
data/SUPPORTED.md CHANGED
@@ -102,6 +102,7 @@ Rules version: Comprehensive Rules effective 2026-11-06.
102
102
  | [`additional_cost`](docs/reference/abilities.md#additional_cost) | 601.2b, 601.2f, 601.2h, 118.8, 118.8b, 601.3c | 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. |
103
103
  | [`additional_land_plays`](docs/reference/abilities.md#additional_land_plays) | 305.2, 305.2a, 305.2b, 604.1 | Its controller may play an additional land on each of their turns. Each instance adds one land play (CR 305.2); lands put onto the battlefield by effects don't count. |
104
104
  | [`additional_triggers`](docs/reference/abilities.md#additional_triggers) | 603.2d, 119.9, 607.2d | While this permanent is on the battlefield, a triggered ability of a permanent its controller controls triggers an additional time if it triggers because of `cause` (you_gain_life: its controller gaining life) and/or its permanent matches `of` (a filter: "triggered abilities of Allies you control", {"creature": {"other": true, "subtypes": "chosen"}}). At least one of them. |
105
+ | [`bargain`](docs/reference/abilities.md#bargain) | 702.166a, 702.166b, 702.166c, 601.2b, 601.2h, 701.21a | Bargain: as you cast this spell you may sacrifice an artifact, enchantment or token (announced with the `choose_kicker` decision, the permanent chosen with `choose_cost`; the spell isn't kicked). `{"cast_with": "bargain"}` holds if it was bargained. |
105
106
  | [`beam_me_up`](docs/reference/abilities.md#beam_me_up) | 702.196a, 702.196b, 118.9, 601.2b, 601.2f, 601.2h | You may cast this instant or sorcery card from your graveyard for `cost` plus returning a creature you control to its owner's hand, instead of its mana cost. If you do, it's exiled whenever it would leave the stack. Offered as a cast option with `via: "beam:<ref>"`. |
106
107
  | [`can_block_only`](docs/reference/abilities.md#can_block_only) | 509.1b, 509.1a | This creature can block only attacking creatures matching `filter` (checked as blockers are declared, with their current characteristics; controller-relative filter keys are seen from this creature's controller). |
107
108
  | [`cant_be_blocked_by`](docs/reference/abilities.md#cant_be_blocked_by) | 509.1b, 509.1a | This creature can't be blocked by creatures matching `filter` (checked as blockers are declared, with their current characteristics). |
@@ -118,7 +119,7 @@ Rules version: Comprehensive Rules effective 2026-11-06.
118
119
  | [`choose_number`](docs/reference/abilities.md#choose_number) | 614.12, 614.12a, 607.2 | As this permanent enters, its controller chooses a number from `min` to `max`; abilities of it that say "the chosen number" use it. |
119
120
  | [`choose_option`](docs/reference/abilities.md#choose_option) | 614.12, 607.2f, 614.12b | As this permanent enters, its controller chooses one of the `options` (words with no rules meaning); a condition {"chosen": word} is true when that word was chosen. |
120
121
  | [`class_level`](docs/reference/abilities.md#class_level) | 717.2a, 717.2b, 717.2d, 717.3, 602.5d | A class level bar: `cost` (a mana cost string or a list of costs): this permanent's level becomes `level`; activate only if its level is `level` - 1, as a sorcery. While its level is `level` or greater it has `keywords` and `abilities`. A permanent without a level is level 1. |
121
- | [`cost_modifier`](docs/reference/abilities.md#cost_modifier) | 601.2f, 118.7a, 604.1, 601.2a | While on the battlefield: spells cast by `caster` (you, opponent or any; default you) whose card types match `spells` ({"any_of": [types], "not": [types]}, default all spells; `subtypes`, `colors` and `name` narrow it: "Dragon spells", "red spells"; `"subtypes": "chosen"`: of the type chosen for this permanent, `"name": "chosen"`: with the name its source chose) cost `reduce` less or `increase` more generic mana. `from` / `not_from`: only spells cast from (not from) that zone (hand | graveyard | exile | library | outside). |
122
+ | [`cost_modifier`](docs/reference/abilities.md#cost_modifier) | 601.2f, 118.7a, 604.1, 601.2a, 601.2i | While on the battlefield: spells cast by `caster` (you, opponent or any; default you) whose card types match `spells` ({"any_of": [types], "not": [types]}, default all spells; `subtypes`, `colors` and `name` narrow it: "Dragon spells", "red spells"; `"subtypes": "chosen"`: of the type chosen for this permanent, `"name": "chosen"`: with the name its source chose; `keywords` / `not_subtypes`: "non-Lemur creature spells with flying") cost `reduce` less or `increase` more generic mana. `from` / `not_from`: only spells cast from (not from) that zone (hand | graveyard | exile | library | outside). `first`: only the first matching spell its caster casts `each_turn` or `each_of_your_turns` (spells cast before this permanent was there count too). |
122
123
  | [`cost_reduction`](docs/reference/abilities.md#cost_reduction) | 601.2f, 118.7a, 702.41a | This spell costs `amount` generic mana less to cast, if the optional `if` condition holds when its total cost is determined (after targets are chosen). `amount` may be computed, e.g. {"count": {"each": "artifact", "controller": "you"}} for affinity for artifacts (CR 702.41a). It can't reduce colored mana or go below {0}. |
123
124
  | [`craft`](docs/reference/abilities.md#craft) | 702.167a, 702.167b, 702.167c, 712.11a, 602.2b, 406.1 | Craft with `materials` `cost`: pay `cost`, exile this permanent and exile the materials (`count` (default 1) permanents you control and/or cards in your graveyard matching the card spec `card`; `or_more: true`: that many or more), chosen with `choose_cost`: return this card to the battlefield transformed under its owner's control. Sorcery speed. The exiled materials are the selector "exiled_for_cost". |
124
125
  | [`crew`](docs/reference/abilities.md#crew) | 702.122a, 702.122b, 702.122e, 301.7, 301.7a, 301.7b, 208.3, 302.6 | Crew N: tap any number of other untapped creatures you control with total power N or more (chosen one at a time; `done` once the total is enough): this permanent becomes an artifact creature until end of turn. A Vehicle has its printed power and toughness only while it's a creature. |
@@ -159,7 +160,7 @@ Rules version: Comprehensive Rules effective 2026-11-06.
159
160
  | [`life_gain_replacement`](docs/reference/abilities.md#life_gain_replacement) | 614.1a, 614.5, 616.1, 119.10 | While this permanent is on the battlefield, each time `player` (you (default) | opponent | any, relative to its controller) would gain life, instead: `multiply` (2 = "twice that much"), `plus` an amount ("that much life plus 1"), or `lose: true` ("that player loses that much life instead"). Each applies once to an event; the affected player's best order is used: losing instead first, then adding, then multiplying. Gaining 0 life is no event (nothing applies). |
160
161
  | [`look_at_top`](docs/reference/abilities.md#look_at_top) | 401.5, 604.1 | While this permanent is on the battlefield, its controller sees the top card of their library (the `library_top` of their view). |
161
162
  | [`loyalty`](docs/reference/abilities.md#loyalty) | 606.3, 606.4, 606.5, 602.2b | A loyalty ability. Its cost adds (positive) or removes (negative) loyalty counters and is paid on activation. Sorcery speed, and only one loyalty ability per planeswalker per turn. |
162
- | [`mana`](docs/reference/abilities.md#mana) | 605.1a, 605.3a, 605.3b, 106.1a, 106.4, 106.6, 607.2d, 602.5b, 122.1 | An activated mana ability: pay the cost, add the mana to your mana pool immediately. It does not use the stack and can be activated whenever you have priority. `produce`: the fixed mana (`amount` times). Or `color`: `amount` mana (default 1) of one color you choose as you activate it (`"any_one"`) or in any combination of colors (`"any"`); `colors` limits the choice. `"chosen"`: of the color chosen as this entered (choose_color). `spend_only` restricts how the mana can be spent. `only_if`: "Activate only if ...". `limit: "once_each_turn"`: "Activate only once each turn." `add_counters`: it also puts counters on its own source ("Add {C}. Put a point counter on this"). |
163
+ | [`mana`](docs/reference/abilities.md#mana) | 605.1a, 605.3a, 605.3b, 106.1a, 106.4, 106.6, 607.2d, 602.5b, 122.1, 101.2, 602.2b, 302.6 | An activated mana ability: pay the cost, add the mana to your mana pool immediately. It does not use the stack and can be activated whenever you have priority. `produce`: the fixed mana (`amount` times). Or `color`: `amount` mana (default 1) of one color you choose as you activate it (`"any_one"`) or in any combination of colors (`"any"`); `colors` limits the choice. `"chosen"`: of the color chosen as this entered (choose_color). `spend_only` restricts how the mana can be spent (a spec of `"subtypes": "chosen"`: the creature type chosen as this entered; `"cant_be_countered": true`: a spell cast with it can't be countered). `only_if`: "Activate only if ...". `limit: "once_each_turn"`: "Activate only once each turn." `add_counters`: it also puts counters on its own source ("Add {C}. Put a point counter on this"). A `tap_permanents` cost (count 1) taps another permanent you choose as you activate it ("{T}, Tap an untapped creature you control"): each activation option names it (`tap`). |
163
164
  | [`max_speed`](docs/reference/abilities.md#max_speed) | 702.178a, 702.178b, 702.179e, 113.6c | While your speed is 4 (max speed), this object has `keywords` and `abilities` (any kind: activated, triggered, static, mana; an ability with a graveyard cost works from your graveyard). |
164
165
  | [`may_not_untap`](docs/reference/abilities.md#may_not_untap) | 502.3, 604.1 | Its controller may choose not to untap it during their untap step (decision `untap_choice`, asked only while it's tapped). |
165
166
  | [`mayhem`](docs/reference/abilities.md#mayhem) | 702.187a, 702.187b, 702.187c, 118.9, 601.2b, 601.2f, 601.2h, 305.1 | Mayhem: as long as you discarded this card this turn, you may cast it from your graveyard by paying `cost` rather than its mana cost. Without `cost` (`"mayhem"`), you may play it from your graveyard (a land too) if you discarded it this turn. Cast option `via: "alt:<ref>"`. |
@@ -294,7 +295,7 @@ Rules version: Comprehensive Rules effective 2026-11-06.
294
295
  | [`change_target`](docs/reference/effects.md#change_target) | 115.7, 115.7a, 115.7e | 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. |
295
296
  | [`choose_card_name`](docs/reference/effects.md#choose_card_name) | 201.4, 607.2d, 608.2c | 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. |
296
297
  | [`choose_card_type`](docs/reference/effects.md#choose_card_type) | 205.2a, 607.2d, 608.2c | The player (`to`, default you) chooses a card type; later effects of this spell or ability read it with "types": "chosen". |
297
- | [`choose_cards`](docs/reference/effects.md#choose_cards) | 701.20a, 701.20e, 400.7j, 608.2c, 607.2a, 118.12, 701.9a, 701.9b, 608.2d | 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. |
298
+ | [`choose_cards`](docs/reference/effects.md#choose_cards) | 701.20a, 701.20e, 400.7j, 608.2c, 607.2a, 118.12, 701.9a, 701.9b, 608.2d, 701.23a, 701.23b | 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} / {"library": selector}, or several of them ("search its owner's graveyard, hand, and library": one choice among them all). `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. Its amount ({"this_way": n}) is how many of the cards came from a hand ("draws a card for each card exiled from their hand this way"). |
298
299
  | [`choose_color`](docs/reference/effects.md#choose_color) | 105.4, 607.2d, 608.2c | The player (`to`, default you) chooses a color; later effects of this spell or ability read it with "colors": "chosen". |
299
300
  | [`choose_creature_type`](docs/reference/effects.md#choose_creature_type) | 205.3m, 607.2d, 608.2c | The player (`to`, default you) chooses a creature type; later effects of this spell or ability read it with "subtypes": "chosen". |
300
301
  | [`choose_new_targets`](docs/reference/effects.md#choose_new_targets) | 115.7, 115.7d, 115.7e | You may choose new targets for each spell or ability on the stack `of` refers to (e.g. {"triggering": "object"}: "that spell"): for each target, keep it or pick another legal target for that spell. |
@@ -311,7 +312,7 @@ Rules version: Comprehensive Rules effective 2026-11-06.
311
312
  | [`create_token_copy`](docs/reference/effects.md#create_token_copy) | 707.2, 707.8, 707.9a, 707.9b, 205.1a, 205.1b, 111.1, 614.1c | For each object `of` refers to (a permanent, a card in any zone, or the source with "self"), the referenced players (default: you) each create `amount` tokens that are copies of it: its copiable values (its card as modified by other copy effects, not counters, status or other effects), with the `except` modifications. The tokens are the effect's result, for later effects such as granting haste or a delayed sacrifice. |
312
313
  | [`damage_replacement`](docs/reference/effects.md#damage_replacement) | 614.1a, 611.2a, 611.2c, 616.1 | For the `duration` (end_of_turn by default, or until_your_next_turn), damage that would be dealt to the referenced players and permanents (`to`, fixed as it resolves; with `permanents: true` also the permanents a referenced player controls as the damage is dealt) is changed: `multiply` (2 = "double that damage") or `plus` an amount (computed as it resolves). `combat`: combat | noncombat only. Doubling applies before adding. |
313
314
  | [`damage_unpreventable`](docs/reference/effects.md#damage_unpreventable) | 615.12, 611.2a | Until end of turn, damage (`combat`: combat | noncombat only) can't be prevented. |
314
- | [`deal_damage`](docs/reference/effects.md#deal_damage) | 120.3a, 120.3c, 120.3e, 120.6, 120.4a, 120.10 | Deal `amount` damage to each referenced creature, planeswalker or player. Damage to a player causes life loss; to a planeswalker removes loyalty counters; to a creature is marked until cleanup. {"this_way": n} naming it is the excess damage it dealt (beyond lethal damage, or a planeswalker's loyalty). |
315
+ | [`deal_damage`](docs/reference/effects.md#deal_damage) | 120.3a, 120.3c, 120.3e, 120.6, 120.4a, 120.10, 614.1a, 700.4 | Deal `amount` damage to each referenced creature, planeswalker or player. Damage to a player causes life loss; to a planeswalker removes loyalty counters; to a creature is marked until cleanup. {"this_way": n} naming it is the excess damage it dealt (beyond lethal damage, or a planeswalker's loyalty). `exile_if_dies: true`: a permanent dealt damage this way that would die this turn is exiled instead (not one whose damage was prevented). |
315
316
  | [`delayed_trigger`](docs/reference/effects.md#delayed_trigger) | 603.7a, 603.7b, 603.7c, 603.7d, 603.7e, 107.3n | 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. |
316
317
  | [`destroy`](docs/reference/effects.md#destroy) | 701.8a | Destroy each referenced permanent (it goes to its owner's graveyard). |
317
318
  | [`dig`](docs/reference/effects.md#dig) | 701.20a, 701.20e, 401.4, 400.7j, 406.3, 607.2a, 702.75a | 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). |
data/docs/guides/api.md CHANGED
@@ -307,6 +307,9 @@ game.submit(type: "activate_mana", object: "mountain#3",
307
307
  game.submit(type: "pay_mana", mana: "R") # pay_cost: spend it -> the spell is cast
308
308
  ```
309
309
 
310
+ A mana ability whose mana is chosen as it's activated has one option per choice (`mana: "{G}"`), and one whose cost
311
+ taps another permanent ("{T}, Tap an untapped creature you control") has one per permanent it could tap (`tap: id`).
312
+
310
313
  Depending on the card, the engine also asks for modes (`choose_mode`), X
311
314
  (`choose_x`), kicker (`choose_kicker`), the number of targets
312
315
  (`choose_target_count`), how to divide damage (`distribute`), or which permanent
@@ -98,6 +98,7 @@ pool, so tap other sources first:
98
98
  | --- | --- |
99
99
  | "{T}: Add one mana of any color." | `{ "mana": { "cost": ["tap"], "color": "any_one" } }` |
100
100
  | "{T}: Add {R} or {G}." | `{ "mana": { "cost": ["tap"], "color": "any_one", "colors": ["R", "G"] } }` |
101
+ | "{T}, Tap an untapped creature you control: Add one mana of any color." | `{ "mana": { "cost": ["tap", { "tap_permanents": { "filter": "creature" } }], "color": "any_one" } }`: the permanent to tap is named by each activation option (`"tap": id`, CR 605.3a, 602.2b); only one (count 1) |
101
102
  | "{T}: Add two mana in any combination of {R} and/or {G}." | `{ "mana": { "cost": ["tap"], "color": "any", "amount": 2, "colors": ["R", "G"] } }` |
102
103
  | "{T}: Add {G} for each creature you control." | `{ "mana": { "cost": ["tap"], "produce": "{G}", "amount": { "count": { "each": "creature", "controller": "you" } } } }` |
103
104
  | "{T}: Add X mana of any one color, where X is …" | `"color": "any_one", "amount": <amount>` |
@@ -106,6 +107,7 @@ pool, so tap other sources first:
106
107
  | "{T}, Remove a charge counter from this: Add one mana of any color." | `{ "mana": { "cost": ["tap", { "remove_counters": { "count": 1, "counter": "charge", "self": true } }], "color": "any_one" } }` (only `self: true` with a named `counter`: no choice; without {T} it may be activated once per counter) |
107
108
  | "{T}: Add {C}. Put a point counter on this." | `{ "mana": { "cost": ["tap"], "produce": "{C}", "add_counters": { "counter": "point", "amount": 1 } } }` (`amount` defaults to 1; using it during a payment makes the payment irreversible) |
108
109
  | "{T}: Add {C}. Spend this mana only to cast artifact spells or activate abilities of artifacts." | `{ "mana": { "cost": ["tap"], "produce": "{C}", "spend_only": { "spells": { "types": ["artifact"] }, "abilities": { "types": ["artifact"] } } } }` |
110
+ | "As this land enters, choose a creature type. {T}: Add one mana of any color. Spend this mana only to cast a creature spell of the chosen type, and that spell can't be countered." (Cavern of Souls) | `{ "choose_creature_type": {} }`, `{ "mana": { "cost": ["tap"], "color": "any_one", "spend_only": { "spells": { "types": ["creature"], "subtypes": "chosen" }, "cant_be_countered": true } } }` |
109
111
 
110
112
  ```json
111
113
  { "name": "Example Lyceum", "types": ["land"],
@@ -118,7 +120,10 @@ card spec (`"card"` for any spell or source). The mana stays in its own part of
118
120
  (`restricted_mana` in the view) and is offered as `{"type": "pay_mana", "mana": "C",
119
121
  "restricted": 0}` only while casting a matching spell or activating an ability of a
120
122
  matching source; it can't pay a cost asked for while something resolves. `add_mana`
121
- takes `spend_only` too ("Add {C}{C}. Spend this mana only to cast spells.").
123
+ takes `spend_only` too ("Add {C}{C}. Spend this mana only to cast spells."). A spec of
124
+ `"subtypes": "chosen"` is the creature type chosen for the mana's source, fixed as the mana is made, so the mana
125
+ keeps it after the source leaves (CR 607.2d, 106.6); with no type chosen it pays for nothing. `"cant_be_countered":
126
+ true` (with `spells`): a spell cast with this mana can't be countered (CR 101.2).
122
127
 
123
128
  ---
124
129
 
@@ -286,6 +291,7 @@ whose qualities must all match:
286
291
  | `"attached"` | "equipped creature" / "enchanted creature", on an Equipment or Aura |
287
292
  | `{ "each": "creature", "controller": "you" }` | "creatures you control", "each creature you control" |
288
293
  | `{ "each": "creature", "controller": "opponent" }` | "creatures your opponents control" |
294
+ | `{ "each": "creature", "controller": { "target": 0 } }` | "each creature target player controls" (none if that player is no longer a legal target, CR 608.2b) |
289
295
  | `{ "each": "creature" }` | "each creature", "all creatures" |
290
296
  | `{ "result": 0 }` | "it" / "that card" / "the token": what effect 0 of the same list moved or created (CR 400.7j) |
291
297
  | `"gift_recipient"` | "the chosen player" of a gift (CR 702.174a; see 4.24) |
@@ -414,6 +420,7 @@ See `docs/reference/effects.md` for the generated list. Currently:
414
420
  | "Noncreature spells you cast cost {1} less to cast." | `{ "cost_modifier": { "spells": { "not": ["creature"] }, "reduce": 1 } }` |
415
421
  | "Spells your opponents cast cost {1} more to cast." | `{ "cost_modifier": { "caster": "opponent", "increase": 1 } }` |
416
422
  | "Dragon spells you cast cost {1} less" / "Red spells you cast cost {1} less" | `{ "cost_modifier": { "spells": { "subtypes": ["dragon"] }, "reduce": 1 } }` / `"spells": { "colors": ["R"] }` (combine with `any_of` / `not`) |
423
+ | "The first non-Lemur creature spell with flying you cast during each of your turns costs {1} less to cast." | `{ "cost_modifier": { "spells": { "any_of": ["creature"], "keywords": ["flying"], "not_subtypes": ["lemur"] }, "reduce": 1, "first": "each_of_your_turns" } }` (`"first": "each_turn"`: on any turn) |
417
424
  | "This ability costs {1} less to activate for each land you control." | `"cost_reduction": { "amount": {...} }` inside the `activated` ability |
418
425
 
419
426
  An activated ability without targets that adds mana is a *mana ability* (CR 605.1a):
@@ -681,6 +688,7 @@ Generic shapes (N, [quality] and [zone] stand for whatever the card says):
681
688
  | return a [quality] card from your graveyard to your hand; if you can't, [effect] | `{ "choose_cards": { "from": { "graveyard": "you" }, "for": spec, "put": "hand", "otherwise": [ … ] } }` |
682
689
  | target opponent reveals their hand; you choose a [quality] card from it; that player discards that card | `{ "choose_cards": { "from": { "hand": { "target": 0 } }, "for": spec, "reveal": "all", "put": "discard" } }` (a discard: discard triggers see it) |
683
690
  | look at a player's hand; you may choose a [quality] card; if you do, [effect] | `{ "choose_cards": { "from": { "hand": { "target": 0 } }, "look": true, "for": spec, "optional": true, "put": "exile", "then": [ … ] } }` |
691
+ | exile a card from an opponent's graveyard. Then search its owner's graveyard, hand, and library for any number of cards with that name and exile them. That player shuffles, then draws a card for each card exiled from their hand this way (Deadly Cover-Up) | effect 1 `{ "choose_cards": { "from": { "graveyard": "each_opponent" }, "for": "card", "put": "exile" } }`, then `{ "choose_cards": { "from": { "graveyard": P, "hand": P, "library": P }, "for": { "same_name_as": { "result": 1 } }, "count": "any", "look": true, "put": "exile" } }`, `{ "shuffle_library": { "to": P } }`, `{ "draw": { "amount": { "this_way": 2 }, "to": P } }` with P = `{ "controller_of": { "result": 1 } }` (several zones are one choice, CR 701.23a; a `choose_cards` amount is how many came from a hand) |
684
692
  | each player sacrifices a [quality] permanent of their choice | `{ "sacrifice_choice": { "filter": filter, "to": { "each": "player" } } }` (`"count": "any"`: any number) |
685
693
  | exile a target card in a graveyard; return a target card from your graveyard to your hand | `exile` / `return_to_hand` with a `graveyard_card` target |
686
694
  | its owner puts it on the top or bottom of their library, as they choose | `{ "put_in_library": { "to": { "target": 0 }, "position": "owner_choice" } }` |
@@ -1274,6 +1282,8 @@ its seed and decisions, and an exported game continues with the same results.
1274
1282
  | "Exile X artifact cards from your graveyard: … -X/-X" (CR 601.2b) | `{ "exile_from_graveyard": { "count": "X", "card": { "types": ["artifact"] } } }` in the `cost` (X is announced, at most the number of matching cards; also `discard`, `exile_from_hand`) and the amount `"x"` in effects |
1275
1283
  | "As this land enters, you may behold a Jace. If you don't, this land enters tapped." (CR 614.12) | `{ "enters_tapped_unless_behold": { "card": { "subtypes": ["jace"] } } }` (the `enter_choice` option `{type: "behold", object: id}`) |
1276
1284
  | "Gift a Treasure … Return target spell to its owner's hand. If the gift was promised, …" (CR 702.174) | `"gift"` in `abilities`; the gift as the spell's first effect, `{ "create_token": { "token": "Treasure", "to": "gift_recipient", "if": { "cast_with": "gift" } } }`, then the rest (on a permanent: an `enters` trigger with `"if": { "cast_with": "gift" }`) |
1285
+ | "Bargain (You may sacrifice an artifact, enchantment, or token as you cast this spell.) … If this spell was bargained, …" (CR 702.166) | `"bargain"` in `abilities` (announced with `choose_kicker`, the permanent chosen with `choose_cost`); `"if": { "cast_with": "bargain" }` on what the bargained spell does |
1286
+ | "… deals 2 damage to target creature. If a permanent dealt damage this way would die this turn, exile it instead." | `{ "deal_damage": { "amount": 2, "to": { "target": 0 }, "exile_if_dies": true } }`: only a permanent actually dealt damage (not one whose damage was prevented, CR 614.1a, 700.4) |
1277
1287
  | "You may discard your hand. If you do, draw …" / "… Draw X cards, where X is the number of cards discarded this way" | `{ "may": { "effects": [{ "discard": { "hand": true } }], "then": [ … ] } }`; X is `{ "this_way": n }` of that effect (n: its position in the list) |
1278
1288
  | "Noncreature spells you cast have improvise." (CR 702.126a) | `{ "spells_have": { "spells": { "not_types": ["creature"] }, "keywords": ["improvise"] } }` (convoke too) |
1279
1289
  | "Counter target spell unless its controller pays {2}. If …, {4} instead" | two `counter_unless_pays` with opposite `if` conditions (`cost` takes a list of costs too) |
@@ -181,7 +181,7 @@ Keyword breakdown: plot 7, craft 4, Case / suspect 3, leyline / opening hand 3,
181
181
  | Case of the Uneaten Feast | FAIL | Case mechanic (To solve / Solved, CR 719) not supported; also granting 'you may cast this card from your graveyard' to graveyard cards until end of turn |
182
182
  | Clay-Fired Bricks // Cosmium Kiln | FAIL | Craft with artifact (exile this and another artifact / artifact card from graveyard, return transformed) is not supported |
183
183
  | Corpses of the Lost | PARTIAL | The end-step trigger ('if you descended this turn, you may pay 1 life; if you do, return this to its owner's hand') is left out: no condition for descend (a permanent card put into your graveyard this turn). |
184
- | Deadly Cover-Up | FAIL | Collect evidence (CR 701.59) not supported; also searching graveyard/hand/library for cards with that name |
184
+ | Deadly Cover-Up | FAIL | Collect evidence (CR 701.59) not supported; also searching graveyard/hand/library for cards with that name (**done, Unreleased**: `choose_cards` from several zones with `library`, card spec `same_name_as: {"result": n}`) |
185
185
  | Doc Aurlock, Grizzled Genius | PARTIAL | 'Plotting cards from your hand costs {2} less' is left out: Enjine has no plot. |
186
186
  | Dust Animus | PARTIAL | Plot {1}{W} is left out (no plot in Enjine). 'Enters with two +1/+1 counters and a lifelink counter if you control five or more untapped lands' is an ETB trigger that checks the same condition, because enters_with_counters takes no condition. |
187
187
  | Forsaken Miner | PARTIAL | the 'Whenever you commit a crime, you may pay {B}. If you do, return this card from your graveyard to the battlefield' ability: Enjine has no commit-a-crime trigger |
@@ -206,7 +206,7 @@ Keyword breakdown: plot 7, craft 4, Case / suspect 3, leyline / opening hand 3,
206
206
  | The Enigma Jewel // Locus of Enlightenment | PARTIAL | Craft with four or more nonlands with activated abilities {8}{U} is left out (no craft), so it never transforms; the back face Locus of Enlightenment has none of its abilities (gaining the exiled cards' activated abilities, copying non-mana abilities) |
207
207
  | The Mind Stone | FAIL | Harness / ∞ (Infinity Stone) abilities that become active once harnessed are not supported |
208
208
  | The Soul Stone | PARTIAL | harness cost 'Exile a creature you control' is paid by sacrificing a creature instead (no exile-a-permanent cost); harnessing is modelled as the Stone gaining the ∞ upkeep trigger for as long as it stays on the battlefield, with the harness ability limited to once (re-harnessing does nothing on the real card) |
209
- | Torch the Tower | FAIL | Bargain (CR 702.166) not a primitive; and 'if a permanent dealt damage by this spell would die this turn, exile it' needs a replacement conditional on the damage actually being dealt (exile_if_dies on the target ignores prevented damage) |
209
+ | Torch the Tower | FAIL | Bargain (CR 702.166) not a primitive; and 'if a permanent dealt damage by this spell would die this turn, exile it' needs a replacement conditional on the damage actually being dealt (exile_if_dies on the target ignores prevented damage) (**done, Unreleased**: `bargain` and `deal_damage` `exile_if_dies`) |
210
210
  | Turn Inside Out | PARTIAL | 'When it dies this turn, manifest dread' is left out (no manifest / face-down 2/2 creatures) |
211
211
  | Unholy Annex // Ritual Chamber | PARTIAL | Room layout isn't supported: written as the Unholy Annex half plus a once-only sorcery-speed {3}{B}{B} 'unlock' ability for Ritual Chamber; Ritual Chamber can't be cast on its own and the mana value is always 3 |
212
212
  | Urgent Necropsy | PARTIAL | the additional cost 'collect evidence X, where X is the total mana value of the permanents this spell targets' (collect evidence has no primitive), so it is cheaper than printed |
@@ -253,7 +253,7 @@ Keyword breakdown: plot 7, craft 4, Case / suspect 3, leyline / opening hand 3,
253
253
  | Eluge, the Shoreless Sea | PARTIAL | The cost reduction only takes off generic mana ('{U} (or {1})' becomes {1} per flood land), so it does nothing for a spell with no generic cost. 'The first instant or sorcery each turn' is an amount that becomes 0 once you've cast an instant or sorcery this turn. (Written as reduce = flood lands x (1 - min(1, instants/sorceries you've cast this turn)), where the min is floor((n+99)/100), because divisors must be fixed integers.) Also, a flood land is an Island only while Eluge is on the battlefield (a static on Eluge), not for as long as the counter stays. |
254
254
  | Hearth Elemental // Stoke Genius | FAIL | cost reduction counts graveyard cards that 'have an Adventure': no card filter for Adventure cards |
255
255
  | Mistrise Village | FAIL | "The next spell you cast this turn can't be countered": no one-shot uncounterable effect for the next spell |
256
- | Momo, Friendly Flier | FAIL | cost reduction for only the first non-Lemur creature spell with flying cast each turn |
256
+ | Momo, Friendly Flier | FAIL | cost reduction for only the first non-Lemur creature spell with flying cast each turn (**done, Unreleased**: `cost_modifier` `first`, `keywords`, `not_subtypes`) |
257
257
  | Radagast of Rhosgobel | FAIL | 'The first creature spell you cast each turn costs {2} less and can be cast as though it had flash': cost_modifier has no first-spell-each-turn limit and there is no flash-granting permission for spells |
258
258
  | Sunderflock | FAIL | Cost reduction by "the greatest mana value among Elementals you control": no greatest-mana-value amount |
259
259
  | Temur Battlecrier | PARTIAL | the 'During your turn' limit: the cost reduction also applies to spells cast on the opponent's turn (cost_modifier takes no condition) |
@@ -317,8 +317,8 @@ Keyword breakdown: plot 7, craft 4, Case / suspect 3, leyline / opening hand 3,
317
317
  | Abzan Devotee | FAIL | mana ability with 'Activate only once each turn': mana abilities take no limit (only only_if) |
318
318
  | Barrels of Blasting Jelly | FAIL | mana ability with 'Activate only once each turn': mana abilities take no limit (only only_if) |
319
319
  | Carnelian Orb of Dragonkind | FAIL | mana-spend rider ('if that mana is spent on a Dragon creature spell, it gains haste') not supported |
320
- | Cavern of Souls | FAIL | mana that makes the spell it's spent on uncounterable (spend_only has no such rider) |
321
- | Gene Pollinator | FAIL | Mana ability with a chosen additional cost ('Tap an untapped permanent you control'): mana abilities can't have costs needing a choice |
320
+ | Cavern of Souls | FAIL | mana that makes the spell it's spent on uncounterable (spend_only has no such rider) (**done, Unreleased**: `spend_only` `"subtypes": "chosen"` and `cant_be_countered`) |
321
+ | Gene Pollinator | FAIL | Mana ability with a chosen additional cost ('Tap an untapped permanent you control'): mana abilities can't have costs needing a choice (**done, Unreleased**: `tap_permanents` in a mana ability, option `tap`) |
322
322
  | Groundchuck & Dirtbag | FAIL | mana trigger 'Whenever you tap a land for mana, add {G}' (no tapped-for-mana trigger) |
323
323
  | Lavaleaper | PARTIAL | 'Whenever a player taps a basic land for mana, that player adds one mana of any type that land produced' (no mana-tapping trigger in Enjine) |
324
324
  | Pit of Offerings | PARTIAL | '{T}: Add one mana of any of the exiled cards' colors': no mana ability whose colors come from the cards exiled with it (left out; the land only taps for {C}) |
@@ -326,7 +326,7 @@ Keyword breakdown: plot 7, craft 4, Case / suspect 3, leyline / opening hand 3,
326
326
  | Raphael, Ninja Destroyer | FAIL | mana that isn't lost as steps and phases end until end of turn (add_mana `until` supports only end_of_combat) |
327
327
  | Scene of the Crime | PARTIAL | '{T}, Tap an untapped creature you control: Add one mana of any color': a mana ability's cost can't need a choice (left out) |
328
328
  | Secluded Courtyard | PARTIAL | the chosen creature type: the colored mana can be spent on any creature spell or ability of a creature source, not only of the chosen type (card specs can't read a chosen creature type), so the 'choose a creature type' is dropped |
329
- | Springleaf Drum | FAIL | mana ability cost with a choice (tap an untapped creature) is rejected by validation |
329
+ | Springleaf Drum | FAIL | mana ability cost with a choice (tap an untapped creature) is rejected by validation (**done, Unreleased**: `tap_permanents` in a mana ability, option `tap`) |
330
330
  | The Last Agni Kai | FAIL | no effect for keeping unspent red mana as steps and phases end until end of turn |
331
331
 
332
332
  <a id="7"></a>
@@ -420,7 +420,7 @@ Keyword breakdown: plot 7, craft 4, Case / suspect 3, leyline / opening hand 3,
420
420
  | Gnashing of Teeth | FAIL | mode 2 'Creatures target player controls get -1/-1': selector `each` can't be scoped to a targeted player (same gap as Practiced Offense) |
421
421
  | Hex Magic | FAIL | 'Exile all the cards from your hand': no selector for every card in a hand (choose_cards 'any' is optional, not all) |
422
422
  | Lost in the Maze | PARTIAL | 'Tapped creatures you control have hexproof' is left out (a static ability can't filter on tapped yet); 'X target creatures' may only be creatures an opponent controls (the card can also tap your own creatures, which then get no stun counter): an effect can't put counters on only the targets you don't control |
423
- | Practiced Offense | FAIL | no selector for 'each creature target player controls' |
423
+ | Practiced Offense | FAIL | no selector for 'each creature target player controls' (**done, Unreleased**: `each` `controller: {"target": n}`) |
424
424
  | Settle the Wreckage | FAIL | "all attacking creatures target player controls": selector `each` can't be scoped to a targeted player |
425
425
  | Tishana's Tidebinder | FAIL | Selector for the source permanent of a countered (targeted) ability, to make it lose all abilities, does not exist |
426
426
  | Turtle Van | FAIL | no target filter for 'creature that crewed it this turn' (and doubling the +1/+1 counters on it) |
@@ -520,7 +520,7 @@ Keyword breakdown: plot 7, craft 4, Case / suspect 3, leyline / opening hand 3,
520
520
  |---|---|---|
521
521
  | Ancestral Anger | PARTIAL | X counts only the base 1: no amount for 'the number of cards named Ancestral Anger in your graveyard' (graveyard filters take no name), so the target always gets +1/+0 |
522
522
  | Ancient Vendetta | FAIL | Choose a card name; search an opponent's graveyard, hand and library for cards with that name |
523
- | Deadly Cover-Up | FAIL | Collect evidence (CR 701.59) not supported; also searching graveyard/hand/library for cards with that name |
523
+ | Deadly Cover-Up | FAIL | Collect evidence (CR 701.59) not supported; also searching graveyard/hand/library for cards with that name (**done, Unreleased**: `choose_cards` from several zones with `library`, card spec `same_name_as: {"result": n}`) |
524
524
  | Key to the Side-Door | FAIL | cost 'Discard a legendary card with the same name as a legendary permanent you control' (card spec can't compare names with permanents you control) |
525
525
  | Maelstrom Pulse | PARTIAL | 'and all other permanents with the same name as that permanent': no same-name filter; only the target is destroyed |
526
526
  | Petrified Hamlet | FAIL | Choose a land card name on an ETB trigger; grant mana ability / ban activation for sources with the chosen name (no name filter for chosen names) |
@@ -106,6 +106,16 @@ Rules: CR 603.2d, CR 119.9, CR 607.2d
106
106
  }
107
107
  ```
108
108
 
109
+ ## bargain
110
+
111
+ Bargain: as you cast this spell you may sacrifice an artifact, enchantment or token (announced with the `choose_kicker` decision, the permanent chosen with `choose_cost`; the spell isn't kicked). `{"cast_with": "bargain"}` holds if it was bargained.
112
+
113
+ Rules: CR 702.166a, CR 702.166b, CR 702.166c, CR 601.2b, CR 601.2h, CR 701.21a
114
+
115
+ ```json
116
+ "bargain"
117
+ ```
118
+
109
119
  ## beam_me_up
110
120
 
111
121
  You may cast this instant or sorcery card from your graveyard for `cost` plus returning a creature you control to its owner's hand, instead of its mana cost. If you do, it's exiled whenever it would leave the stack. Offered as a cast option with `via: "beam:<ref>"`.
@@ -436,9 +446,9 @@ Rules: CR 717.2a, CR 717.2b, CR 717.2d, CR 717.3, CR 602.5d
436
446
 
437
447
  ## cost_modifier
438
448
 
439
- While on the battlefield: spells cast by `caster` (you, opponent or any; default you) whose card types match `spells` ({"any_of": [types], "not": [types]}, default all spells; `subtypes`, `colors` and `name` narrow it: "Dragon spells", "red spells"; `"subtypes": "chosen"`: of the type chosen for this permanent, `"name": "chosen"`: with the name its source chose) cost `reduce` less or `increase` more generic mana. `from` / `not_from`: only spells cast from (not from) that zone (hand | graveyard | exile | library | outside).
449
+ While on the battlefield: spells cast by `caster` (you, opponent or any; default you) whose card types match `spells` ({"any_of": [types], "not": [types]}, default all spells; `subtypes`, `colors` and `name` narrow it: "Dragon spells", "red spells"; `"subtypes": "chosen"`: of the type chosen for this permanent, `"name": "chosen"`: with the name its source chose; `keywords` / `not_subtypes`: "non-Lemur creature spells with flying") cost `reduce` less or `increase` more generic mana. `from` / `not_from`: only spells cast from (not from) that zone (hand | graveyard | exile | library | outside). `first`: only the first matching spell its caster casts `each_turn` or `each_of_your_turns` (spells cast before this permanent was there count too).
440
450
 
441
- Rules: CR 601.2f, CR 118.7a, CR 604.1, CR 601.2a
451
+ Rules: CR 601.2f, CR 118.7a, CR 604.1, CR 601.2a, CR 601.2i
442
452
 
443
453
  | Parameter | Description |
444
454
  | --- | --- |
@@ -448,6 +458,7 @@ Rules: CR 601.2f, CR 118.7a, CR 604.1, CR 601.2a
448
458
  | `increase` | amount |
449
459
  | `from` | zone |
450
460
  | `not_from` | zone |
461
+ | `first` | each_turn | each_of_your_turns |
451
462
 
452
463
  ```json
453
464
  {
@@ -1267,9 +1278,9 @@ Rules: CR 606.3, CR 606.4, CR 606.5, CR 602.2b
1267
1278
 
1268
1279
  ## mana
1269
1280
 
1270
- An activated mana ability: pay the cost, add the mana to your mana pool immediately. It does not use the stack and can be activated whenever you have priority. `produce`: the fixed mana (`amount` times). Or `color`: `amount` mana (default 1) of one color you choose as you activate it (`"any_one"`) or in any combination of colors (`"any"`); `colors` limits the choice. `"chosen"`: of the color chosen as this entered (choose_color). `spend_only` restricts how the mana can be spent. `only_if`: "Activate only if ...". `limit: "once_each_turn"`: "Activate only once each turn." `add_counters`: it also puts counters on its own source ("Add {C}. Put a point counter on this").
1281
+ An activated mana ability: pay the cost, add the mana to your mana pool immediately. It does not use the stack and can be activated whenever you have priority. `produce`: the fixed mana (`amount` times). Or `color`: `amount` mana (default 1) of one color you choose as you activate it (`"any_one"`) or in any combination of colors (`"any"`); `colors` limits the choice. `"chosen"`: of the color chosen as this entered (choose_color). `spend_only` restricts how the mana can be spent (a spec of `"subtypes": "chosen"`: the creature type chosen as this entered; `"cant_be_countered": true`: a spell cast with it can't be countered). `only_if`: "Activate only if ...". `limit: "once_each_turn"`: "Activate only once each turn." `add_counters`: it also puts counters on its own source ("Add {C}. Put a point counter on this"). A `tap_permanents` cost (count 1) taps another permanent you choose as you activate it ("{T}, Tap an untapped creature you control"): each activation option names it (`tap`).
1271
1282
 
1272
- Rules: CR 605.1a, CR 605.3a, CR 605.3b, CR 106.1a, CR 106.4, CR 106.6, CR 607.2d, CR 602.5b, CR 122.1
1283
+ Rules: CR 605.1a, CR 605.3a, CR 605.3b, CR 106.1a, CR 106.4, CR 106.6, CR 607.2d, CR 602.5b, CR 122.1, CR 101.2, CR 602.2b, CR 302.6
1273
1284
 
1274
1285
  | Parameter | Description |
1275
1286
  | --- | --- |
@@ -1278,7 +1289,7 @@ Rules: CR 605.1a, CR 605.3a, CR 605.3b, CR 106.1a, CR 106.4, CR 106.6, CR 607.2d
1278
1289
  | `amount` | amount (default 1; with produce: how many times) |
1279
1290
  | `color` | any_one | any | chosen |
1280
1291
  | `colors` | list of colors to choose from (default all five) |
1281
- | `spend_only` | {"spells": card spec, "abilities": card spec, "from" | "not_from": zone} |
1292
+ | `spend_only` | {"spells": card spec, "abilities": card spec, "from" | "not_from": zone, "cant_be_countered": true} |
1282
1293
  | `only_if` | condition: it can be activated only while it holds (CR 602.5b) |
1283
1294
  | `limit` | "once_each_turn" (CR 602.5b) |
1284
1295
  | `add_counters` | {"counter": name, "amount": integer (default 1)}: put on this permanent |
@@ -103,7 +103,7 @@ Untap step: `{type: "untap", object: id}` or `{type: "keep_tapped", object: id}`
103
103
  ## Priority actions
104
104
 
105
105
  - `activate` — `{type: "activate", object: id, ability: ref}` — start activating an ability (CR 602.2), including planeswalker loyalty abilities (CR 606) and abilities of cards in your hand (cycling, CR 702.29).
106
- - `activate_mana` — `{type: "activate_mana", object: id, ability: ref}` — activate a mana ability; it resolves immediately (CR 605.3). `mana: "{G}{G}"` names the mana when it is chosen as the ability is activated.
106
+ - `activate_mana` — `{type: "activate_mana", object: id, ability: ref}` — activate a mana ability; it resolves immediately (CR 605.3). `mana: "{G}{G}"` names the mana when it is chosen as the ability is activated; `tap: id` names the permanent tapped for a "tap an untapped creature you control" cost (CR 602.2b).
107
107
  - `cast` — `{type: "cast", object: id}` — start casting a card from your hand (CR 601.2). `{type: "cast", object: id, via: method}` casts a card from another zone (graveyard, exile, the top of your library) by the permission or alternative cost `via` names, e.g. beam me up (CR 601.3, 702.196). In a Commander game `via: "command"` casts your commander from the command zone, its cost including the commander tax (CR 903.8). A card outside the game is named `"outside:<card id>"` (CR 400.11b). `{type: "cast", object: id, face: 1}` casts another face of a card in your hand: a modal double-faced card's back face, an Adventure or an Omen (CR 712.8b, 716.3, 721.3). Offered only when timing allows, targets exist and enough mana is available.
108
108
  - `pass` — `{type: "pass"}` — pass priority. When all players pass in succession with an empty stack, the step ends (CR 117.4).
109
109
  - `play_land` — `{type: "play_land", object: id}` — special action: your main phase, empty stack, one land per turn plus additional land plays (CR 305.1, 305.2). With `via`: a land from another zone that an effect lets you play. With `face: 1`: a modal double-faced card played with its land back face up (CR 712.9).
@@ -509,13 +509,13 @@ 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; "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.
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} / {"library": selector}, or several of them ("search its owner's graveyard, hand, and library": one choice among them all). `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. Its amount ({"this_way": n}) is how many of the cards came from a hand ("draws a card for each card exiled from their hand this way").
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, CR 608.2d
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, CR 701.23a, CR 701.23b
515
515
 
516
516
  | Parameter | Description |
517
517
  | --- | --- |
518
- | `from` | selector or {"hand"|"graveyard": player selector} |
518
+ | `from` | selector or {"hand"|"graveyard"|"library": player selector, ...} |
519
519
  | `for` | card spec |
520
520
  | `count` | integer, "any" or "all" |
521
521
  | `optional` | boolean |
@@ -898,14 +898,15 @@ Rules: CR 615.12, CR 611.2a
898
898
 
899
899
  ## deal_damage
900
900
 
901
- Deal `amount` damage to each referenced creature, planeswalker or player. Damage to a player causes life loss; to a planeswalker removes loyalty counters; to a creature is marked until cleanup. {"this_way": n} naming it is the excess damage it dealt (beyond lethal damage, or a planeswalker's loyalty).
901
+ Deal `amount` damage to each referenced creature, planeswalker or player. Damage to a player causes life loss; to a planeswalker removes loyalty counters; to a creature is marked until cleanup. {"this_way": n} naming it is the excess damage it dealt (beyond lethal damage, or a planeswalker's loyalty). `exile_if_dies: true`: a permanent dealt damage this way that would die this turn is exiled instead (not one whose damage was prevented).
902
902
 
903
- Rules: CR 120.3a, CR 120.3c, CR 120.3e, CR 120.6, CR 120.4a, CR 120.10
903
+ Rules: CR 120.3a, CR 120.3c, CR 120.3e, CR 120.6, CR 120.4a, CR 120.10, CR 614.1a, CR 700.4
904
904
 
905
905
  | Parameter | Description |
906
906
  | --- | --- |
907
907
  | `amount` | integer |
908
908
  | `to` | selector |
909
+ | `exile_if_dies` | true: "if a permanent dealt damage this way would die this turn, exile it instead" |
909
910
 
910
911
  ```json
911
912
  {
@@ -7,7 +7,8 @@ module Enjine
7
7
  class ActivateManaAbility
8
8
  def self.doc
9
9
  '`{type: "activate_mana", object: id, ability: ref}` — activate a mana ability; it resolves immediately ' \
10
- '(CR 605.3). `mana: "{G}{G}"` names the mana when it is chosen as the ability is activated.'
10
+ '(CR 605.3). `mana: "{G}{G}"` names the mana when it is chosen as the ability is activated; `tap: id` names ' \
11
+ 'the permanent tapped for a "tap an untapped creature you control" cost (CR 602.2b).'
11
12
  end
12
13
 
13
14
  def self.options(engine, index)
@@ -15,7 +16,7 @@ module Enjine
15
16
  end
16
17
 
17
18
  def self.perform(engine, index, option)
18
- engine.activate_mana_ability!(index, option[:object], option[:ability], option[:mana])
19
+ engine.activate_mana_ability!(index, option[:object], option[:ability], option[:mana], option[:tap])
19
20
  engine.action_taken!(index)
20
21
  end
21
22
  end
@@ -159,7 +159,8 @@ module Enjine
159
159
  when "activate" then "Activate #{name_of(opt[:object])}: #{ability_text(opt[:object], opt[:ability])}"
160
160
  when "special_action" then "#{ability_text(opt[:object], opt[:ability])}: #{name_of(opt[:object])} (special action)"
161
161
  when "activate_mana"
162
- "Tap #{name_of(opt[:object])} for #{opt[:mana] || "mana"} (#{ability_text(opt[:object], opt[:ability])})"
162
+ "Tap #{name_of(opt[:object])}#{" and #{name_of(opt[:tap])}" if opt[:tap]} for #{opt[:mana] || "mana"} " \
163
+ "(#{ability_text(opt[:object], opt[:ability])})"
163
164
  when "pay_mana"
164
165
  "Pay {#{opt[:mana]}} from mana pool#{" (restricted)" if opt[:restricted]}#{" (made by an artifact)" if opt[:from]}"
165
166
  when "target" then "Target #{name_of(opt[:target])}"
@@ -182,7 +182,7 @@ module Enjine
182
182
  when "pay_mana" then engine.pay_mana!(option[:mana], option[:restricted], option[:from])
183
183
  when "convoke", "improvise" then engine.convoke!(option[:object], option[:type]) # CR 702.51a, 702.126a
184
184
  when "waterbend" then engine.waterbend!(option[:object]) # CR 701.67a
185
- else engine.tap_for_payment!(option[:object], option[:ability], option[:mana])
185
+ else engine.tap_for_payment!(option[:object], option[:ability], option[:mana], option[:tap])
186
186
  end
187
187
  end
188
188
  end
@@ -278,6 +278,7 @@ module Enjine
278
278
  obj.modes = ctx["modes"].dup unless ctx["modes"].empty?
279
279
  obj.mana_spent = ctx["spent"].dup if ctx["spent"]
280
280
  obj.memory["mana_from"] = Snapshot.deep_copy(ctx["spent_from"]) if ctx["spent_from"] # the sources (ManaSources)
281
+ obj.memory["cant_be_countered"] = true if ctx["uncounterable"] # mana with that rider was spent (CR 106.6, 101.2)
281
282
  record_announcements!(obj, ctx) # kicked (CR 702.33d), division (CR 601.2d), modes chosen before
282
283
  record_cast_choices!(obj, ctx) # cost choices; facing a dilemma (CR 700.17)
283
284
  waterbent!(ctx) # CR 701.67c (Engine::Waterbending)
@@ -121,6 +121,7 @@ module Enjine
121
121
  frame["remaining"] = after_paying(frame["remaining"], slot)
122
122
  (frame["spent"] ||= []) << type # what was spent matters later (sunburst, CR 702.44a; 609.4b: its real type)
123
123
  (frame["spent_from"] ||= []) << entry["from"] if entry&.key?("from") # "if mana from a Treasure was spent"
124
+ frame["uncounterable"] = true if frame["kind"] == "spell" && Mechanics::SpendOnly.uncounterable?(entry) # CR 106.6, 101.2
124
125
  (frame["refund"] ||= []) << { "mana" => type, (restricted ? "restricted" : "source") => entry }.compact # #refund_payment!
125
126
  emit Events::ManaPaid.new(player: name(frame["player"]), mana: "{#{type}}", object: frame["object"])
126
127
  ask!(nil)
@@ -168,10 +169,11 @@ module Enjine
168
169
  purpose = payment_purpose(frame)
169
170
  sources = all_mana_sources(frame["player"]).reject do |id, ref|
170
171
  spend_only = chars(id).ability(ref).spend_only
171
- reserved_for_cost?(frame, id, ref) || (spend_only && !spend_only.allows?(self, purpose))
172
+ reserved_for_cost?(frame, id, ref) || (spend_only && !spend_only.bound(self, id).allows?(self, purpose))
172
173
  end
173
174
  mana_activation_options(sources).select do |option|
174
175
  id = option[:object]
176
+ next false if option[:tap] && reserved_helper?(frame, option[:tap]) # Engine::ManaHelpers
175
177
  next !frame["irreversible"] && !irreversible_mana_ability?(id, option[:ability]) if chars(id).ability(option[:ability]).mana_cost
176
178
 
177
179
  (!frame["irreversible"] && !irreversible_mana_ability?(id, option[:ability])) ||
@@ -182,6 +184,9 @@ module Enjine
182
184
  # A mana ability that can't be undone (Abilities::ManaAbility#irreversible?).
183
185
  def irreversible_mana_ability?(id, ref) = chars(id).ability(ref).irreversible?
184
186
 
187
+ # A permanent the spell or ability being paid for still needs, which a mana ability can't tap for its cost.
188
+ def reserved_helper?(frame, id) = id == payment_excluded_source(frame) || payment_reserved(frame).include?(id)
189
+
185
190
  def reserved_for_cost?(frame, id, ref)
186
191
  return true if id == payment_excluded_source(frame)
187
192
 
@@ -206,11 +211,11 @@ module Enjine
206
211
  pool = player(frame["player"]).mana_pool.dup
207
212
  rest = player(frame["player"]).restricted_mana
208
213
  if ability.spend_only
209
- rest += produced.map { { "mana" => it.to_s, "spend_only" => ability.spend_only.data } }
214
+ rest += produced.map { { "mana" => it.to_s, "spend_only" => ability.spend_only.bound(self, id).data } }
210
215
  else
211
216
  produced.each { pool[it] += 1 }
212
217
  end
213
- used = [id, tapped_granter(option[:ability], ability)].compact
218
+ used = [id, tapped_granter(option[:ability], ability), option[:tap]].compact
214
219
  later = units_after_activating(id, option[:ability], ability) # ManaSources: it may be activated again
215
220
  payable_with?(frame, remaining_cost(frame["remaining"]), pool, payment_reserved(frame) + used, restricted: rest, extra: later)
216
221
  end
@@ -218,14 +223,14 @@ module Enjine
218
223
  # CR 605.3: activating a mana ability while paying. One whose costs include more than {T} (a
219
224
  # sacrifice, life, a discard) can't be undone, so the payment stops being cancellable. Tapping the
220
225
  # permanent that granted it can (CR 734.1: it is untapped with the source).
221
- def tap_for_payment!(id, ability_ref, mana = nil)
226
+ def tap_for_payment!(id, ability_ref, mana = nil, helper = nil)
222
227
  frame = payment
223
228
  frame["irreversible"] = true if irreversible_mana_ability?(id, ability_ref)
224
229
  granter = tapped_granter(ability_ref, chars(id).ability(ability_ref))
225
- activate_mana_ability!(frame["player"], id, ability_ref, mana)
226
- frame["tapped"] << id
227
- frame["tapped"] << granter if granter
228
- (frame["mana_tapped"] ||= []).push(*[id, granter].compact) # kept tapped by #refund_payment!
230
+ activate_mana_ability!(frame["player"], id, ability_ref, mana, helper)
231
+ tapped = [id, granter, helper].compact # the helper tapped for its cost (Engine::ManaHelpers)
232
+ frame["tapped"].push(*tapped)
233
+ (frame["mana_tapped"] ||= []).push(*tapped) # kept tapped by #refund_payment!
229
234
  ask!(nil)
230
235
  end
231
236
 
@@ -292,13 +297,14 @@ module Enjine
292
297
  # ---- countering (CR 701.6) ----------------------------------------------------------------
293
298
 
294
299
  # CR 701.6a: a countered spell goes to its owner's graveyard; a countered ability ceases to exist.
295
- # "This spell can't be countered" and "Spells [and abilities] you control can't be countered" win (CR 101.2).
300
+ # "This spell can't be countered", "Spells [and abilities] you control can't be countered" and a spell cast with mana
301
+ # whose rider says so (memory "cant_be_countered", CR 106.6) win (CR 101.2).
296
302
  # `exile`: "If that spell is countered this way, exile it instead of putting it into its owner's graveyard"
297
303
  # (CR 614.1a). Returns whether it was countered.
298
304
  def counter!(id, exile: false)
299
305
  obj = object(id)
300
306
  return false if obj.ability? && player_rule?(obj.controller, "abilities_cant_be_countered")
301
- return false if !obj.ability? && (chars(obj).keyword?(:cant_be_countered) ||
307
+ return false if !obj.ability? && (chars(obj).keyword?(:cant_be_countered) || obj.memory["cant_be_countered"] ||
302
308
  player_rule?(obj.controller, "spells_cant_be_countered", obj))
303
309
 
304
310
  if obj.ability?
@@ -12,6 +12,7 @@ module Enjine
12
12
 
13
13
  data = propose("damage", { "source" => source, "target" => ref, "amount" => amount, "combat" => combat }).data
14
14
  dealt = deal_proposed_damage!(source, data, combat, lifelink)
15
+ yield data["target"] if block_given? && dealt.positive? # who was dealt it (redirected, CR 614.9)
15
16
  run_follow_ups!(data) # the rest of a prevention effect (CR 615.5)
16
17
  dealt
17
18
  end