enjine 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +55 -1
- data/README.md +2 -1
- data/SUPPORTED.md +12 -9
- data/docs/ARCHITECTURE.md +2 -0
- data/docs/DESIGN.md +12 -5
- data/docs/MECHANICS_COVERAGE.md +33 -5
- data/docs/guides/api.md +51 -0
- data/docs/guides/card-data-format.md +43 -4
- data/docs/guides/deck-builder.md +18 -0
- data/docs/plans/commander.md +63 -0
- data/docs/plans/dsl-gaps.md +606 -0
- data/docs/plans/standard.md +3 -0
- data/docs/reference/abilities.md +33 -7
- data/docs/reference/costs.md +11 -1
- data/docs/reference/decisions.md +6 -2
- data/docs/reference/effects.md +30 -9
- data/docs/reference/triggers.md +3 -2
- data/lib/enjine/actions/cast.rb +2 -1
- data/lib/enjine/actions/special_action.rb +4 -2
- data/lib/enjine/card_definition.rb +24 -3
- data/lib/enjine/cli/text.rb +23 -1
- data/lib/enjine/cli.rb +2 -1
- data/lib/enjine/color_identity.rb +38 -0
- data/lib/enjine/decisions/commander_zone.rb +36 -0
- data/lib/enjine/deck.rb +73 -14
- data/lib/enjine/deck_builder.rb +62 -18
- data/lib/enjine/engine/casting/alt_casting.rb +19 -2
- data/lib/enjine/engine/casting/casting.rb +3 -3
- data/lib/enjine/engine/casting/costs.rb +5 -1
- data/lib/enjine/engine/casting/permissions.rb +3 -3
- data/lib/enjine/engine/characteristics.rb +0 -13
- data/lib/enjine/engine/commander.rb +125 -0
- data/lib/enjine/engine/damage.rb +1 -0
- data/lib/enjine/engine/defined_power_toughness.rb +30 -0
- data/lib/enjine/engine/emblems.rb +1 -1
- data/lib/enjine/engine/mana_sources.rb +8 -1
- data/lib/enjine/engine/pregame.rb +1 -0
- data/lib/enjine/engine/priority.rb +1 -0
- data/lib/enjine/engine/resolution.rb +1 -0
- data/lib/enjine/engine/rules.rb +1 -1
- data/lib/enjine/engine/state_based_actions.rb +1 -0
- data/lib/enjine/engine/triggers.rb +2 -1
- data/lib/enjine/engine/turn_history.rb +25 -1
- data/lib/enjine/engine/zones.rb +17 -6
- data/lib/enjine/format.rb +53 -0
- data/lib/enjine/fuzz.rb +17 -0
- data/lib/enjine/game.rb +4 -3
- data/lib/enjine/mechanics/abilities/additional_triggers.rb +23 -11
- data/lib/enjine/mechanics/abilities/cost_changes.rb +20 -7
- data/lib/enjine/mechanics/abilities/mana_ability.rb +21 -6
- data/lib/enjine/mechanics/abilities/stack_abilities.rb +13 -9
- data/lib/enjine/mechanics/abilities/static.rb +13 -7
- data/lib/enjine/mechanics/costs/sacrifice.rb +28 -2
- data/lib/enjine/mechanics/effects/become.rb +8 -4
- data/lib/enjine/mechanics/effects/choose_cards.rb +9 -7
- data/lib/enjine/mechanics/effects/delayed_triggers.rb +2 -1
- data/lib/enjine/mechanics/effects/search.rb +15 -8
- data/lib/enjine/mechanics/keywords/plot.rb +79 -0
- data/lib/enjine/mechanics/triggers/casting.rb +8 -6
- data/lib/enjine/mechanics/values.rb +82 -14
- data/lib/enjine/player.rb +2 -1
- data/lib/enjine/rules_monitor.rb +25 -1
- data/lib/enjine/setup.rb +10 -4
- data/lib/enjine/snapshot/player_checks.rb +47 -0
- data/lib/enjine/snapshot.rb +4 -1
- data/lib/enjine/state.rb +33 -14
- data/lib/enjine/version.rb +1 -1
- data/lib/enjine/view.rb +18 -1
- data/lib/enjine.rb +2 -0
- metadata +9 -1
data/docs/plans/standard.md
CHANGED
|
@@ -107,6 +107,9 @@ rotation is announced, drop the rotating sets from this table.
|
|
|
107
107
|
|
|
108
108
|
## Mechanics gaps
|
|
109
109
|
|
|
110
|
+
For the gaps behind deckfinder's DSL FAIL and PARTIAL cards, ranked by how many
|
|
111
|
+
cards each blocks, with a quick-wins list, see [dsl-gaps.md](dsl-gaps.md).
|
|
112
|
+
|
|
110
113
|
Census taken 2026-11-09 against `SUPPORTED.md` at this commit. It lists what can't
|
|
111
114
|
yet be written in the card DSL. Card lists came from the Scryfall API (main sets,
|
|
112
115
|
`unique=cards`, no bonus sheets) and were checked outside the repository; nothing
|
data/docs/reference/abilities.md
CHANGED
|
@@ -82,18 +82,25 @@ Rules: CR 305.2, CR 305.2a, CR 305.2b, CR 604.1
|
|
|
82
82
|
|
|
83
83
|
## additional_triggers
|
|
84
84
|
|
|
85
|
-
While this permanent is on the battlefield, a triggered ability of a permanent its controller controls
|
|
85
|
+
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.
|
|
86
86
|
|
|
87
|
-
Rules: CR 603.2d, CR 119.9
|
|
87
|
+
Rules: CR 603.2d, CR 119.9, CR 607.2d
|
|
88
88
|
|
|
89
89
|
| Parameter | Description |
|
|
90
90
|
| --- | --- |
|
|
91
91
|
| `cause` | you_gain_life |
|
|
92
|
+
| `of` | filter of the permanent whose ability triggers |
|
|
92
93
|
|
|
93
94
|
```json
|
|
94
95
|
{
|
|
95
96
|
"additional_triggers": {
|
|
96
|
-
"
|
|
97
|
+
"of": {
|
|
98
|
+
"creature": {
|
|
99
|
+
"subtypes": [
|
|
100
|
+
"ally"
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
}
|
|
97
104
|
}
|
|
98
105
|
}
|
|
99
106
|
```
|
|
@@ -397,13 +404,13 @@ Rules: CR 717.2a, CR 717.2b, CR 717.2d, CR 717.3, CR 602.5d
|
|
|
397
404
|
|
|
398
405
|
## cost_modifier
|
|
399
406
|
|
|
400
|
-
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) cost `reduce` less or `increase` more generic mana. `from` / `not_from`: only spells cast from (not from) that zone (hand | graveyard | exile | library | outside).
|
|
407
|
+
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` and `colors` narrow it: "Dragon spells", "red spells") cost `reduce` less or `increase` more generic mana. `from` / `not_from`: only spells cast from (not from) that zone (hand | graveyard | exile | library | outside).
|
|
401
408
|
|
|
402
409
|
Rules: CR 601.2f, CR 118.7a, CR 604.1, CR 601.2a
|
|
403
410
|
|
|
404
411
|
| Parameter | Description |
|
|
405
412
|
| --- | --- |
|
|
406
|
-
| `spells` | {"any_of": [types], "not": [types]} (optional) |
|
|
413
|
+
| `spells` | {"any_of": [types], "not": [types], "subtypes": [subtypes], "colors": [colors]} (optional) |
|
|
407
414
|
| `caster` | you | opponent | any |
|
|
408
415
|
| `reduce` | amount |
|
|
409
416
|
| `increase` | amount |
|
|
@@ -1080,7 +1087,7 @@ Rules: CR 606.3, CR 606.4, CR 606.5, CR 602.2b
|
|
|
1080
1087
|
|
|
1081
1088
|
| Parameter | Description |
|
|
1082
1089
|
| --- | --- |
|
|
1083
|
-
| `cost` | integer, e.g. 1 for +1 or -2 |
|
|
1090
|
+
| `cost` | integer, e.g. 1 for +1 or -2; or "-X" (X is announced, at most its loyalty) |
|
|
1084
1091
|
| `targets` | list of target filters |
|
|
1085
1092
|
| `effects` | list of effects |
|
|
1086
1093
|
|
|
@@ -1107,7 +1114,7 @@ Rules: CR 606.3, CR 606.4, CR 606.5, CR 602.2b
|
|
|
1107
1114
|
|
|
1108
1115
|
## mana
|
|
1109
1116
|
|
|
1110
|
-
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 ...".
|
|
1117
|
+
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."
|
|
1111
1118
|
|
|
1112
1119
|
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
|
|
1113
1120
|
|
|
@@ -1120,6 +1127,7 @@ Rules: CR 605.1a, CR 605.3a, CR 605.3b, CR 106.1a, CR 106.4, CR 106.6, CR 607.2d
|
|
|
1120
1127
|
| `colors` | list of colors to choose from (default all five) |
|
|
1121
1128
|
| `spend_only` | {"spells": card spec, "abilities": card spec, "from" | "not_from": zone} |
|
|
1122
1129
|
| `only_if` | condition: it can be activated only while it holds (CR 602.5b) |
|
|
1130
|
+
| `limit` | "once_each_turn" (CR 602.5b) |
|
|
1123
1131
|
|
|
1124
1132
|
```json
|
|
1125
1133
|
{
|
|
@@ -1264,6 +1272,24 @@ Rules: CR 702.11c, CR 115.4, CR 508.1c, CR 402.2, CR 514.1, CR 615.1, CR 615.1a,
|
|
|
1264
1272
|
}
|
|
1265
1273
|
```
|
|
1266
1274
|
|
|
1275
|
+
## plot
|
|
1276
|
+
|
|
1277
|
+
Plot `cost`: during your main phase, while the stack is empty, you may pay `cost` and exile this card from your hand (special action `{type: "special_action"}`). It becomes plotted: on a later turn you may cast it from exile without paying its mana cost, during your main phase while the stack is empty (cast option `via: "plotted"`).
|
|
1278
|
+
|
|
1279
|
+
Rules: CR 702.170a, CR 702.170b, CR 702.170d, CR 116.2k
|
|
1280
|
+
|
|
1281
|
+
| Parameter | Description |
|
|
1282
|
+
| --- | --- |
|
|
1283
|
+
| `cost` | mana cost string |
|
|
1284
|
+
|
|
1285
|
+
```json
|
|
1286
|
+
{
|
|
1287
|
+
"plot": {
|
|
1288
|
+
"cost": "{1}{R}"
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
```
|
|
1292
|
+
|
|
1267
1293
|
## prevent_damage
|
|
1268
1294
|
|
|
1269
1295
|
While this permanent is on the battlefield, all damage from sources in `by` to recipients in `to` (damage scopes as in damage_replacement, both optional; `combat`: combat | noncombat) is prevented. "To and by this creature" is two of them. `then`: effects right after it prevents damage ("prevent that damage and put that many +1/+1 counters on him"), reading {"triggering": "amount"} (the damage prevented), "object" (the source) and "player" (its controller).
|
data/docs/reference/costs.md
CHANGED
|
@@ -133,6 +133,16 @@ Rules: CR 406.1, CR 601.2h, CR 602.2b, CR 118.3
|
|
|
133
133
|
}
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
+
## exile_self
|
|
137
|
+
|
|
138
|
+
Exile the permanent the ability belongs to ("Exile this enchantment: ...").
|
|
139
|
+
|
|
140
|
+
Rules: CR 406.1, CR 602.2b, CR 118.3
|
|
141
|
+
|
|
142
|
+
```json
|
|
143
|
+
"exile_self"
|
|
144
|
+
```
|
|
145
|
+
|
|
136
146
|
## exile_self_from_graveyard
|
|
137
147
|
|
|
138
148
|
Exile this card from your graveyard. An ability with this cost is activated from your graveyard.
|
|
@@ -256,7 +266,7 @@ Rules: CR 701.21a, CR 602.2b, CR 118.3
|
|
|
256
266
|
|
|
257
267
|
## sacrifice_permanent
|
|
258
268
|
|
|
259
|
-
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`).
|
|
269
|
+
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`).
|
|
260
270
|
|
|
261
271
|
Rules: CR 701.21a, CR 601.2h, CR 602.2b, CR 118.3, CR 608.2h
|
|
262
272
|
|
data/docs/reference/decisions.md
CHANGED
|
@@ -40,6 +40,10 @@ While casting/activating: `{type: "count", count: n}` announces how many targets
|
|
|
40
40
|
|
|
41
41
|
While casting/activating a spell or ability with {X} in its cost: `{type: "x", value: n}` announces X (0 up to `max`, the most the available mana could pay for); `{type: "cancel"}` rewinds.
|
|
42
42
|
|
|
43
|
+
## commander_zone
|
|
44
|
+
|
|
45
|
+
Your commander is in a graveyard, exile, hand or library: `{type: "command", object: id}` puts it into the command zone, `{type: "stay", object: id}` leaves it where it is (CR 903.9).
|
|
46
|
+
|
|
43
47
|
## declare_attackers
|
|
44
48
|
|
|
45
49
|
Declare one attacker: `{type: "attack", object: id, target: ref}` (the defending player or one of their planeswalkers), or `{type: "done"}` (withheld while a creature that attacks each combat if able could still attack, CR 508.1d, or while a creature that can't attack alone attacks alone, CR 506.5; then `{type: "withdraw", object: id}` undoes an attack).
|
|
@@ -96,7 +100,7 @@ Untap step: `{type: "untap", object: id}` or `{type: "keep_tapped", object: id}`
|
|
|
96
100
|
|
|
97
101
|
- `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).
|
|
98
102
|
- `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.
|
|
99
|
-
- `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). 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.
|
|
103
|
+
- `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.
|
|
100
104
|
- `pass` — `{type: "pass"}` — pass priority. When all players pass in succession with an empty stack, the step ends (CR 117.4).
|
|
101
105
|
- `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).
|
|
102
|
-
- `special_action` — `{type: "special_action", object: id, ability: ref}` — a special action of a card in your hand: foretell (during your turn, pay {2} and exile it face down, CR 116.2h) or suspend (when you could begin to cast it, pay its suspend cost and exile it with time counters, CR 116.2f).
|
|
106
|
+
- `special_action` — `{type: "special_action", object: id, ability: ref}` — a special action of a card in your hand: foretell (during your turn, pay {2} and exile it face down, CR 116.2h) or suspend (when you could begin to cast it, pay its suspend cost and exile it with time counters, CR 116.2f) or plot (in your main phase with an empty stack, pay its plot cost and exile it, CR 116.2k).
|
data/docs/reference/effects.md
CHANGED
|
@@ -224,7 +224,7 @@ Rules: CR 701.3a, CR 701.3b, CR 701.3c, CR 301.5c
|
|
|
224
224
|
|
|
225
225
|
## become
|
|
226
226
|
|
|
227
|
-
Each referenced permanent becomes what the parameters say, for `duration` (end_of_turn, default; indefinite: as long as it stays on the battlefield; while_source_on_battlefield: for as long as this effect's source remains on the battlefield; while_you_control_source: for as long as you control it): it has the card `types`, `supertypes` and `subtypes` in addition to its other types (layer 4, "becomes an artifact creature"), its creature types are exactly `creature_types` (layer 4), its colors are `colors` (layer 5), with `loses_abilities: true` it loses all the abilities it had (layer 6; abilities granted later, keyword counters put on it later and this effect's own `keywords` and `abilities` stay, CR 613.7), it has the `keywords` and `abilities` (layer 6: triggered, activated, mana, play_from or additional_land_plays abilities) and its base power and toughness are `base_power_toughness` (layer 7b). A permanent that becomes a creature has its printed power and toughness (a Vehicle's), or 0/0.
|
|
227
|
+
Each referenced permanent becomes what the parameters say, for `duration` (end_of_turn, default; until_your_next_turn: until your next turn begins; indefinite: as long as it stays on the battlefield; while_source_on_battlefield: for as long as this effect's source remains on the battlefield; while_you_control_source: for as long as you control it): it has the card `types`, `supertypes` and `subtypes` in addition to its other types (layer 4, "becomes an artifact creature"), its creature types are exactly `creature_types` (layer 4), its colors are `colors` (layer 5), with `loses_abilities: true` it loses all the abilities it had (layer 6; abilities granted later, keyword counters put on it later and this effect's own `keywords` and `abilities` stay, CR 613.7), it has the `keywords` and `abilities` (layer 6: triggered, activated, mana, play_from or additional_land_plays abilities) and its base power and toughness are `base_power_toughness` (layer 7b). A permanent that becomes a creature has its printed power and toughness (a Vehicle's), or 0/0.
|
|
228
228
|
|
|
229
229
|
Rules: CR 611.2a, CR 611.2b, CR 611.2c, CR 613.1d, CR 613.1e, CR 613.1f, CR 613.4b, CR 613.7b, CR 205.1a, CR 205.1b, CR 301.7b, CR 514.2
|
|
230
230
|
|
|
@@ -239,7 +239,7 @@ Rules: CR 611.2a, CR 611.2b, CR 611.2c, CR 613.1d, CR 613.1e, CR 613.1f, CR 613.
|
|
|
239
239
|
| `keywords` | list of keywords it gains |
|
|
240
240
|
| `base_power_toughness` | {"power": n, "toughness": n} |
|
|
241
241
|
| `abilities` | list of abilities it gains |
|
|
242
|
-
| `duration` | end_of_turn | indefinite | while_source_on_battlefield | while_you_control_source |
|
|
242
|
+
| `duration` | end_of_turn | until_your_next_turn | indefinite | while_source_on_battlefield | while_you_control_source |
|
|
243
243
|
| `to` | selector |
|
|
244
244
|
|
|
245
245
|
```json
|
|
@@ -461,9 +461,9 @@ Rules: CR 205.2a, CR 607.2d, CR 608.2c
|
|
|
461
461
|
|
|
462
462
|
## choose_cards
|
|
463
463
|
|
|
464
|
-
You choose `count` (default 1; "any": any number) cards matching `for` from `from`: a selector (e.g. {"result": 0}, the cards an earlier effect milled) or a player's zone, {"hand": selector} / {"graveyard": selector}. `optional`: you may choose fewer. Then they are put into `put` (`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.
|
|
464
|
+
You choose `count` (default 1; "any": any number) cards matching `for` from `from`: a selector (e.g. {"result": 0}, the cards an earlier effect milled) or a player's zone, {"hand": selector} / {"graveyard": selector}. `optional`: you may choose fewer. Then they are put into `put` (`discard`: from a hand, its owner discards them; `tapped` onto the battlefield, under your control; exiled cards `link`ed to the source). `look`: you look at the whole zone first; `reveal`: "chosen" reveals what you chose, "all" the whole set. `then` runs if a card was chosen, `otherwise` if none was ("if you can't"). `random: true`: the cards are picked at random (the game's random number generator) instead of chosen.
|
|
465
465
|
|
|
466
|
-
Rules: CR 701.20a, CR 701.20e, CR 400.7j, CR 608.2c, CR 607.2a, CR 118.12, CR 701.9b
|
|
466
|
+
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
|
|
467
467
|
|
|
468
468
|
| Parameter | Description |
|
|
469
469
|
| --- | --- |
|
|
@@ -471,7 +471,7 @@ Rules: CR 701.20a, CR 701.20e, CR 400.7j, CR 608.2c, CR 607.2a, CR 118.12, CR 70
|
|
|
471
471
|
| `for` | card spec |
|
|
472
472
|
| `count` | integer or "any" |
|
|
473
473
|
| `optional` | boolean |
|
|
474
|
-
| `put` | hand | graveyard | exile | battlefield | library_top | library_bottom |
|
|
474
|
+
| `put` | hand | graveyard | exile | battlefield | library_top | library_bottom | discard |
|
|
475
475
|
| `tapped` | boolean |
|
|
476
476
|
| `link` | boolean |
|
|
477
477
|
| `look` | boolean |
|
|
@@ -1361,14 +1361,15 @@ Rules: CR 119.3
|
|
|
1361
1361
|
|
|
1362
1362
|
## grant
|
|
1363
1363
|
|
|
1364
|
-
Each referenced permanent (or spell on the stack) gains the `keywords` until end of turn.
|
|
1364
|
+
Each referenced permanent (or spell on the stack) gains the `keywords` until end of turn (`duration: "until_your_next_turn"`: until its controller's next turn begins).
|
|
1365
1365
|
|
|
1366
|
-
Rules: CR 611.2a, CR 611.2c, CR 613.1f, CR 514.2
|
|
1366
|
+
Rules: CR 611.2a, CR 611.2c, CR 613.1f, CR 514.2, CR 500.1
|
|
1367
1367
|
|
|
1368
1368
|
| Parameter | Description |
|
|
1369
1369
|
| --- | --- |
|
|
1370
1370
|
| `keywords` | list of keywords |
|
|
1371
1371
|
| `to` | selector |
|
|
1372
|
+
| `duration` | end_of_turn | until_your_next_turn |
|
|
1372
1373
|
|
|
1373
1374
|
```json
|
|
1374
1375
|
{
|
|
@@ -1657,6 +1658,26 @@ Rules: CR 702.11c, CR 115.4, CR 508.1c, CR 402.2, CR 514.1, CR 615.1, CR 615.1a,
|
|
|
1657
1658
|
}
|
|
1658
1659
|
```
|
|
1659
1660
|
|
|
1661
|
+
## plot
|
|
1662
|
+
|
|
1663
|
+
Each referenced card or spell is exiled (if it isn't already) and becomes plotted: its owner may cast it from exile without paying its mana cost during their main phase while the stack is empty, on any later turn (cast option `via: "plotted"`).
|
|
1664
|
+
|
|
1665
|
+
Rules: CR 702.170c, CR 702.170d, CR 406.1
|
|
1666
|
+
|
|
1667
|
+
| Parameter | Description |
|
|
1668
|
+
| --- | --- |
|
|
1669
|
+
| `to` | selector (a spell, a card, or an exiled card such as {"result": 0}) |
|
|
1670
|
+
|
|
1671
|
+
```json
|
|
1672
|
+
{
|
|
1673
|
+
"plot": {
|
|
1674
|
+
"to": {
|
|
1675
|
+
"target": 0
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
```
|
|
1680
|
+
|
|
1660
1681
|
## prepare
|
|
1661
1682
|
|
|
1662
1683
|
Each referenced permanent (default: this one) becomes prepared, if it has a prepare spell and isn't prepared already: its controller creates a copy of the prepare spell in exile and may cast that copy while the permanent stays prepared. Casting it unprepares the permanent.
|
|
@@ -2054,7 +2075,7 @@ Rules: CR 701.22a
|
|
|
2054
2075
|
|
|
2055
2076
|
## search_library
|
|
2056
2077
|
|
|
2057
|
-
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
|
|
2078
|
+
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").
|
|
2058
2079
|
|
|
2059
2080
|
Rules: CR 701.23a, CR 701.23b, CR 701.23d, CR 701.23e, CR 701.20a, CR 701.24a, CR 701.24b, CR 118.12, CR 110.2a
|
|
2060
2081
|
|
|
@@ -2062,7 +2083,7 @@ Rules: CR 701.23a, CR 701.23b, CR 701.23d, CR 701.23e, CR 701.20a, CR 701.24a, C
|
|
|
2062
2083
|
| --- | --- |
|
|
2063
2084
|
| `for` | card spec: "card" (default), {"types"|"subtypes"|"supertypes": [...], "name": "..."} or {"any_of": [spec, ...]} |
|
|
2064
2085
|
| `count` | integer (default 1), "any" (any number), "x" or an amount ("up to that many") |
|
|
2065
|
-
| `put` | "hand" (default) or "
|
|
2086
|
+
| `put` | "hand" (default), "battlefield", "graveyard" or "library_top" (count 1) |
|
|
2066
2087
|
| `tapped` | true: the cards enter tapped (with put: battlefield) |
|
|
2067
2088
|
| `counters` | {counter name: n}: the cards enter with these counters (with put: battlefield) |
|
|
2068
2089
|
| `reveal` | true: reveal the found cards |
|
data/docs/reference/triggers.md
CHANGED
|
@@ -27,9 +27,9 @@ Rules: CR 603.2, CR 603.3b, CR 508.1, CR 707.10
|
|
|
27
27
|
|
|
28
28
|
## activates_ability
|
|
29
29
|
|
|
30
|
-
A player (`controller`: you (default) | opponent | any) activates an ability that isn't a mana ability. `source`: optional filter on the source's card; `name: "chosen"`: only a source with the name chosen as this permanent entered. `exhaust: true`: only an exhaust ability ("whenever you activate an exhaust ability", CR 702.177). `boast: true`: only a boast ability ("whenever a creature you control boasts", CR 702.142b).
|
|
30
|
+
A player (`controller`: you (default) | opponent | any) activates an ability that isn't a mana ability. `source`: optional filter on the source's card; `name: "chosen"`: only a source with the name chosen as this permanent entered. `exhaust: true`: only an exhaust ability ("whenever you activate an exhaust ability", CR 702.177). `boast: true`: only a boast ability ("whenever a creature you control boasts", CR 702.142b). `loyalty: true`: only a loyalty ability (CR 606).
|
|
31
31
|
|
|
32
|
-
Rules: CR 602.2, CR 605.1a, CR 603.2, CR 201.4, CR 702.177a, CR 702.142b
|
|
32
|
+
Rules: CR 602.2, CR 605.1a, CR 603.2, CR 201.4, CR 702.177a, CR 702.142b, CR 606.1
|
|
33
33
|
|
|
34
34
|
| Parameter | Description |
|
|
35
35
|
| --- | --- |
|
|
@@ -38,6 +38,7 @@ Rules: CR 602.2, CR 605.1a, CR 603.2, CR 201.4, CR 702.177a, CR 702.142b
|
|
|
38
38
|
| `name` | "chosen" |
|
|
39
39
|
| `exhaust` | true: only exhaust abilities |
|
|
40
40
|
| `boast` | true: only boast abilities |
|
|
41
|
+
| `loyalty` | true: only loyalty abilities |
|
|
41
42
|
|
|
42
43
|
```json
|
|
43
44
|
{
|
data/lib/enjine/actions/cast.rb
CHANGED
|
@@ -9,7 +9,8 @@ module Enjine
|
|
|
9
9
|
'`{type: "cast", object: id}` — start casting a card from your hand (CR 601.2). ' \
|
|
10
10
|
'`{type: "cast", object: id, via: method}` casts a card from another zone (graveyard, exile, the top ' \
|
|
11
11
|
"of your library) by the permission or alternative cost `via` names, e.g. beam me up (CR 601.3, " \
|
|
12
|
-
|
|
12
|
+
'702.196). In a Commander game `via: "command"` casts your commander from the command zone, its cost ' \
|
|
13
|
+
"including the commander tax (CR 903.8). A card outside the game is named `\"outside:<card id>\"` (CR 400.11b). " \
|
|
13
14
|
'`{type: "cast", object: id, face: 1}` casts another face of a card in your hand: a modal double-faced ' \
|
|
14
15
|
"card's back face, an Adventure or an Omen (CR 712.8b, 716.3, 721.3). Offered only when timing " \
|
|
15
16
|
"allows, targets exist and enough mana is available."
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
module Enjine
|
|
4
4
|
module Actions
|
|
5
|
-
# CR 116.2f, 116.2h: special actions that pay a cost and exile a card from your hand (foretell,
|
|
5
|
+
# CR 116.2f, 116.2h, 116.2k: special actions that pay a cost and exile a card from your hand (foretell,
|
|
6
|
+
# suspend, plot).
|
|
6
7
|
# The card's ability names the cost, when the action is allowed and what it does; the cost is paid in a
|
|
7
8
|
# "pay" frame (Engine::Payment#begin_payment!), which can be cancelled, and the player gets priority
|
|
8
9
|
# again afterwards (CR 116.3).
|
|
@@ -10,7 +11,8 @@ module Enjine
|
|
|
10
11
|
def self.doc
|
|
11
12
|
'`{type: "special_action", object: id, ability: ref}` — a special action of a card in your hand: foretell ' \
|
|
12
13
|
"(during your turn, pay {2} and exile it face down, CR 116.2h) or suspend (when you could begin to cast it, " \
|
|
13
|
-
"pay its suspend cost and exile it with time counters, CR 116.2f)
|
|
14
|
+
"pay its suspend cost and exile it with time counters, CR 116.2f) or plot (in your main phase with an empty " \
|
|
15
|
+
"stack, pay its plot cost and exile it, CR 116.2k)."
|
|
14
16
|
end
|
|
15
17
|
|
|
16
18
|
def self.options(engine, index)
|
|
@@ -11,7 +11,8 @@ module Enjine
|
|
|
11
11
|
# Enjine.registry. Anything unknown is reported (with its path) in a single
|
|
12
12
|
# InvalidCardDefinition error.
|
|
13
13
|
class CardDefinition
|
|
14
|
-
KEYS = %w[name mana_cost colors types supertypes subtypes keywords power toughness loyalty abilities rules_text deck_limit
|
|
14
|
+
KEYS = %w[name mana_cost colors types supertypes subtypes keywords power toughness loyalty abilities rules_text deck_limit
|
|
15
|
+
color_identity].freeze
|
|
15
16
|
# Optional catalogue data beside the rules data, never read by the rules: rarity, and the set code and
|
|
16
17
|
# collector number printed on the card ({"set" => "trk", "number" => "12"}).
|
|
17
18
|
PRINT_KEYS = %w[rarity printing].freeze
|
|
@@ -63,6 +64,7 @@ module Enjine
|
|
|
63
64
|
@rules_data = @source
|
|
64
65
|
@source = deep_freeze(@source.merge("rarity" => @rarity, "printing" => @printing).compact) if @rarity || @printing
|
|
65
66
|
@printed_characteristics = Characteristics.printed(self) if errors.empty?
|
|
67
|
+
@color_identity = ColorIdentity.of(self) if face.nil? && errors.empty? # a face has its card's (see #color_identity)
|
|
66
68
|
freeze
|
|
67
69
|
end
|
|
68
70
|
|
|
@@ -79,6 +81,7 @@ module Enjine
|
|
|
79
81
|
@keywords, keyword_modules = read_names(card, "keywords", :keyword, errors)
|
|
80
82
|
@colors = read_colors(card, errors)
|
|
81
83
|
@deck_limit = read_deck_limit(card, errors)
|
|
84
|
+
@declared_color_identity = read_color_identity(card, errors)
|
|
82
85
|
@power, @power_amount = read_pt(card, "power", errors)
|
|
83
86
|
@toughness, @toughness_amount = read_pt(card, "toughness", errors)
|
|
84
87
|
@loyalty = read_stat(card, "loyalty", errors)
|
|
@@ -167,6 +170,12 @@ module Enjine
|
|
|
167
170
|
def planeswalker? = @planeswalker
|
|
168
171
|
def deck_limit_exempt? = @deck_limit_exempt
|
|
169
172
|
|
|
173
|
+
# The colors a Commander deck must hold to include this card (CR 903.4), WUBRG-ordered, over every face.
|
|
174
|
+
def color_identity = @front ? @front.color_identity : @color_identity
|
|
175
|
+
|
|
176
|
+
# The identity this face states by hand ("color_identity": ["R"]), nil when derived from its data.
|
|
177
|
+
attr_reader :declared_color_identity
|
|
178
|
+
|
|
170
179
|
# Most copies a constructed deck may hold (CR 100.2a): nil for any number (basic lands, or a card that
|
|
171
180
|
# says "a deck can have any number of cards named ~").
|
|
172
181
|
def deck_limit = @deck_limit_exempt ? nil : (@deck_limit || Deck::MAX_COPIES)
|
|
@@ -319,6 +328,16 @@ module Enjine
|
|
|
319
328
|
ok ? Mana::COLORS.select { |c| list.map { it.to_s.upcase }.include?(c.to_s) }.freeze : [].freeze
|
|
320
329
|
end
|
|
321
330
|
|
|
331
|
+
# "color_identity": colors W U B R G; states a face's color identity instead of deriving it (CR 903.4).
|
|
332
|
+
def read_color_identity(card, errors)
|
|
333
|
+
return nil unless card.key?("color_identity")
|
|
334
|
+
|
|
335
|
+
list = card["color_identity"]
|
|
336
|
+
ok = list.is_a?(Array) && list.all? { Mana::COLORS.include?(it.to_s.upcase.to_sym) }
|
|
337
|
+
errors << "color_identity: must be a list of W, U, B, R, G" unless ok
|
|
338
|
+
ok ? Mana::COLORS.select { |c| list.map { it.to_s.upcase }.include?(c.to_s) }.freeze : nil
|
|
339
|
+
end
|
|
340
|
+
|
|
322
341
|
# CR 100.2a: "a deck can have any number of cards named ~" is `"deck_limit": "any"`; "up to seven" is 7.
|
|
323
342
|
# Reads the PRINT_KEYS of a whole card; returns the card without them.
|
|
324
343
|
def read_print(card, errors)
|
|
@@ -415,10 +434,12 @@ module Enjine
|
|
|
415
434
|
out["loyalty"] = @loyalty unless @loyalty.nil?
|
|
416
435
|
out["abilities"] = Snapshot.deep_stringify(card["abilities"]) if card["abilities"].is_a?(Array) && !card["abilities"].empty?
|
|
417
436
|
out["rules_text"] = @rules_text if @rules_text
|
|
418
|
-
out
|
|
419
|
-
deep_freeze(out)
|
|
437
|
+
deep_freeze(out.merge!(deck_building_h))
|
|
420
438
|
end
|
|
421
439
|
|
|
440
|
+
# What deck construction reads beyond the card's characteristics (CR 100.2a, 903.4).
|
|
441
|
+
def deck_building_h = { "deck_limit" => @deck_limit, "color_identity" => @declared_color_identity&.map(&:to_s) }.compact
|
|
442
|
+
|
|
422
443
|
# An integer, or the amount of a characteristic-defining ability as given.
|
|
423
444
|
def normalized_stat(card, key) = card[key].is_a?(Hash) ? Snapshot.deep_stringify(card[key]) : instance_variable_get("@#{key}")
|
|
424
445
|
|
data/lib/enjine/cli/text.rb
CHANGED
|
@@ -79,6 +79,7 @@ module Enjine
|
|
|
79
79
|
lines << " Lands: #{lands.empty? ? "-" : lands.map { permanent(it) }.join(", ")}"
|
|
80
80
|
lines << " Permanents: #{"-" if others.empty?}"
|
|
81
81
|
others.each { lines << " #{permanent(it)}" }
|
|
82
|
+
lines.concat(commander_lines(view, player)) if player["commander"]
|
|
82
83
|
lines << " Hand: #{player["hand"].map { card(it) }.join(", ")}" if player["hand"]
|
|
83
84
|
if player["library"]
|
|
84
85
|
lines << " Library (top first): #{player["library"].first(5).map do
|
|
@@ -89,6 +90,23 @@ module Enjine
|
|
|
89
90
|
lines
|
|
90
91
|
end
|
|
91
92
|
|
|
93
|
+
# A Commander game: the commander, where it waits, its tax and the damage it has taken from commanders.
|
|
94
|
+
def commander_lines(view, player)
|
|
95
|
+
waiting = view["command"].select { it["owner"] == player["name"] && it["kind"] != "emblem" }
|
|
96
|
+
damage = player["commander_damage"].map { |name, n| "#{n} from #{name}" }.join(", ")
|
|
97
|
+
[" Commander: #{player["commander"]}#{" [#{waiting.first["id"]}] in the command zone" unless waiting.empty?}" \
|
|
98
|
+
"#{" · tax {#{player["commander_tax"]}}" if player["commander_tax"].positive?}" \
|
|
99
|
+
"#{" · commander damage taken: #{damage}" unless damage.empty?}"]
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# " from the command zone (+{2})" on a cast option of a commander.
|
|
103
|
+
def commander_tax(opt)
|
|
104
|
+
return "" unless opt[:via] == "command"
|
|
105
|
+
|
|
106
|
+
tax = Engine::Commander::TAX * @game.state.players[@game.state.object(opt[:object]).owner].commander_casts.to_i
|
|
107
|
+
" from the command zone#{" (+{#{tax}})" if tax.positive?}"
|
|
108
|
+
end
|
|
109
|
+
|
|
92
110
|
def permanent(obj)
|
|
93
111
|
parts = [obj["name"]]
|
|
94
112
|
parts << "#{obj["power"]}/#{obj["toughness"]}" if obj.key?("power")
|
|
@@ -120,6 +138,7 @@ module Enjine
|
|
|
120
138
|
when "bottom" then " — put #{decision.details["count"]} more on the bottom"
|
|
121
139
|
when "assign_damage" then " — #{name_of(decision.details["attacker"])}: #{decision.details["remaining"]} damage left"
|
|
122
140
|
when "choose_target" then " — target ##{decision.details["index"] + 1}"
|
|
141
|
+
when "commander_zone" then " — #{name_of(decision.details["object"])} (your commander)"
|
|
123
142
|
when "choose_target_count" then " — how many for target ##{decision.details["index"] + 1}"
|
|
124
143
|
else ""
|
|
125
144
|
end
|
|
@@ -132,7 +151,9 @@ module Enjine
|
|
|
132
151
|
case opt[:type]
|
|
133
152
|
when "pass" then "Pass priority"
|
|
134
153
|
when "play_land" then "Play land #{name_of(opt[:object])}"
|
|
135
|
-
when "cast" then "Cast #{name_of(opt[:object])} #{cost_of(opt[:object])}".rstrip
|
|
154
|
+
when "cast" then "Cast #{name_of(opt[:object])} #{cost_of(opt[:object])}#{commander_tax(opt)}".rstrip
|
|
155
|
+
when "command" then "Put #{name_of(opt[:object])} into the command zone"
|
|
156
|
+
when "stay" then "Leave #{name_of(opt[:object])} where it is"
|
|
136
157
|
when "activate" then "Activate #{name_of(opt[:object])}: #{ability_text(opt[:object], opt[:ability])}"
|
|
137
158
|
when "special_action" then "#{ability_text(opt[:object], opt[:ability])}: #{name_of(opt[:object])} (special action)"
|
|
138
159
|
when "activate_mana"
|
|
@@ -260,6 +281,7 @@ module Enjine
|
|
|
260
281
|
when "sba_toughness" then "#{what} dies (0 toughness)"
|
|
261
282
|
when "sba_loyalty" then "#{what} is put into the graveyard (0 loyalty)"
|
|
262
283
|
when "countered" then "#{what} is countered"
|
|
284
|
+
when "commander" then "#{ev["owner"]} puts #{what} into the command zone"
|
|
263
285
|
when "mulligan_bottom" then "#{ev["owner"]} puts #{what} on the bottom of their library (mulligan)"
|
|
264
286
|
else "#{ev["owner"]}'s #{what}: #{ev["from"]} → #{ev["to"]} (#{ev["reason"]})"
|
|
265
287
|
end
|
data/lib/enjine/cli.rb
CHANGED
|
@@ -68,6 +68,7 @@ module Enjine
|
|
|
68
68
|
o.on("--random-deck [SPEC]", "Print a random deck from --pool as JSON, e.g. \"colors=WU seed=7\"") do
|
|
69
69
|
@options[:random_deck] = it
|
|
70
70
|
end
|
|
71
|
+
o.on("--format NAME", "constructed (default) or duel_commander: decks then name a \"commander\"") { @options[:format] = it }
|
|
71
72
|
o.on("--names A,B", Array, "Player names (default alice,bob)") { @options[:names] = it }
|
|
72
73
|
o.on("--validate FILE", "Validate a JSON array of card data blocks; prints a JSON report") { @options[:validate] = it }
|
|
73
74
|
o.on("--verify DIR", "Validate and play-test every card in DIR's JSON files; exit 1 on any problem") do
|
|
@@ -161,7 +162,7 @@ module Enjine
|
|
|
161
162
|
def new_game
|
|
162
163
|
decks = [@options[:deck1], @options[:deck2]].each_with_index.map { |deck, i| deck_for(deck, i) }
|
|
163
164
|
players = @options[:names].zip(decks).map { |name, deck| Player.new(name: name, deck: deck) }
|
|
164
|
-
@setup = Setup.new(*players)
|
|
165
|
+
@setup = Setup.new(*players, format: @options.fetch(:format, Format::CONSTRUCTED))
|
|
165
166
|
@setup.new_game(seed: @options[:seed])
|
|
166
167
|
end
|
|
167
168
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Enjine
|
|
4
|
+
# A card's color identity (CR 903.4): the colors of the mana symbols in its mana cost and rules, plus its
|
|
5
|
+
# color indicator, characteristic-defining colors and the mana its basic land types make (CR 903.5d), over
|
|
6
|
+
# every face of the card (CR 903.4d-e). Reminder text doesn't count (CR 903.4c), and the engine never reads
|
|
7
|
+
# text: the symbols are found in the card's *data* (costs, produced mana, kicker, ...), not in `rules_text`.
|
|
8
|
+
# A face may state its identity by hand with "color_identity" instead, for the odd card the data can't tell.
|
|
9
|
+
module ColorIdentity
|
|
10
|
+
SKIPPED_KEYS = %w[name rules_text rarity printing color_identity].freeze
|
|
11
|
+
BASIC_LAND_COLORS = { plains: :W, island: :U, swamp: :B, mountain: :R, forest: :G }.freeze
|
|
12
|
+
|
|
13
|
+
module_function
|
|
14
|
+
|
|
15
|
+
# WUBRG-ordered colors of a whole card.
|
|
16
|
+
def of(definition)
|
|
17
|
+
colors = definition.faces.flat_map { face_colors(it) }
|
|
18
|
+
Mana::COLORS.select { colors.include?(it) }.freeze
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def face_colors(face)
|
|
22
|
+
face.declared_color_identity || (face.colors + land_colors(face) + symbols(face.source.except("faces")))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# The colors of the mana a basic land type makes (CR 305.6, 903.5d).
|
|
26
|
+
def land_colors(face) = face.subtypes.filter_map { BASIC_LAND_COLORS[it] }
|
|
27
|
+
|
|
28
|
+
# The colors named by every mana symbol in the card's data, hybrid and monocolored hybrid symbols included.
|
|
29
|
+
def symbols(node)
|
|
30
|
+
case node
|
|
31
|
+
when Hash then node.flat_map { |key, value| SKIPPED_KEYS.include?(key) ? [] : symbols(value) }
|
|
32
|
+
when Array then node.flat_map { symbols(it) }
|
|
33
|
+
when String then node.scan(Mana::SYMBOL).flatten.flat_map { it.scan(/[WUBRG]/).map(&:to_sym) }
|
|
34
|
+
else []
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Enjine
|
|
4
|
+
module Decisions
|
|
5
|
+
# CR 903.9: a commander went to a graveyard, exile, hand or library; its owner chooses whether to put it
|
|
6
|
+
# into the command zone instead (Engine::Commander).
|
|
7
|
+
class CommanderZone < Base
|
|
8
|
+
def self.doc
|
|
9
|
+
'Your commander is in a graveyard, exile, hand or library: `{type: "command", object: id}` puts it into ' \
|
|
10
|
+
'the command zone, `{type: "stay", object: id}` leaves it where it is (CR 903.9).'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.options(_engine, pending)
|
|
14
|
+
[{ type: "command", object: pending["object"] }, { type: "stay", object: pending["object"] }]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.submit(engine, _pending, option) = engine.choose_commander_zone!(option[:type] == "command")
|
|
18
|
+
end
|
|
19
|
+
register("commander_zone", CommanderZone)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
module Frames
|
|
23
|
+
# The owner's choice to send a commander back to the command zone (CR 903.9), before priority.
|
|
24
|
+
class CommanderZone < Base
|
|
25
|
+
def self.step(engine, frame) = engine.step_commander_zone!(frame)
|
|
26
|
+
def self.decisions = %w[commander_zone]
|
|
27
|
+
|
|
28
|
+
def self.validate(frame, data, errors)
|
|
29
|
+
errors << "frames: commander_zone object #{frame["object"]} doesn't exist" unless data["objects"].any? do
|
|
30
|
+
it["id"] == frame["object"]
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
register("commander_zone", CommanderZone)
|
|
35
|
+
end
|
|
36
|
+
end
|