enjine 0.6.1 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +36 -1
- data/SUPPORTED.md +8 -8
- data/docs/guides/api.md +12 -0
- data/docs/guides/card-data-format.md +17 -4
- data/docs/reference/abilities.md +5 -4
- data/docs/reference/costs.md +2 -2
- data/docs/reference/effects.md +12 -10
- data/lib/enjine/engine/casting/casting.rb +13 -6
- data/lib/enjine/engine/casting/payment.rb +6 -7
- data/lib/enjine/engine/copies.rb +20 -6
- data/lib/enjine/engine/mana_sources.rb +26 -2
- data/lib/enjine/engine/options_memo.rb +4 -1
- data/lib/enjine/engine/state_based_actions.rb +12 -1
- data/lib/enjine/engine/triggers.rb +2 -2
- data/lib/enjine/game.rb +6 -3
- data/lib/enjine/mana.rb +5 -4
- data/lib/enjine/mechanics/abilities/entering_copy.rb +1 -1
- data/lib/enjine/mechanics/abilities/mana_ability.rb +48 -6
- data/lib/enjine/mechanics/copy_except.rb +23 -3
- data/lib/enjine/mechanics/costs/remove_counters.rb +12 -2
- data/lib/enjine/mechanics/costs/sacrifice.rb +7 -0
- data/lib/enjine/mechanics/effects/copy.rb +1 -1
- data/lib/enjine/mechanics/effects/delayed_triggers.rb +9 -2
- data/lib/enjine/mechanics/effects/pay.rb +1 -1
- data/lib/enjine/mechanics/effects/scry_and_surveil.rb +32 -6
- data/lib/enjine/mechanics/filters/base.rb +27 -4
- data/lib/enjine/setup.rb +12 -3
- data/lib/enjine/snapshot/player_checks.rb +6 -0
- data/lib/enjine/snapshot.rb +2 -0
- data/lib/enjine/state.rb +13 -4
- data/lib/enjine/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 853cd6e6c1fa6e8ea3038049debaa947f18b6c948c595d3e546604c8a3dbc865
|
|
4
|
+
data.tar.gz: 87ae58e7c4561df98afa3a6924214e0c3bbfd1fd30fa2242be66656fdac9d019
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c39a7f897e7c56df2a8939af69de53453751711520f005ded7f5c94d669d08e1bddc5a51c37b35a99c02316f64feb0ced04e6dfbbea74f84ceab4d2b8852af4a
|
|
7
|
+
data.tar.gz: 698779f724842481530bd5f474e3fbaa316c3cbdcef0aceb0e58e59b1a88c975021fa220660e89f1c1f8768a5fd4ab33aa083c0c01a0ab08edcf668095e9954f
|
data/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,39 @@ change the public API; the stable surface is described in
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [0.6.3] - 2026-11-29
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
- `Setup.new(..., permanent_limit: n)`: an opt-in guard for simulations, not a rule of the game. Once more than `n`
|
|
15
|
+
permanents are on the battlefield the game is a draw with the reason `permanent_limit`, checked with state-based
|
|
16
|
+
actions. Off by default; kept in snapshots.
|
|
17
|
+
|
|
18
|
+
## [0.6.2] - 2026-11-29
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
- Filters take `color_count` bounds (integers 0-5): "monocolored" `{"color_count": {"equal": 1}}`, "multicolored"
|
|
22
|
+
`{"at_least": 2}`, "colorless" `{"equal": 0}`, for targets, `spell` filters and `each` selectors (CR 105.2a-c).
|
|
23
|
+
- Mana abilities may remove counters from their own source as a cost (`{"remove_counters": {"count": 1, "counter":
|
|
24
|
+
"charge", "self": true}}`: no choice, so CR 605.3a holds; without {T} it can be activated once per counter and
|
|
25
|
+
affordability counts each) and put counters on it (`"add_counters": {"counter": "point", "amount": 1}`, CR 605.1a).
|
|
26
|
+
Either makes a payment that used it irreversible.
|
|
27
|
+
- Copy exceptions take `replace` (`["types", "subtypes", "supertypes"]`): the listed values set the copied ones instead
|
|
28
|
+
of adding to them ("except it's a 6/6 Dinosaur creature", CR 707.9b, 205.1a); without it they still add (CR 205.1b).
|
|
29
|
+
A later copy effect's `replace` wins over earlier additions.
|
|
30
|
+
- Colorless hybrid mana symbols `{C/W}`, `{C/U}`, `{C/B}`, `{C/R}`, `{C/G}` in mana costs: paid with colorless mana or
|
|
31
|
+
the color, the card is that color, mana value 1 per symbol (CR 107.4, 107.4e, 202.2d, 202.3f).
|
|
32
|
+
- `scry` and `surveil` take `to`: each named player does it with their own library, in APNAP order ("target player
|
|
33
|
+
scries X", CR 701.22a, 701.25a, 101.4). It was accepted and ignored before.
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
- An activated ability costing "remove N counters from this" (`remove_counters` with `self: true`) and "sacrifice
|
|
37
|
+
this" crashed (KeyError) when the sacrifice came first in the list: costs that take the source away (`sacrifice`,
|
|
38
|
+
`exile_self`) are now paid after the others, in activated abilities, `pay` effects and mana abilities (CR 601.2h,
|
|
39
|
+
602.2b). A sacrificed source's remembered counters are those it had as it left.
|
|
40
|
+
- A delayed or reflexive triggered ability created by a spell or ability with X read X as 0; it now has the X of what
|
|
41
|
+
created it (CR 107.3n, 603.12).
|
|
42
|
+
- `scry` and `surveil` ignored their `if` condition (CR 608.2c).
|
|
43
|
+
|
|
11
44
|
## [0.6.1] - 2026-11-29
|
|
12
45
|
|
|
13
46
|
### Fixed
|
|
@@ -316,7 +349,9 @@ Includes 0.4.0, which was tagged but never published to RubyGems.
|
|
|
316
349
|
- `enjine` CLI: hot-seat and random play, `--validate`, `--verify`,
|
|
317
350
|
`--random-deck`, save and load.
|
|
318
351
|
|
|
319
|
-
[Unreleased]: https://github.com/thisiscetin/enjine/compare/v0.6.
|
|
352
|
+
[Unreleased]: https://github.com/thisiscetin/enjine/compare/v0.6.3...HEAD
|
|
353
|
+
[0.6.3]: https://github.com/thisiscetin/enjine/compare/v0.6.2...v0.6.3
|
|
354
|
+
[0.6.2]: https://github.com/thisiscetin/enjine/compare/v0.6.1...v0.6.2
|
|
320
355
|
[0.6.1]: https://github.com/thisiscetin/enjine/compare/v0.6.0...v0.6.1
|
|
321
356
|
[0.6.0]: https://github.com/thisiscetin/enjine/compare/v0.5.0...v0.6.0
|
|
322
357
|
[0.5.0]: https://github.com/thisiscetin/enjine/compare/v0.4.1...v0.5.0
|
data/SUPPORTED.md
CHANGED
|
@@ -132,7 +132,7 @@ Rules version: Comprehensive Rules effective 2026-11-06.
|
|
|
132
132
|
| [`double_tokens`](docs/reference/abilities.md#double_tokens) | 614.1a, 614.5, 111.1, 616.1 | While this permanent is on the battlefield, if tokens would be created under its controller's control, twice that many of those tokens are created instead. Several apply one after another (two make four times as many). |
|
|
133
133
|
| [`draw_replacement`](docs/reference/abilities.md#draw_replacement) | 614.11, 614.11a, 614.5, 121.2, 616.1 | While this permanent is on the battlefield, each time its controller would draw a card, they draw `amount` cards instead (even with an empty library). The draws it makes aren't replaced by it again, but another such effect applies to each of them. |
|
|
134
134
|
| [`enchant`](docs/reference/abilities.md#enchant) | 702.5a, 115.1b, 303.4a | The Aura's enchant ability: a target filter for what its spell targets and what the Aura may be attached to, e.g. "creature" or {"permanent": {"any_of": ["artifact", "creature"]}}. Only Auras have it. |
|
|
135
|
-
| [`enter_as_copy`](docs/reference/abilities.md#enter_as_copy) | 707.5, 707.9b, 614.1c, 614.12 | As this permanent enters, its controller may choose a permanent on the battlefield matching `of`; it enters as a copy of that permanent (its copiable values, with the `except` modifications) and its enter abilities trigger. `with_counters: true`: it also enters with the counters the copied permanent has. Choosing none: it enters as itself. |
|
|
135
|
+
| [`enter_as_copy`](docs/reference/abilities.md#enter_as_copy) | 707.5, 707.9b, 205.1a, 614.1c, 614.12 | As this permanent enters, its controller may choose a permanent on the battlefield matching `of`; it enters as a copy of that permanent (its copiable values, with the `except` modifications) and its enter abilities trigger. `with_counters: true`: it also enters with the counters the copied permanent has. Choosing none: it enters as itself. |
|
|
136
136
|
| [`enters_attacking`](docs/reference/abilities.md#enters_attacking) | 614.1c, 508.4, 506.4 | While this permanent's controller controls an attacking creature, permanents matching `affects` enter the battlefield tapped and attacking (the defending player). They never "attacked", so attack triggers don't see them. |
|
|
137
137
|
| [`enters_prepared`](docs/reference/abilities.md#enters_prepared) | 723.3a, 614.1c | This permanent enters the battlefield prepared (it needs a prepare spell, see `layout: "prepare"`). |
|
|
138
138
|
| [`enters_tapped`](docs/reference/abilities.md#enters_tapped) | 614.1c, 614.12 | This permanent enters the battlefield tapped (a self-replacement effect). |
|
|
@@ -159,7 +159,7 @@ Rules version: Comprehensive Rules effective 2026-11-06.
|
|
|
159
159
|
| [`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
160
|
| [`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
161
|
| [`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 | 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." |
|
|
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
163
|
| [`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
164
|
| [`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
165
|
| [`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>"`. |
|
|
@@ -261,7 +261,7 @@ Rules version: Comprehensive Rules effective 2026-11-06.
|
|
|
261
261
|
| [`mana`](docs/reference/costs.md#mana) | 601.2g, 601.2h, 602.2b | Pay mana as part of an activation. Paid during the activation by spending mana from your pool, tapping sources one at a time. |
|
|
262
262
|
| [`one_of`](docs/reference/costs.md#one_of) | 118.3, 601.2b, 601.2f, 602.2b, 118.12 | Pay one of the listed costs (two or more), chosen as the spell or ability is cast or activated (the `choose_cost_option` decision) or, for `pay` and ward, as it is paid. A cost that can't be paid can't be chosen. |
|
|
263
263
|
| [`pay_life`](docs/reference/costs.md#pay_life) | 119.4, 119.4b, 118.3b, 601.2b, 107.3a, 702.21a | Pay that much life (you lose it). Only possible while your life total is at least that much. `"X"` pays the X announced for the spell or ability (at most your life total); it may be a spell's additional cost. An amount (e.g. {"power": "self"}, "pay life equal to its power") is computed as the cost is paid. |
|
|
264
|
-
| [`remove_counters`](docs/reference/costs.md#remove_counters) | 602.2b, 601.2h, 118.3, 122.1 | Remove `count` counters (of kind `counter`, or any kind) from among permanents you control matching `filter` (default creature), one counter per choice. Removed as it becomes cast. `self: true`: only from this permanent ("Remove two counters from Ghost-Spider"). |
|
|
264
|
+
| [`remove_counters`](docs/reference/costs.md#remove_counters) | 602.2b, 601.2h, 118.3, 122.1, 605.3a | Remove `count` counters (of kind `counter`, or any kind) from among permanents you control matching `filter` (default creature), one counter per choice. Removed as it becomes cast. `self: true`: only from this permanent ("Remove two counters from Ghost-Spider"). With `self: true` and a `counter` kind it needs no choice, so a mana ability may have it ("Remove a charge counter from this: Add one mana of any color"). |
|
|
265
265
|
| [`sacrifice`](docs/reference/costs.md#sacrifice) | 701.21a, 602.2b, 118.3 | Sacrifice the permanent the ability belongs to (it goes to its owner's graveyard). |
|
|
266
266
|
| [`sacrifice_permanent`](docs/reference/costs.md#sacrifice_permanent) | 701.21a, 601.2h, 602.2b, 118.3, 608.2h | Sacrifice `count` permanents you control matching `filter` (`other: true`: not the source). Chosen while casting or activating, sacrificed as it becomes cast; the sacrificed permanent's last known types and subtypes are remembered (condition `sacrificed`), and its power, toughness and mana value (amount `sacrificed`). |
|
|
267
267
|
| [`tap`](docs/reference/costs.md#tap) | 107.5, 602.5a, 602.2b, 607.1a, 302.6 | {T} — tap the permanent the ability belongs to. Requires it to be untapped. `{"tap": "granter"}` instead taps the permanent whose static ability granted this ability ("Tap Fishing Pole"; not {T}, so summoning sickness doesn't matter). |
|
|
@@ -308,11 +308,11 @@ Rules version: Comprehensive Rules effective 2026-11-06.
|
|
|
308
308
|
| [`counter_unless_pays`](docs/reference/effects.md#counter_unless_pays) | 701.6a, 118.12a, 605.3a, 701.67a | Counter each referenced spell or ability unless its controller pays `mana` (or `waterbend`s that cost, CR 701.67a, or pays the list of costs `cost`) as this resolves (they choose, and pay like any cost; mana abilities allowed). |
|
|
309
309
|
| [`create_emblem`](docs/reference/effects.md#create_emblem) | 114.1, 114.2, 114.3, 114.4, 113.6p | Each referenced player (default you) gets an emblem with the `abilities` (triggered, static or player_rule abilities). An emblem is in the command zone for the rest of the game; its abilities work there, and "this emblem" is the source of what they do. |
|
|
310
310
|
| [`create_token`](docs/reference/effects.md#create_token) | 111.1, 111.10, 701.7a, 704.5d, 508.4, 506.3b, 707.2 | Create `amount` tokens under the referenced player's control (default: you). `token` is a predefined token name (Treasure, Clue, Food) or an inline card definition. `tapped: true` creates them tapped; `attacking: true` attacking (only for the attacking player during combat, CR 506.3b); when the defending player controls a planeswalker, the controller chooses for each token whether it attacks that player or one of their planeswalkers (CR 508.4). `size` (an amount, fixed as the effect starts) makes them N/N ("an X/X Spirit token, where X is ..."; part of their copiable values). |
|
|
311
|
-
| [`create_token_copy`](docs/reference/effects.md#create_token_copy) | 707.2, 707.8, 707.9a, 707.9b, 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. |
|
|
311
|
+
| [`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
312
|
| [`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
313
|
| [`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
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
|
-
| [`delayed_trigger`](docs/reference/effects.md#delayed_trigger) | 603.7a, 603.7b, 603.7c, 603.7d, 603.7e | 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. |
|
|
315
|
+
| [`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
316
|
| [`destroy`](docs/reference/effects.md#destroy) | 701.8a | Destroy each referenced permanent (it goes to its owner's graveyard). |
|
|
317
317
|
| [`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). |
|
|
318
318
|
| [`discard`](docs/reference/effects.md#discard) | 701.9a, 701.9b | Each referenced player discards `amount` cards of their choice (default: you). `random: true`: the cards are chosen at random (the game's random number generator), with no decision. `hand: true`: each discards their whole hand at once ("discard your hand"; how many is its amount {"this_way": n}). |
|
|
@@ -359,7 +359,7 @@ Rules version: Comprehensive Rules effective 2026-11-06.
|
|
|
359
359
|
| [`pump`](docs/reference/effects.md#pump) | 611.2a, 611.2c, 613.4c, 514.2, 500.1 | Each referenced creature gets +power/+toughness until end of turn (`duration: "until_your_next_turn"`: until its controller's next turn begins). The set of affected creatures is locked in when the effect starts. |
|
|
360
360
|
| [`put_in_library`](docs/reference/effects.md#put_in_library) | 401.4, 400.7, 608.2b | Put each referenced permanent, or card in a graveyard or exile, into its owner's library: on the `top` or `bottom`, or (`owner_choice`) where its owner chooses. |
|
|
361
361
|
| [`recruit`](docs/reference/effects.md#recruit) | 701.70a | Each referenced player (default: you) recruits: draws a card, then discards a card; if a nonland card was discarded, they create a 1/1 white Human Soldier creature token. |
|
|
362
|
-
| [`reflexive_trigger`](docs/reference/effects.md#reflexive_trigger) | 603.12, 603.12a, 603.7d, 603.7e, 603.3d | 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"). |
|
|
362
|
+
| [`reflexive_trigger`](docs/reference/effects.md#reflexive_trigger) | 603.12, 603.12a, 603.7d, 603.7e, 603.3d, 107.3n | 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"). |
|
|
363
363
|
| [`remove_all_counters`](docs/reference/effects.md#remove_all_counters) | 122.8, 122.1 | Remove every counter named `counter` (every counter, if no `counter` is given) from each referenced permanent or player ("you lose all poison counters"). |
|
|
364
364
|
| [`remove_counters`](docs/reference/effects.md#remove_counters) | 122.8, 122.1 | 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, ..."). |
|
|
365
365
|
| [`remove_damage`](docs/reference/effects.md#remove_damage) | 120.6, 514.2 | Remove all damage marked on each referenced permanent. |
|
|
@@ -371,7 +371,7 @@ Rules version: Comprehensive Rules effective 2026-11-06.
|
|
|
371
371
|
| [`roll_dice`](docs/reference/effects.md#roll_dice) | 706.1, 706.1a, 706.2, 706.3a, 608.2c | You roll `amount` dice (default 1) with `sides` sides (default 6). The total of the results is this effect's amount: {"this_way": n} in later effects and conditions (a results table is effects with an `if` on it). |
|
|
372
372
|
| [`sacrifice`](docs/reference/effects.md#sacrifice) | 701.21a | The controller sacrifices each referenced permanent they control (it goes to its owner's graveyard; it isn't destroyed, so indestructible doesn't stop it). |
|
|
373
373
|
| [`sacrifice_choice`](docs/reference/effects.md#sacrifice_choice) | 701.21a, 101.4, 118.3 | Each referenced player (default: you) sacrifices `count` (default 1; "any": any number) permanents they control matching `filter`, chosen by them in turn order starting with the active player; all are sacrificed at once. The `filter`'s `controller` and `other` restrictions are relative to the effect's controller and source. |
|
|
374
|
-
| [`scry`](docs/reference/effects.md#scry) | 701.22a | Look at the top `amount` cards of your library; put any number on the bottom and the rest on top in any order. |
|
|
374
|
+
| [`scry`](docs/reference/effects.md#scry) | 701.22a, 101.4 | Look at the top `amount` cards of your library; put any number on the bottom and the rest on top in any order. `to`: who scries (default "you"; e.g. {"target": 0} for "target player scries"), each in turn. |
|
|
375
375
|
| [`search_library`](docs/reference/effects.md#search_library) | 701.23a, 701.23b, 701.23d, 701.23e, 701.20a, 701.24a, 701.24b, 118.12, 110.2a, 614.1a | Search your library for up to `count` cards matching `for`, then put them into your hand (or onto the battlefield, tapped if `tapped`, with `counters`; or into your graveyard) and shuffle. `put: library_top`: shuffle, then put the found card (one) on top. Computed bounds in `for` are worked out as the effect resolves. With a stated quality you may find fewer (or none); a search for just "a card" must find one if it can. `reveal` shows the found cards to every player. `searcher` names another player who searches their own library (e.g. {"controller_of": {"target": 0}}); `may: true` lets the searcher decline (then nothing is shuffled). `different_names: true`: the cards found must all have different names ("basic land cards with different names"). `battlefield_instead`: {"if": condition, "for": card spec}: a found card matching `for` goes onto the battlefield instead of into your hand while the condition holds. |
|
|
376
376
|
| [`set_base_power_toughness`](docs/reference/effects.md#set_base_power_toughness) | 613.4b, 611.2a, 611.2b, 611.2c | Each referenced creature's base power and toughness become `power`/`toughness` (layer 7b; counters and pumps still apply), until end of turn or, with `duration: "indefinite"`, for as long as it stays on the battlefield. |
|
|
377
377
|
| [`set_creature_types`](docs/reference/effects.md#set_creature_types) | 205.1a, 613.1d, 611.2c, 514.2 | Until end of turn, each referenced creature's creature types are exactly `types` (its other subtypes, such as artifact types, stay). The affected set is locked in. |
|
|
@@ -380,7 +380,7 @@ Rules version: Comprehensive Rules effective 2026-11-06.
|
|
|
380
380
|
| [`shuffle_library`](docs/reference/effects.md#shuffle_library) | 701.24a | Each referenced player shuffles their library (default: you). |
|
|
381
381
|
| [`skip_turns`](docs/reference/effects.md#skip_turns) | 614.1b, 614.10, 614.10a | Each referenced player skips their next `amount` turns (extra turns included): each of those turns doesn't happen, and the next player in turn order takes theirs. Several skips add up. |
|
|
382
382
|
| [`solve`](docs/reference/effects.md#solve) | 720.3a, 720.3b | 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`. |
|
|
383
|
-
| [`surveil`](docs/reference/effects.md#surveil) | 701.25a | Look at the top `amount` cards of your library; put any number into your graveyard and the rest on top in any order. |
|
|
383
|
+
| [`surveil`](docs/reference/effects.md#surveil) | 701.25a, 101.4 | Look at the top `amount` cards of your library; put any number into your graveyard and the rest on top in any order. `to`: who surveils (default "you"), each in turn. |
|
|
384
384
|
| [`suspend`](docs/reference/effects.md#suspend) | 702.62a, 702.62b, 406.1 | Exile each referenced card or spell with `amount` time counters on it; if it doesn't have suspend, it gains suspend (keyword `suspend`) while it stays exiled. |
|
|
385
385
|
| [`tap`](docs/reference/effects.md#tap) | 701.26a | Tap each referenced permanent. |
|
|
386
386
|
| [`transform`](docs/reference/effects.md#transform) | 701.27a, 701.27c, 701.27d, 701.27e, 701.27g, 712.15 | Transform each referenced permanent (default: this one): turn it over so its other face is up. It stays the same object, and effects on it keep applying. Nothing happens to a permanent that isn't a double-faced card or token, or whose other face is an instant or sorcery. An ability of the permanent transforms it only if it hasn't transformed since the ability was put on the stack. |
|
data/docs/guides/api.md
CHANGED
|
@@ -240,6 +240,18 @@ or draw (CR 103.1), then each player decides on a mulligan.
|
|
|
240
240
|
players lose at once the game is a draw: `"winner" => nil` and the reasons are
|
|
241
241
|
joined, e.g. `"life,life"` (CR 104.4a).
|
|
242
242
|
|
|
243
|
+
### Limiting the board (simulations)
|
|
244
|
+
|
|
245
|
+
Some boards double every turn, and each decision then takes longer than the
|
|
246
|
+
last. `Enjine::Setup.new(alice, bob, permanent_limit: 150)` ends such a game as
|
|
247
|
+
a draw, `{"winner" => nil, "reason" => "permanent_limit"}`, once more than 150
|
|
248
|
+
permanents (both players' together; phased-out ones aren't counted) are on the
|
|
249
|
+
battlefield. This is not a rule of the game and is off unless you set it. It is
|
|
250
|
+
checked with state-based actions (CR 704.3), after players have lost, so one
|
|
251
|
+
effect can overshoot the limit before the game ends. The limit is part of the
|
|
252
|
+
snapshot, survives `fork` and `restart`, and replays are unaffected: the same
|
|
253
|
+
setup, seed and decisions end the same way.
|
|
254
|
+
|
|
243
255
|
## 5. The decision loop
|
|
244
256
|
|
|
245
257
|
```ruby
|
|
@@ -50,7 +50,7 @@ Tips:
|
|
|
50
50
|
| --- | --- | --- | --- |
|
|
51
51
|
| `name` | yes | string | Unique (a card with faces: see 4.17). Its slug becomes the card id: `"Jace, the Mind Sculptor"` → `jace_the_mind_sculptor`. Two different definitions with the same name in one game raise `CatalogConflict`. |
|
|
52
52
|
| `types` | yes | list | Card types, lowercase: `land`, `creature`, `artifact`, `enchantment`, `planeswalker`, `instant`, `sorcery`. A card can have several (`["artifact", "creature"]`). |
|
|
53
|
-
| `mana_cost` | castable cards | string | `"{2}{W}{W}"`. Symbols: `{N}` generic, `{W}{U}{B}{R}{G}`, `{C}`, `{X}` (announced while casting; use the amount `"x"` in effects, see 4.7). Lands must **not** have one. A card without one can't be cast. Two-color hybrid `{R/G}` is supported (paid with either color, CR 107.4e), and so
|
|
53
|
+
| `mana_cost` | castable cards | string | `"{2}{W}{W}"`. Symbols: `{N}` generic, `{W}{U}{B}{R}{G}`, `{C}`, `{X}` (announced while casting; use the amount `"x"` in effects, see 4.7). Lands must **not** have one. A card without one can't be cast. Two-color hybrid `{R/G}` is supported (paid with either color, CR 107.4e), and so are monocolored hybrid `{2/B}` (one black mana or two mana of any type; mana value 2, CR 202.3f) and colorless hybrid `{C/W}` (one colorless or one white mana; the card is white, mana value 1 for the symbol, CR 107.4, 202.2d); Phyrexian and `{S}` are not yet. |
|
|
54
54
|
| `supertypes` | no | list | `basic` (exempt from the 4-copy rule). `legendary` and `snow`: not yet. |
|
|
55
55
|
| `subtypes` | no | list | Lowercase, spaces become `_`: `["human", "wizard"]`. Free-form labels, except the basic land types `plains island swamp mountain forest`, which grant their mana ability automatically (CR 305.6) and are valid only on lands. |
|
|
56
56
|
| `keywords` | no | list | Keyword abilities, lowercase: see `SUPPORTED.md` → *Keyword abilities*. A keyword listed twice is one instance (redundant, CR 702.2f), except where each instance triggers separately: `cascade`, `storm`, `extort` and `increment` get one ability per listing ("cascade, cascade" is `["cascade", "cascade"]`, CR 702.85c). |
|
|
@@ -103,6 +103,8 @@ pool, so tap other sources first:
|
|
|
103
103
|
| "{T}: Add X mana of any one color, where X is …" | `"color": "any_one", "amount": <amount>` |
|
|
104
104
|
| "As this land enters, choose a color. {T}: Add one mana of the chosen color." | `{ "choose_color": {} }`, `{ "mana": { "cost": ["tap"], "color": "chosen" } }` (also on `add_mana`, CR 607.2d) |
|
|
105
105
|
| "{T}, Pay 1 life: Add one mana of any color." | `{ "mana": { "cost": ["tap", { "pay_life": 1 }], "color": "any_one" } }` |
|
|
106
|
+
| "{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
|
+
| "{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) |
|
|
106
108
|
| "{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"] } } } }` |
|
|
107
109
|
|
|
108
110
|
```json
|
|
@@ -159,7 +161,9 @@ takes `spend_only` too ("Add {C}{C}. Spend this mana only to cast spells.").
|
|
|
159
161
|
- `cost`: costs before the colon. `"tap"` is `{T}`; `{ "mana": "{1}{R}" }` is a mana
|
|
160
162
|
cost; `"sacrifice"` sacrifices this permanent and `"exile_self"` exiles it; `{ "sacrifice_permanent": { "filter": "creature", "other": true } }`,
|
|
161
163
|
`{ "tap_permanents": { "count": 3, "filter": ... } }` and `{ "remove_counters": { "count": 3 } }` are chosen while
|
|
162
|
-
activating
|
|
164
|
+
activating (from this permanent only: `"self": true`; "Remove three quest counters from this and sacrifice it" is
|
|
165
|
+
`[{ "remove_counters": { "count": 3, "counter": "quest", "self": true } }, "sacrifice"]` in either order: costs that
|
|
166
|
+
take the permanent away are paid last, CR 601.2h); `"exile_self_from_graveyard"` / `"bottom_self_from_graveyard"` make it a graveyard ability. `{Q}` is
|
|
163
167
|
not supported yet. More costs (each also usable in a spell's `additional_cost`):
|
|
164
168
|
|
|
165
169
|
| Oracle words | Cost |
|
|
@@ -253,6 +257,7 @@ have '[−2]: …'" is `{ "static": { "affects": { "each": "planeswalker", "cont
|
|
|
253
257
|
| "noncreature spell" | `{ "spell": { "not": ["creature"] } }` |
|
|
254
258
|
|
|
255
259
|
| "with flying", "with flying or reach", "without flying" | `{ "creature": { "keywords": ["flying"] } }`, `{ "creature": { "keywords": ["flying", "reach"] } }`, `{ "creature": { "not_keywords": ["flying"] } }` (current keywords: granted ones count, CR 702.1) |
|
|
260
|
+
| "monocolored", "multicolored", "colorless" (CR 105.2a-c) | `{ "permanent": { "color_count": { "equal": 1 } } }`, `{ "color_count": { "at_least": 2 } }`, `{ "color_count": { "equal": 0 } }` (integer bounds 0-5; any filter: `creature`, `spell`, a static's `affects.each`) |
|
|
256
261
|
| "of the chosen color / creature type / card type", "not of the chosen type" | `{ "creature": { "subtypes": "chosen" } }`, `{ "spell": { "colors": "chosen" } }`, `{ "permanent": { "types": "chosen" } }`, `{ "creature": { "not_subtypes": "chosen" } }` (see 4.15) |
|
|
257
262
|
|
|
258
263
|
**Card specs.** Effects that look at cards in any zone (graveyard, hand, library, exile; `for`,
|
|
@@ -266,7 +271,7 @@ whose qualities must all match:
|
|
|
266
271
|
| "a non-Avatar creature card" | `{ "types": ["creature"], "not_subtypes": ["avatar"] }` |
|
|
267
272
|
| "a creature card with flying" | `{ "types": ["creature"], "keywords": ["flying"] }` (any listed keyword) |
|
|
268
273
|
| "with mana value 3 or less", "with power or toughness 1 or less" | `{ "mana_value": { "at_most": 3 } }`, `{ "any_of": [{ "power": { "at_most": 1 } }, { "toughness": { "at_most": 1 } }] }` |
|
|
269
|
-
| "a black card", "a monocolored card" | `{ "colors": ["B"] }`, `{ "color_count": { "equal": 1 } }` |
|
|
274
|
+
| "a black card", "a monocolored card" | `{ "colors": ["B"] }`, `{ "color_count": { "equal": 1 } }` (also in target and `each` filters, below) |
|
|
270
275
|
| "a card that has an Adventure" | `{ "layout": "adventure" }` (any card layout: adventure, omen, prepare, transform, modal, meld) |
|
|
271
276
|
| "an instant or sorcery card" | `{ "any_of": [{ "types": ["instant"] }, { "types": ["sorcery"] }] }` |
|
|
272
277
|
|
|
@@ -314,6 +319,8 @@ is a flicker ("exile …, then return it to the battlefield under its owner's co
|
|
|
314
319
|
is "… at the beginning of the next end step". It triggers once, with the controller
|
|
315
320
|
and source of what created it; a remembered object that has changed zones is not
|
|
316
321
|
affected (CR 603.7c).
|
|
322
|
+
- A delayed or reflexive trigger reads the X of the spell or ability that created it: `"x"` in its effects is that
|
|
323
|
+
X (CR 107.3n, 603.12), e.g. "when you cast your next instant or sorcery spell this turn, copy that spell X times".
|
|
317
324
|
- `{ "was_cast": true }` as a triggered ability's `if` is "if you cast it" (CR 603.4).
|
|
318
325
|
|
|
319
326
|
### 4.5b More trigger shapes
|
|
@@ -652,6 +659,7 @@ Generic shapes (N, [quality] and [zone] stand for whatever the card says):
|
|
|
652
659
|
|
|
653
660
|
| Shape | Data |
|
|
654
661
|
| --- | --- |
|
|
662
|
+
| "target player scries N", "each player surveils N" | `{ "scry": { "amount": N, "to": { "target": 0 } } }`, `{ "surveil": { "amount": N, "to": { "each": "player" } } }` (each named player in turn, APNAP order; default `"you"`) |
|
|
655
663
|
| look at the top N; you may reveal a [quality] card among them and put it into your hand; the rest go to the bottom in a random order | `{ "dig": { "amount": N, "for": spec, "optional": true, "reveal": "chosen", "put": "hand" } }` |
|
|
656
664
|
| look at the top N; one goes to your hand, the rest to your graveyard | `{ "dig": { "amount": N, "rest": "graveyard" } }` |
|
|
657
665
|
| reveal the top N; every [quality] card goes onto the battlefield tapped | `{ "dig": { "amount": N, "reveal": "all", "for": spec, "count": "all", "put": "battlefield", "tapped": true } }` |
|
|
@@ -712,7 +720,12 @@ copies with `of` (a selector; `"self"` is the source in any zone, even a card th
|
|
|
712
720
|
exiled itself from a graveyard to pay the cost) and takes the same `except` object for
|
|
713
721
|
"except …" (CR 707.9a-b), which a copy of the copy keeps:
|
|
714
722
|
`{ "legendary": false, "keywords": ["menace"], "types": [...], "subtypes": [...],
|
|
715
|
-
"supertypes": [...], "name": "…", "power": 1, "toughness": 1, "colors": [] }`.
|
|
723
|
+
"supertypes": [...], "name": "…", "power": 1, "toughness": 1, "colors": [], "replace": [...] }`.
|
|
724
|
+
`types`, `subtypes` and `supertypes` are **added** to the copied ones ("except it's an artifact in addition
|
|
725
|
+
to its other types", CR 205.1b). List them in `replace` when the text **sets** them instead ("except it's a
|
|
726
|
+
6/6 green Dinosaur creature": `{ "types": ["creature"], "subtypes": ["dinosaur"], "colors": ["G"], "power": 6,
|
|
727
|
+
"toughness": 6, "replace": ["types", "subtypes"] }`, CR 707.9b, 205.1a). Set subtypes replace the creature
|
|
728
|
+
types; other subtypes (Equipment, Vehicle) stay unless `types` is set too.
|
|
716
729
|
|
|
717
730
|
| Oracle words | Data |
|
|
718
731
|
| --- | --- |
|
data/docs/reference/abilities.md
CHANGED
|
@@ -742,12 +742,12 @@ Rules: CR 702.5a, CR 115.1b, CR 303.4a
|
|
|
742
742
|
|
|
743
743
|
As this permanent enters, its controller may choose a permanent on the battlefield matching `of`; it enters as a copy of that permanent (its copiable values, with the `except` modifications) and its enter abilities trigger. `with_counters: true`: it also enters with the counters the copied permanent has. Choosing none: it enters as itself.
|
|
744
744
|
|
|
745
|
-
Rules: CR 707.5, CR 707.9b, CR 614.1c, CR 614.12
|
|
745
|
+
Rules: CR 707.5, CR 707.9b, CR 205.1a, CR 614.1c, CR 614.12
|
|
746
746
|
|
|
747
747
|
| Parameter | Description |
|
|
748
748
|
| --- | --- |
|
|
749
749
|
| `of` | filter (the permanents it may copy) |
|
|
750
|
-
| `except` | {"legendary": false, "keywords": [...], "types": [...], "subtypes": [...], "supertypes": [...], "name": ..., "power": n, "toughness": n, "colors": [...]} |
|
|
750
|
+
| `except` | {"legendary": false, "keywords": [...], "types": [...], "subtypes": [...], "supertypes": [...], "name": ..., "power": n, "toughness": n, "colors": [...], "replace": ["types" | "subtypes" | "supertypes"]} |
|
|
751
751
|
| `with_counters` | boolean |
|
|
752
752
|
|
|
753
753
|
```json
|
|
@@ -1264,9 +1264,9 @@ Rules: CR 606.3, CR 606.4, CR 606.5, CR 602.2b
|
|
|
1264
1264
|
|
|
1265
1265
|
## mana
|
|
1266
1266
|
|
|
1267
|
-
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."
|
|
1267
|
+
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").
|
|
1268
1268
|
|
|
1269
|
-
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
|
|
1269
|
+
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
|
|
1270
1270
|
|
|
1271
1271
|
| Parameter | Description |
|
|
1272
1272
|
| --- | --- |
|
|
@@ -1278,6 +1278,7 @@ Rules: CR 605.1a, CR 605.3a, CR 605.3b, CR 106.1a, CR 106.4, CR 106.6, CR 607.2d
|
|
|
1278
1278
|
| `spend_only` | {"spells": card spec, "abilities": card spec, "from" | "not_from": zone} |
|
|
1279
1279
|
| `only_if` | condition: it can be activated only while it holds (CR 602.5b) |
|
|
1280
1280
|
| `limit` | "once_each_turn" (CR 602.5b) |
|
|
1281
|
+
| `add_counters` | {"counter": name, "amount": integer (default 1)}: put on this permanent |
|
|
1281
1282
|
|
|
1282
1283
|
```json
|
|
1283
1284
|
{
|
data/docs/reference/costs.md
CHANGED
|
@@ -284,9 +284,9 @@ Rules: CR 119.4, CR 119.4b, CR 118.3b, CR 601.2b, CR 107.3a, CR 702.21a
|
|
|
284
284
|
|
|
285
285
|
## remove_counters
|
|
286
286
|
|
|
287
|
-
Remove `count` counters (of kind `counter`, or any kind) from among permanents you control matching `filter` (default creature), one counter per choice. Removed as it becomes cast. `self: true`: only from this permanent ("Remove two counters from Ghost-Spider").
|
|
287
|
+
Remove `count` counters (of kind `counter`, or any kind) from among permanents you control matching `filter` (default creature), one counter per choice. Removed as it becomes cast. `self: true`: only from this permanent ("Remove two counters from Ghost-Spider"). With `self: true` and a `counter` kind it needs no choice, so a mana ability may have it ("Remove a charge counter from this: Add one mana of any color").
|
|
288
288
|
|
|
289
|
-
Rules: CR 602.2b, CR 601.2h, CR 118.3, CR 122.1
|
|
289
|
+
Rules: CR 602.2b, CR 601.2h, CR 118.3, CR 122.1, CR 605.3a
|
|
290
290
|
|
|
291
291
|
| Parameter | Description |
|
|
292
292
|
| --- | --- |
|
data/docs/reference/effects.md
CHANGED
|
@@ -278,7 +278,7 @@ Rules: CR 707.2, CR 707.4, CR 613.2a, CR 613.7, CR 611.2a, CR 514.2
|
|
|
278
278
|
| --- | --- |
|
|
279
279
|
| `to` | selector (the permanents that become copies) |
|
|
280
280
|
| `of` | selector (what they copy) |
|
|
281
|
-
| `except` | {"legendary": false, "keywords": [...], "types": [...], "subtypes": [...], "supertypes": [...], "name": ..., "power": n, "toughness": n, "colors": [...]} |
|
|
281
|
+
| `except` | {"legendary": false, "keywords": [...], "types": [...], "subtypes": [...], "supertypes": [...], "name": ..., "power": n, "toughness": n, "colors": [...], "replace": ["types" | "subtypes" | "supertypes"]} |
|
|
282
282
|
| `duration` | end_of_turn | until_your_next_turn | permanent |
|
|
283
283
|
|
|
284
284
|
```json
|
|
@@ -688,7 +688,7 @@ Rules: CR 707.10, CR 707.10a, CR 707.10b, CR 707.10c, CR 707.10f, CR 608.3f
|
|
|
688
688
|
| `amount` | amount (default 1) |
|
|
689
689
|
| `new_targets` | boolean |
|
|
690
690
|
| `to` | selector (default "you") |
|
|
691
|
-
| `except` | {"legendary": false, "keywords": [...], "types": [...], "subtypes": [...], "supertypes": [...], "name": ..., "power": n, "toughness": n, "colors": [...]} |
|
|
691
|
+
| `except` | {"legendary": false, "keywords": [...], "types": [...], "subtypes": [...], "supertypes": [...], "name": ..., "power": n, "toughness": n, "colors": [...], "replace": ["types" | "subtypes" | "supertypes"]} |
|
|
692
692
|
|
|
693
693
|
```json
|
|
694
694
|
{
|
|
@@ -829,14 +829,14 @@ Rules: CR 111.1, CR 111.10, CR 701.7a, CR 704.5d, CR 508.4, CR 506.3b, CR 707.2
|
|
|
829
829
|
|
|
830
830
|
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.
|
|
831
831
|
|
|
832
|
-
Rules: CR 707.2, CR 707.8, CR 707.9a, CR 707.9b, CR 111.1, CR 614.1c
|
|
832
|
+
Rules: CR 707.2, CR 707.8, CR 707.9a, CR 707.9b, CR 205.1a, CR 205.1b, CR 111.1, CR 614.1c
|
|
833
833
|
|
|
834
834
|
| Parameter | Description |
|
|
835
835
|
| --- | --- |
|
|
836
836
|
| `of` | selector (what to copy) |
|
|
837
837
|
| `amount` | amount (default 1) |
|
|
838
838
|
| `tapped` | boolean |
|
|
839
|
-
| `except` | {"legendary": false, "keywords": [...], "types": [...], "subtypes": [...], "supertypes": [...], "name": ..., "power": n, "toughness": n, "colors": [...]} |
|
|
839
|
+
| `except` | {"legendary": false, "keywords": [...], "types": [...], "subtypes": [...], "supertypes": [...], "name": ..., "power": n, "toughness": n, "colors": [...], "replace": ["types" | "subtypes" | "supertypes"]} |
|
|
840
840
|
| `to` | selector (default "you") |
|
|
841
841
|
|
|
842
842
|
```json
|
|
@@ -920,7 +920,7 @@ Rules: CR 120.3a, CR 120.3c, CR 120.3e, CR 120.6, CR 120.4a, CR 120.10
|
|
|
920
920
|
|
|
921
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.
|
|
922
922
|
|
|
923
|
-
Rules: CR 603.7a, CR 603.7b, CR 603.7c, CR 603.7d, CR 603.7e
|
|
923
|
+
Rules: CR 603.7a, CR 603.7b, CR 603.7c, CR 603.7d, CR 603.7e, CR 107.3n
|
|
924
924
|
|
|
925
925
|
| Parameter | Description |
|
|
926
926
|
| --- | --- |
|
|
@@ -1927,7 +1927,7 @@ Rules: CR 701.70a
|
|
|
1927
1927
|
|
|
1928
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").
|
|
1929
1929
|
|
|
1930
|
-
Rules: CR 603.12, CR 603.12a, CR 603.7d, CR 603.7e, CR 603.3d
|
|
1930
|
+
Rules: CR 603.12, CR 603.12a, CR 603.7d, CR 603.7e, CR 603.3d, CR 107.3n
|
|
1931
1931
|
|
|
1932
1932
|
| Parameter | Description |
|
|
1933
1933
|
| --- | --- |
|
|
@@ -2216,13 +2216,14 @@ Rules: CR 701.21a, CR 101.4, CR 118.3
|
|
|
2216
2216
|
|
|
2217
2217
|
## scry
|
|
2218
2218
|
|
|
2219
|
-
Look at the top `amount` cards of your library; put any number on the bottom and the rest on top in any order.
|
|
2219
|
+
Look at the top `amount` cards of your library; put any number on the bottom and the rest on top in any order. `to`: who scries (default "you"; e.g. {"target": 0} for "target player scries"), each in turn.
|
|
2220
2220
|
|
|
2221
|
-
Rules: CR 701.22a
|
|
2221
|
+
Rules: CR 701.22a, CR 101.4
|
|
2222
2222
|
|
|
2223
2223
|
| Parameter | Description |
|
|
2224
2224
|
| --- | --- |
|
|
2225
2225
|
| `amount` | integer |
|
|
2226
|
+
| `to` | selector of players (default you) |
|
|
2226
2227
|
|
|
2227
2228
|
```json
|
|
2228
2229
|
{
|
|
@@ -2410,13 +2411,14 @@ Rules: CR 720.3a, CR 720.3b
|
|
|
2410
2411
|
|
|
2411
2412
|
## surveil
|
|
2412
2413
|
|
|
2413
|
-
Look at the top `amount` cards of your library; put any number into your graveyard and the rest on top in any order.
|
|
2414
|
+
Look at the top `amount` cards of your library; put any number into your graveyard and the rest on top in any order. `to`: who surveils (default "you"), each in turn.
|
|
2414
2415
|
|
|
2415
|
-
Rules: CR 701.25a
|
|
2416
|
+
Rules: CR 701.25a, CR 101.4
|
|
2416
2417
|
|
|
2417
2418
|
| Parameter | Description |
|
|
2418
2419
|
| --- | --- |
|
|
2419
2420
|
| `amount` | integer |
|
|
2421
|
+
| `to` | selector of players (default you) |
|
|
2420
2422
|
|
|
2421
2423
|
```json
|
|
2422
2424
|
{
|
|
@@ -308,17 +308,24 @@ module Enjine
|
|
|
308
308
|
targets: obj.targets.flatten, during_resolution: ctx["no_priority"] == true)
|
|
309
309
|
end
|
|
310
310
|
|
|
311
|
-
# The non-mana costs (CR 602.2b): its own ({T},
|
|
312
|
-
#
|
|
313
|
-
#
|
|
311
|
+
# The non-mana costs (CR 602.2b): its own ({T}, exile it from the graveyard), the chosen ones (sacrifice
|
|
312
|
+
# another creature, remove counters) and a loyalty cost, then last the costs that take the source off the
|
|
313
|
+
# battlefield (sacrifice it, exile it). Costs may be paid in any order (CR 601.2h); this is the order in which
|
|
314
|
+
# all of them can be paid ("Remove three quest counters from this and sacrifice it"). A source sacrificed or
|
|
315
|
+
# exiled as a cost is remembered as it last existed (its counters, CR 608.2h).
|
|
314
316
|
def pay_ability_costs!(ctx, obj)
|
|
315
317
|
source = object(ctx["source"])
|
|
316
318
|
ability = chars(source).ability(ctx["ability"])
|
|
317
|
-
|
|
318
|
-
|
|
319
|
+
leaving, staying = frame_costs(ctx).reject(&:mana?).partition { Mechanics::Costs.leaving_self?(it) }
|
|
320
|
+
staying.each { it.pay!(self, source) } # the chosen option of a one_of (CR 601.2b)
|
|
319
321
|
pay_chosen_costs!(ctx)
|
|
320
|
-
|
|
322
|
+
pay_loyalty_cost!(ctx, source, ability) if ability.kind == :loyalty
|
|
323
|
+
obj.memory["source_counters"] = source.counters.dup if ability.costs.any? { Mechanics::Costs.leaving_self?(it) }
|
|
324
|
+
leaving.each { it.pay!(self, source) }
|
|
325
|
+
end
|
|
321
326
|
|
|
327
|
+
# CR 606.4: a loyalty ability's cost puts or removes loyalty counters.
|
|
328
|
+
def pay_loyalty_cost!(ctx, source, ability)
|
|
322
329
|
source.loyalty_turn = state.turn
|
|
323
330
|
cost = ability.x_loyalty? ? -ctx["x"].to_i : ability.loyalty_cost
|
|
324
331
|
cost.negative? ? remove_counters!(source, "loyalty", -cost) : add_counters!(source, "loyalty", cost)
|
|
@@ -179,10 +179,8 @@ module Enjine
|
|
|
179
179
|
end
|
|
180
180
|
end
|
|
181
181
|
|
|
182
|
-
# A mana ability
|
|
183
|
-
def irreversible_mana_ability?(id, ref)
|
|
184
|
-
chars(id).ability(ref).costs.any? { !it.is_a?(Mechanics::Costs::Tap) && !it.is_a?(Mechanics::Costs::TapGranter) && !it.mana? }
|
|
185
|
-
end
|
|
182
|
+
# A mana ability that can't be undone (Abilities::ManaAbility#irreversible?).
|
|
183
|
+
def irreversible_mana_ability?(id, ref) = chars(id).ability(ref).irreversible?
|
|
186
184
|
|
|
187
185
|
def reserved_for_cost?(frame, id, ref)
|
|
188
186
|
return true if id == payment_excluded_source(frame)
|
|
@@ -213,7 +211,8 @@ module Enjine
|
|
|
213
211
|
produced.each { pool[it] += 1 }
|
|
214
212
|
end
|
|
215
213
|
used = [id, tapped_granter(option[:ability], ability)].compact
|
|
216
|
-
|
|
214
|
+
later = units_after_activating(id, option[:ability], ability) # ManaSources: it may be activated again
|
|
215
|
+
payable_with?(frame, remaining_cost(frame["remaining"]), pool, payment_reserved(frame) + used, restricted: rest, extra: later)
|
|
217
216
|
end
|
|
218
217
|
|
|
219
218
|
# CR 605.3: activating a mana ability while paying. One whose costs include more than {T} (a
|
|
@@ -232,13 +231,13 @@ module Enjine
|
|
|
232
231
|
|
|
233
232
|
# Whether `cost` can be paid from `pool` (and the `restricted` pool) plus the player's untapped
|
|
234
233
|
# sources, minus `excluded` and a source the ability taps for its own cost, for the payment `frame`.
|
|
235
|
-
def payable_with?(frame, cost, pool, excluded, restricted:)
|
|
234
|
+
def payable_with?(frame, cost, pool, excluded, restricted:, extra: [])
|
|
236
235
|
return true if cost.mana_value.zero?
|
|
237
236
|
|
|
238
237
|
index = frame["player"]
|
|
239
238
|
excluded = [*excluded, payment_excluded_source(frame)].compact
|
|
240
239
|
purpose = payment_purpose(frame)
|
|
241
|
-
units = pool_units(index, pool, purpose, restricted) + source_units(index, excluded, purpose) +
|
|
240
|
+
units = extra + pool_units(index, pool, purpose, restricted) + source_units(index, excluded, purpose) +
|
|
242
241
|
convoke_units(index, purpose, excluded) + # CR 702.51a (Engine::AltCasting)
|
|
243
242
|
waterbend_units(index, purpose, excluded) # CR 701.67a (Engine::Waterbending)
|
|
244
243
|
covers?(cost, units)
|
data/lib/enjine/engine/copies.rb
CHANGED
|
@@ -41,14 +41,18 @@ module Enjine
|
|
|
41
41
|
# What a copy of `obj` gets: [card id, exceptions] (CR 707.2, 707.3).
|
|
42
42
|
def copiable_values(obj) = [obj.card, copy_exceptions(obj) || {}]
|
|
43
43
|
|
|
44
|
-
# 707.9b: exceptions of a later copy effect apply on top of those it copied.
|
|
44
|
+
# 707.9b: exceptions of a later copy effect apply on top of those it copied. A list the later one sets
|
|
45
|
+
# (`replace`, CR 205.1a) replaces the earlier list; otherwise the lists add up (CR 205.1b).
|
|
45
46
|
def self.merge_except(old, new)
|
|
46
47
|
old ||= {}
|
|
47
|
-
merged = old.merge(new.except("keywords", "types", "subtypes", "supertypes"))
|
|
48
|
+
merged = old.merge(new.except("keywords", "types", "subtypes", "supertypes", "replace"))
|
|
49
|
+
setting = Array(new["replace"])
|
|
48
50
|
%w[keywords types subtypes supertypes].each do |key|
|
|
49
|
-
list = Array(old[key]) | Array(new[key])
|
|
51
|
+
list = setting.include?(key) ? Array(new[key]) : Array(old[key]) | Array(new[key])
|
|
50
52
|
merged[key] = list unless list.empty?
|
|
51
53
|
end
|
|
54
|
+
replace = Array(old["replace"]) | setting
|
|
55
|
+
merged["replace"] = replace unless replace.empty?
|
|
52
56
|
merged
|
|
53
57
|
end
|
|
54
58
|
|
|
@@ -56,10 +60,13 @@ module Enjine
|
|
|
56
60
|
def self.apply_exceptions(chars, except)
|
|
57
61
|
attrs = {}
|
|
58
62
|
attrs[:name] = except["name"] if except["name"]
|
|
59
|
-
|
|
63
|
+
setting = Array(except["replace"]) # CR 205.1a: set, not added (CR 205.1b)
|
|
64
|
+
attrs[:supertypes] = setting.include?("supertypes") ? sym(except["supertypes"]) : chars.supertypes | sym(except["supertypes"])
|
|
60
65
|
attrs[:supertypes] -= [:legendary] if except["legendary"] == false
|
|
61
|
-
attrs[:types] = chars.types | sym(except["types"])
|
|
62
|
-
attrs[:subtypes] =
|
|
66
|
+
attrs[:types] = setting.include?("types") ? sym(except["types"]) : chars.types | sym(except["types"])
|
|
67
|
+
attrs[:subtypes] = if setting.include?("subtypes") then set_subtypes(chars, except, setting)
|
|
68
|
+
else chars.subtypes | sym(except["subtypes"])
|
|
69
|
+
end
|
|
63
70
|
attrs[:keywords] = chars.keywords | sym(except["keywords"])
|
|
64
71
|
attrs[:colors] = sym(except["colors"]) if except["colors"]
|
|
65
72
|
attrs[:power] = except["power"] if except.key?("power")
|
|
@@ -69,6 +76,13 @@ module Enjine
|
|
|
69
76
|
|
|
70
77
|
def self.sym(list) = Array(list).map(&:to_sym)
|
|
71
78
|
|
|
79
|
+
# CR 205.1a: setting creature types replaces only the creature types; the other subtypes stay unless the card
|
|
80
|
+
# types are set too (a subtype goes with its card type: "a 6/6 Dinosaur creature" is no Equipment any more).
|
|
81
|
+
def self.set_subtypes(chars, except, setting)
|
|
82
|
+
kept = setting.include?("types") ? [] : chars.subtypes - Mechanics::Keywords::Changeling::CREATURE_TYPES
|
|
83
|
+
kept | sym(except["subtypes"])
|
|
84
|
+
end
|
|
85
|
+
|
|
72
86
|
# ---- making copies ---------------------------------------------------------------------------
|
|
73
87
|
|
|
74
88
|
# CR 707.8, 111.1: a token that's a copy of [card, except], created under `controller`'s control.
|
|
@@ -50,6 +50,7 @@ module Enjine
|
|
|
50
50
|
# whose ability costs mana isn't counted (it converts pool mana, CR 605.3a).
|
|
51
51
|
def source_units(index, excluded, purpose = nil)
|
|
52
52
|
by_source = Hash.new { |h, k| h[k] = [] }
|
|
53
|
+
repeats = {}
|
|
53
54
|
all_mana_sources(index).each do |id, ref|
|
|
54
55
|
next if excluded.include?(id)
|
|
55
56
|
|
|
@@ -59,11 +60,25 @@ module Enjine
|
|
|
59
60
|
|
|
60
61
|
# Abilities that tap the permanent granting them (CR 602.2b) make mana once among them all.
|
|
61
62
|
by_source[granter ? "granter:#{granter}" : id].concat(ability.outcomes(self, object(id)))
|
|
63
|
+
# CR 605.3a: one without {T} whose costs only remove counters from it can be activated again
|
|
64
|
+
repeats[id] = [repeats.fetch(id, 1), ability.repeats(object(id), mana_ability_costs(ref, ability))].max unless granter
|
|
65
|
+
end
|
|
66
|
+
units = by_source.flat_map do |key, options|
|
|
67
|
+
Array.new(options.map(&:size).max.to_i * repeats.fetch(key, 1)) { options.flatten.uniq }
|
|
62
68
|
end
|
|
63
|
-
units = by_source.values.flat_map { |options| Array.new(options.map(&:size).max) { options.flatten.uniq } }
|
|
64
69
|
as_any_type(units, purpose)
|
|
65
70
|
end
|
|
66
71
|
|
|
72
|
+
# A mana ability without {T} that removes counters from its source can be activated again after this activation
|
|
73
|
+
# (ManaAbility#repeats, CR 605.3a): the units of mana those later activations could add.
|
|
74
|
+
def units_after_activating(id, ref, ability)
|
|
75
|
+
left = ability.repeats(object(id), mana_ability_costs(ref, ability)) - 1
|
|
76
|
+
return [] unless left.positive? && ability.spend_only.nil?
|
|
77
|
+
|
|
78
|
+
outcomes = ability.outcomes(self, object(id))
|
|
79
|
+
Array.new(left * outcomes.map(&:size).max.to_i) { outcomes.flatten.uniq }
|
|
80
|
+
end
|
|
81
|
+
|
|
67
82
|
# Bipartite matching (augmenting paths): can every colored or hybrid symbol (the list of types
|
|
68
83
|
# that can pay it) get its own unit?
|
|
69
84
|
def match_colored(symbols, units)
|
|
@@ -141,9 +156,18 @@ module Enjine
|
|
|
141
156
|
from = mana_provenance(id) # before a cost sacrifices it (a Treasure)
|
|
142
157
|
record_activation!("source" => id, "ability" => ability_ref) if ability.per_turn
|
|
143
158
|
pay_from_pool!(index, ability.mana_cost, id) if ability.mana_cost
|
|
144
|
-
mana_ability_costs(ability_ref, ability).each
|
|
159
|
+
Mechanics::Costs.payment_order(mana_ability_costs(ability_ref, ability)).map(&:first).each do |cost| # CR 601.2h
|
|
160
|
+
cost.respond_to?(:pay_at_once!) ? cost.pay_at_once!(self, obj) : cost.pay!(self, obj)
|
|
161
|
+
end
|
|
145
162
|
produced = chosen || ability.outcomes(self, obj).first # CR 605.3b: a fixed amount is counted as it resolves
|
|
146
163
|
add_mana!(index, produced, id, restriction: ability.spend_only&.data, from: from)
|
|
164
|
+
add_mana_ability_counters!(index, obj, ability)
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# "Add {C}. Put a point counter on this" (CR 605.1a, 122.1): the counters go on the source if it's still there.
|
|
168
|
+
def add_mana_ability_counters!(index, obj, ability)
|
|
169
|
+
kind, amount = ability.add_counters
|
|
170
|
+
add_counters!(obj, kind, amount, by_player: index) if kind && state.battlefield.include?(obj.id)
|
|
147
171
|
end
|
|
148
172
|
|
|
149
173
|
# Whether the mana in the pool (unrestricted) can pay `cost` (a mana ability's mana cost, CR 605.3a).
|
|
@@ -94,7 +94,10 @@ module Enjine
|
|
|
94
94
|
ids = sources.map(&:first)
|
|
95
95
|
helpers = state.battlefield.count { |id| (obj = object(id)).controller == index && !obj.tapped && !ids.include?(id) }
|
|
96
96
|
pl.mana_pool.sum { |_, n| [n, 0].max } + pl.restricted_mana.size + (2 * helpers) +
|
|
97
|
-
sources.sum
|
|
97
|
+
sources.sum do |id, ref| # one without {T} may be activated again (ManaAbility#repeats, CR 605.3a)
|
|
98
|
+
ability = chars(id).ability(ref)
|
|
99
|
+
ability.outcomes(self, object(id)).map(&:size).max.to_i * ability.repeats(object(id), mana_ability_costs(ref, ability))
|
|
100
|
+
end
|
|
98
101
|
end
|
|
99
102
|
end
|
|
100
103
|
|