# Drawstep AI pack (Magic) — part 13 of 15: Custom mechanics > The primitives people miss with the printed wording each answers, registered natives, and the honesty ladder for a clause nothing expresses. Pack index: https://drawstep.xyz/wiki/mtg/pack.md · previous: https://drawstep.xyz/wiki/mtg/pack/layouts-tokens.md · next: https://drawstep.xyz/wiki/mtg/pack/cookbook.md · everything in one document: https://drawstep.xyz/wiki/drawstep-mtg-ai-pack.md. Generated from Drawstep's card schema; field names and discriminators are exact. ## Custom mechanics and the honesty ladder Custom cards bring clauses no printed card has. The engine is built so those clauses are **played, not approximated**: first look for the primitive that says exactly what the text says, then fall down the honesty ladder only as far as you must. **1. Say it with the vocabulary.** Most "custom" text is ordinary rules text with a new combination. Primitives people miss: - **The selection algebra** — every action's `target` composes `mode` (chosen / choose / all / random / top / back-references) × `zone` × `player` (+ `playerTarget`) × `filter` × `min` / `max` × `chooser` independently. "Exile a card at random from an opponent's hand", "destroy a land chosen at random", "put a creature card at random from your graveyard onto the battlefield" need no new primitive; see **Filters & targets**. - **`name` on any ability** — the printed ability word ("Hellfire Retribution — …"). The English rendering prefixes it, the stack reads ": Hellfire Retribution", the game log too; the Studio's Flow shows it as the pipeline title. Name every custom ability that is printed with a word. - **Choosing one die result** ? "Roll two d6 and choose one result. ? equal to that result. Then ? equal to the other result" is `{ effect: "rollDie", amount: 2, sides: 6, chooseResult: true, results: [], then: [...] }` with `{ kind: "dieResult", of: "chosen" }` / `of: "other"` (CR 706.3, 608.2d). - **Repeat this process** ? wrap the process in `{ effect: "repeat", process: true, effects: [...] }` and put `{ effect: "repeatProcess" }` where the text says "repeat this process" (inside an `if` / `ifDone` / `clash` / `mayPay` branch for "If you do / If you win, repeat this process"); `optional: true` is "You may repeat this process any number of times" (CR 608.2c-d). - **Type-changing statics** — "Demon, Devil, and Imp creatures you own have all of those types" is `{ type: "addTypes", to: { mode: "all", filter: { types: ["Creature"], subtypes: ["Demon","Devil","Imp"], owner: "you" } }, subtypes: ["Demon","Devil","Imp"] }`. - **`shareAttachments`** (static) — "Equipment and Auras attached to your commander are treated as if they were attached to ~ as well": `{ type: "shareAttachments", to: { mode: "all", filter: { isCommander: true, controller: "you", other: true } } }` (`with` defaults to the source). Host statics, host-mode effects and host filters then apply to both. - **`playerRule` `manaAsAnyColor` / `manaAsAnyType`** with a spell `filter` — "Demon, Devil, and Imp spells can be cast with mana of any color". - **Free attach / put onto the battlefield attached** — `attach` with `what: { mode: "choose", filter: {…} }`, or `moveTo` … `destination: "battlefield", attachedTo: { mode: "self" }` for an Aura from hand. Offer alternatives as `modes` on the trigger. - **Enchanted player** (Curses, CR 303.4) — the `enchantedPlayer` player selector ("enchanted player draws a card"), trigger `damageTo: "enchantedPlayer"` and the attack-recipient relation `enchantedPlayer` resolve to the player the Aura is attached to. "Whenever a player attacks enchanted player with one or more creatures" is `attacks` + `oneOrMore` + `by: "any"` with the enchanted-player recipient. - **Your team** (CR 810.2) — the `yourTeam` player selector and filter `controller: "yourTeam"` ("creatures your team controls"). Outside Two-Headed Giant it is exactly you. - **"A spell or ability an opponent controls causes you to discard"** (CR 701.9a) — `discards` (and `zoneChange`: Sacred Ground) trigger with `causedBy: "opponent"`; the engine records the controller of the resolving spell or ability, and discards paid as costs have no cause. The same cause on a replacement — `{ replaces: "event", event: "toGraveyard", to: self, discarded: true, causedBy: "opponent", zone: "battlefield" }` — is Obstinate Baloth's "put it onto the battlefield instead of putting it into your graveyard". - **"Exile cards until you exile a …"** — `digTop` with `until: { subtypes: [...] }`, `restTo: "exile"`, and `picks: [{ take: 1, order: "first", filter, then: [...] }]` to act on the found card. - **Life or other payments measured at resolution** — `mayPay` with `cost: { payLife: { kind: "affected", property: "manaValue" } }`; the engine fixes the number as the ability resolves and asks "Pay 5 life?". - **"Put it into the command zone; it costs {2} less"** — `moveTo` … `destination: "command", link: true`, a `playerRule` `castLinkedExile` (or `playLinkedExile`) so the linked card may be cast from there (no commander tax), and a `costModifier` with `filter: { linkedToSource: true }, amount: -2`. - **"You may have the damage dealt to another creature instead" (once per turn)** — a damage replacement with `optional: true`, `firstEachTurn: true` and `redirectTo: { mode: "choose", filter: {…} }`; the controller picks the recipient as the damage would be dealt. - **"When ~ becomes the target of a spell or ability, you may change that target"** — a `becomesTarget` trigger (`filter: { self: true }`, `onceEachTurn: true`, `optional: true`) whose `retarget` targets `{ of: "spellOrAbility", mode: "triggeringOther" }` with `to: { mode: "choose", filter: {…} }`. - **"When your commander dies"** — `{ event: "dies", filter: { isCommander: true, controller: "you", other: true } }`; permanent self-changes use `modifyPT` / `grantAbility` with `duration: "permanent"`. - **"End the turn."** — `{ "effect": "endTurn" }` (CR 716): exiles every object on the stack including the card itself, removes all creatures from combat, checks state-based actions and skips straight to the cleanup step — "at the beginning of the end step" abilities do not trigger that turn. Later effects of the same spell still resolve ("End the turn. At the beginning of your next end step, you lose the game."). - **"This ability triggers only once."** — `trigger.onlyOnce: true`: once per object across turns and controllers; leaving and returning makes a new object that can trigger again (CR 400.7). `onceEachTurn` is the per-turn limiter. - **Trigger limits** — `trigger.maxTriggersPerTurn` limits total triggers to the stated count each turn. A campaign Augment can use `trigger.oncePerBattle` to track its use on a physical card even if it leaves and returns. - **"Its owner puts it on their choice of the top or bottom of their library"** — `moveTo` … `destination: "library", position: { chooser: "owner" }`; "put it on *your* choice of the top or bottom of its owner's library" is `position: { chooser: "you" }`. The chooser is asked as the effect resolves, once per owner's library. - **"~ assigns no combat damage this turn"** — `restrict` … `restriction: "assignsNoCombatDamage", duration: "endOfTurn"`: the creature stays attacking or blocking and deals no combat damage (CR 510.1), unlike removing it from combat. - **"Target creature can't be blocked this turn except by Walls" / "It can't be blocked by creatures of that color this turn"** — `restrict` … `restriction: "cantBeBlocked"` with `exceptBy: { subtypes: ["Wall"] }` or `by: { colors: … }` (CR 509.1b): only the matching blockers are forbidden (or allowed); the filters read the resolving ability (its chosen color / player), and a `mode: "all"` set stays dynamic (CR 611.2c). - **"The player or planeswalker it's attacking" / "… that creature is attacking"** — the target `{ of: "any", mode: "attacked" }` (CR 506.2, 508.1b): in an attack trigger, the player, planeswalker or battle the attacker was attacking when it attacked (it still applies after the attacker leaves combat; a permanent that changed zones is a new object, CR 400.7); otherwise what the source (`attacker: "self"`, the default) or the triggering creature (`attacker: "triggering"`) is attacking now ("Whenever this creature becomes blocked, it deals 1 damage to the player or planeswalker it's attacking"). `filter` names the permanent half (`{ "types": ["Planeswalker"] }`). - **"Players can't gain life this turn"** — the one-shot `playerRule` with `rule: "cantGainLife"`, `who: "eachPlayer"`, `duration: "endOfTurn"` (CR 119.7). - **"Target unblocked attacking creature becomes blocked"** — `{ effect: "becomeBlocked", target }` (CR 509.1h): the attacker becomes blocked with no blockers, its "becomes blocked" abilities trigger, and without trample it assigns no combat damage. - **"Shuffle the cards from your hand into your library, then draw that many cards"** — putting cards into a library is a recorded action: `moveTo` … `destination: "library"` then `{ "kind": "doneThisWay", "of": "putIntoLibrary" }`. For "each player shuffles …, then draws that many", give the count `filter: { owner: "current" }` so each player counts the recorded cards they own — the same composition serves "each player discards their hand, then draws that many" (`of: "discarded"`). - **"If it shares a creature type with ~, you may reveal it. If you do, …"** (kinship) — the looked-at card is the previous selection; test it with `{ kind: "affectedMatches", filter: { sharesWithSource: "creatureType" } }` and nest the optional and its rider inside the `if`. - **"Choose one that hasn't been chosen (this turn) —" on a trigger** — `modeHistory: "game"` / `"turn"` on the triggered ability (the same field activated abilities use): modes already chosen by this object are no longer offered, recorded as the ability goes on the stack. A head with two event alternatives ("Whenever ~ attacks or becomes the target of a spell, choose one —") is two triggered abilities sharing the same `modes`. - **"Exile it with three time counters on it and it gains suspend"** — `exile`, `addCounters` (`counter: "time"`) and `{ "effect": "suspendCard", "target": … }` on the exiled card (`thisWay: exiled`): the card is a suspended card (CR 702.62c) whose owner removes a counter each upkeep and casts it free when the last leaves. "If it doesn't have suspend, it gains suspend" is the same effect — a card in exile with time counters is suspended either way. - **"The exiled card" after an exile cost** — `{ "of": "object", "mode": "thisWay", "action": "exiled" }`: the engine seeds a resolution's "exiled this way" set with the cards exiled to pay that activation or spell (CR 607.2c), so "{2}, Exile a nonland card from your hand: Put four time counters on the exiled card" acts on this activation's card, never on cards exiled by earlier activations. - **"Return it to the battlefield under an opponent's control"** — `moveTo` … `controller: "opponent"`: the controller picks an opponent as the effect resolves (CR 608.2d); with one opponent nothing is asked. - **"If enchanted creature would be destroyed or exiled, instead …"** — one replacement watching two events: `{ replaces: "event", event: "destroy", orEvents: [{ event: "leavesBattlefield", toZone: "exile" }], to: { of: "object", mode: "host" }, instead: [...] }` (CR 614.1a). `toZone` tells exile apart from every other way of leaving (hand, library, graveyard); "destroyed" is the destroy event (CR 701.8, lethal damage included) — not a sacrifice, not 0 toughness. With no `zone` written the creature never leaves and the program runs instead. "Transform ~, then that creature phases out" puts `transform` first: an Aura that transformed into a creature is no longer an Aura, so it doesn't phase out with the creature (CR 702.26g) and becomes unattached (CR 704.5p). - **"If ~ would leave the battlefield, return it to the battlefield under an opponent's control instead"** — a `leavesBattlefield` replacement on `self` whose `instead` is `moveTo` the `replaced` permanent with `destination: "battlefield", controller: "opponent"`: it never goes to another zone (no dies or leaves abilities trigger), but it returns as a new object (CR 400.7) — damage, counters, Auras and effects on it are gone and its enters abilities trigger. It applies again to the next event (CR 614.5), so the card keeps changing hands. "Target opponent" in a replacement is an opponent of the controller's choice — static abilities and their replacement effects don't target (CR 115.1). - **"~ deals 0 combat damage to its owner"** — `{ replaces: "event", event: "damage", from: { of: "object", mode: "self" }, toPlayer: "owner", damageKind: "combat", set: 0 }`: a replacement, not prevention (CR 615), so "damage can't be prevented" doesn't stop it; trample still assigns past its blockers and the part assigned to its owner becomes 0 (CR 120.8: 0 damage is no damage). Damage to the owner's planeswalkers and to other players is dealt normally. - **"These counters can't be put on ~ by any other means"** — a `putCounters` replacement `{ to: { of: "object", mode: "self" }, counter: "adaptation", from: { of: "object", mode: "all", filter: { other: true } }, prevent: true }`, read back as "Adaptation counters can't be put on ~ except by its own abilities": proliferate and every other spell or ability are stopped. A transforming permanent keeps its counters (it doesn't become a new object, CR 712.18), so "the back face begins with as many counters as the front face had" needs nothing at all. - **"Gains protection from the card type of your choice"** — `{ effect: "choose", kind: "cardType", options: ["Artifact", "Creature", …], inline: true }` followed by `grantKeywordAbility` with `keywordAbility: { keyword: "protection", from: { chosenType: true } }`; the type is fixed as it resolves (CR 608.2d). "Until the next turn ends" is `duration: "untilEndOfNextTurn"`, "until the stack resolves" is `untilStackEmpty` (it ends the next time a player would receive priority with an empty stack), and "Once per turn" is `oncePerTurn: true` on the activated ability. - **"Crews Vehicles as though its power were 2 greater"** — the static `{ type: "crewPowerBonus", to, amount: 2 }`, with `saddle: true` for "saddles Mounts and crews Vehicles …" (the Pilot tokens); crew and saddle totals read the bonus (CR 702.122, 702.172). - **"When ~ dies, … return it to the battlefield"** — plain `moveTo` … `target: { mode: "self" }`: the engine binds a self reference after a dies / leaves / exiled / sacrificed / discarded / cycled head to the card in the zone the event moved it to and finds nothing once it has moved again (CR 400.7f) — a response that exiles the card from the graveyard makes the return do nothing, without any extra vocabulary. - **"Ward—Pay life equal to this creature's power"** — a ward cost is any `cost`, not only mana: `{ keyword: "ward", cost: { payLife: { kind: "sourcePower" } } }` (likewise `discard`, `sacrifice`, …). "This creature" in the cost is the warded permanent — the engine fixes the amount in *its* context as the ward trigger resolves (CR 702.21a), so a 7-power Wurm asks for seven life whatever targeted it. - **"Conjure a random card from ~'s spellbook" / "Draft a card from ~'s spellbook"** — the card's `spellbook` field holds the names (stock cards carry curated data; a custom card lists its own); `draft` offers three, `{ "effect": "conjure", "choices": [...], "chooseAtRandom": true, "destination": "hand" }` picks one uniformly. A two-faced card is named by its front face or its full "Front // Back" name — both resolve. - **"Choose target creature you control and target creature you don't control. … Then those creatures fight each other."** — a *declared* target: the declaring sentence is `{ "effect": "choose", "kind": "object", "selections": [A, B] }` (one target: `"target": A`) where every selector is `mode: "chosen"` with a `slot` ("declared-1", "declared-2"); each later clause names the same creature by repeating the selector with its slot — `fight` with `what: A` and `target: B`, a conditional pump on A — and the engine prompts once per slot (CR 601.2c), whether or not the clause that first names it runs. "That creature's power" with nothing acted on yet is `{ "kind": "aggregate", "op": "sum", "property": "power", "target": A }` — a value may read any selection (a slot, `affected`, `triggering`, `host`, `self`) and never prompts; a chosen target inside a value must carry a slot the ability declares. - **"Reveal cards from the top of your library until you reveal a nonland card. That creature gets +X/-X until end of turn, where X is that card's mana value. Put all cards revealed this way on the bottom of your library in any order."** — `digTop` with `until`, `reveal`, `restTo: "bottom"`, `restOrder: "chosen"` and one pick `{ take: 1, order: "first", filter, then: [...] }`: the continuation runs with the found card as `affected` (`{ kind: "affected", property: "manaValue" }`) and, left in the library, the card goes to the bottom with the rest; "~ deals damage to any target equal to that card's mana value" inside the pick is a real target of the spell — the engine declares targets inside dig picks while casting. - **Tiered** — `{ "keyword": "tiered" }` plus a spell ability with `chooseMin: 1, chooseMax: 1` whose `modes` each carry a `cost` (`"Thundara — {3} — …"`): exactly one tier is chosen as the spell is cast and its mana is paid on top of the mana cost (CR 702.182); spree uses the same mode costs with one-or-more. - **"Triple target creature's power and toughness until end of turn"** — `{ "effect": "double", "what": "powerAndToughness", "factor": 3, … }`: +X/+X where X is twice the current value (CR 701.10); `factor` works for counters the same way. - **"You may cast this spell as though it had flash if you pay {2} more to cast it"** — the `castAsFlash` player rule with `extraCost: { mana: "{2}" }` (and `filter: { self: true }`): the surcharge is part of the total cost only when the permission is what allows the cast — at sorcery speed the spell costs its printed mana (CR 601.2f). - **"Flashback {8}{B}{B}. This spell costs {X} less to cast this way, where X is …"** — the keyword plus a static `costModifier` on `{ self: true }` under `condition: { kind: "castWith", alternative: "flashback" }` with `amount` −max(0, X): the engine reads the way the spell would be cast while checking whether it can be cast at all, so the reduced flashback is offered when it is affordable. "The greatest mana value of a commander you own on the battlefield or in the command zone" is an `aggregate` over two `sets` (one description, two zones). - **"Target opponent exiles cards from the top of their library until they exile a nonland card. You may cast that card without paying its mana cost."** — the same `digTop` with `who` naming the examining player (`"target"` + a player target, `"eachOpponent"`, `"eachPlayer"`, `"affectedController"` for "its controller" after "destroy target creature"): the digger owns the library and finds the card; the pick's `then` runs for *your* benefit (`castFree` by the effect's controller), and "they may cast that card" is `castFree` … `who: "current"` — inside a per-player examination `current` is the digger (CR 608.2h). "You may cast any number of spells from among those nonland cards" after an each-opponent dig is one `castFree` over `{ mode: "choose", action: "exiled", zone: "exile", filter: { notTypes: ["Land"] }, max: "any" }`; `chooser: "thatPlayer"` makes the digger's find enter under their control (Polymorph), `controller: "you"` on the pick takes it (Curse of Unbinding); `link: true` makes every card the examination exiles a card "exiled with" the source. - **"Flashback—{1}{U}, Pay 3 life." / "Kicker—{2}{R}, Sacrifice a land." / "Equip—Pay {3} or remove a counter from this Equipment."** — a keyword's `cost` is a complete cost, not only mana (CR 118.2): `{ mana: "{1}{U}", payLife: 3 }`, `{ mana, sacrifice: {…} }`, `{ oneOf: [{ mana: "{3}" }, { removeCounters: { amount: 1 } }] }`, `{ reveal: { colors: ["W"] } }` (Morph—Reveal a white card), `{ payCounters: { counter: "energy", amount: 3 } }`. - **Beam me up** — `{ keyword: "beamMeUp", cost }`: cast from your graveyard for that cost if you also return a creature you control to its owner's hand (the return is an additional cost, CR 118.8), then the spell is exiled as it leaves the stack (as flashback); the permission is offered only while you control a creature to return. - **"If this ability has been activated four or more times this turn, …"** — `{ kind: "activationsThisTurn" }`: the resolving activated ability's activations this turn, counting this one (CR 602.2, 608.2h) — compare it, or use it as an amount. - **"It deals that much damage to each other opponent"** — a player target's `exceptPlayer`: `{ of: "player", mode: "all", player: "eachOpponent", exceptPlayer: "triggeringPlayer" }` is every opponent but the one the ability triggered for; any player selector may be excluded. - **Excess damage (CR 120.4a)** — the engine measures damage beyond lethal as it is dealt (toughness less damage already marked, one from a deathtouch source, loyalty, defense). `dealDamage` … `excessTo: "controller"` is "Excess damage is dealt to that creature's controller instead" (the creature is dealt only lethal; its controller the rest, at the same time); `{ kind: "excessDamageThisWay" }` is "the amount of excess damage dealt this way" and, compared with 0, "if excess damage was dealt this way". - **"At end of combat, if this creature attacked or blocked this combat, remove a +1/+0 counter from it"** — `{ kind: "sourceThisTurn", did: "attackedOrBlocked", combat: true }` reads this combat phase only (CR 506.1; a second combat starts clean); every "+X/+Y" counter kind changes power and toughness by X and Y per counter (CR 122.1a). **"This ability can't cause the total number of +1/+0 counters on this creature to be greater than four"** is `addCounters` … `maxTotal: 4`: an "up to X" choice is bounded by the room left and a fixed amount is cut to it. - **"That creature is a black Zombie in addition to its other colors and types"** — after a return to the battlefield, `becomeType` (`subtypes: ["Zombie"]`) and `becomeColor` (`colors: ["B"]`) on `{ mode: "created" }` with `duration: "permanent"` — "is" after an entry is the same characteristic-setting effect as "becomes". - **"… until this card is cast from exile" / "until an opponent becomes the monarch"** — an event-bound duration: `duration: { untilEvent: { event: "castSpell", filter: { self: true }, from: "exile" } }` (any trigger spec; `{ event: "becameMonarch", by: "opponent" }`). The engine screens events against the effect's source with its controller fixed on resolution and ends the effect the moment the event happens (CR 611.2a) — it never restarts. Pair it with **"You may cast this card for as long as it remains exiled"** after an "Exile this card from your hand" cost: `exileMayPlay` on `{ mode: "thisWay", action: "exiled" }` with `until: "forever"` (and `castOnly`) — the card the cost exiled is this payment's exiled card (CR 400.7i), and a card already in exile keeps its identity. - **"Draw a card and reveal it."** — `drawCards` … `reveal: true`: the drawn card is revealed and becomes the latest selection, so "remove a number of loyalty counters equal to that card's mana value" reads `{ kind: "affected", property: "manaValue" }` and "if it's a land card, discard it" is `if` + `affectedMatches` + `discard` … `cards: { mode: "affected" }`. - **"Target player can't play lands this turn" / "Your opponents can't gain life this turn" / "that player can't gain life for the rest of the game" / "The "legend rule" doesn't apply to permanents you control this turn"** — the one-shot `{ "effect": "playerRule", rule, who | target, duration }` takes the prohibitions of the static `playerRule` (`cantGainLife`, `cantLoseLife`, `lifeCantChange`, `cantLoseGame`, `cantWinGame`, `cantSearchLibraries`, `cantPlayLands`, `cantDrawCards`, `ignoreLegendRule`); the affected players are fixed on resolution and the rule lasts this turn, until your next turn or (`"permanent"`) the rest of the game (CR 611.2a, 611.2c). Consecutive prohibitions print as one sentence joined by "and". - **"The next instant or sorcery spell you cast this turn has storm" / "… has cascade" / "… has convoke" / "… has affinity for artifacts"** — `{ "effect": "nextSpellHas", filter, keywordAbility }`: until end of turn the next matching spell its controller casts has the keyword ability, already while being cast (cost aids apply, CR 601.2f), and its cast triggers trigger; each such effect is used up by one spell and non-matching spells don't use it (CR 611.2). Two of them print "the next instant spell and the next sorcery spell you cast this turn each have cascade". - **"The next spell you cast this turn costs {1} less to cast" / "Face-down spells you cast this turn cost {1} less to cast" / "Until your next turn, … spells that player casts cost {2} less to cast"** — `{ "effect": "costModifier", amount, filter, next, who | target, duration }`: a resolved spell or ability changes the generic cost of matching spells the affected players cast (signed amount, negative = less), fixed on resolution, until end of turn or until your next turn (CR 601.2f, 611.2a). With `next` each affected player's next matching spell uses it up.- **"Clash with an opponent. If you win, …. Otherwise, that player gains control of enchanted creature."** — the `clash` branches run with the clashing opponent as `current`: "that player" there is `{ of: "player", mode: "all", player: "current" }` (the earlier selections stay the history — "that creature's controller" after a damage sentence still means the creature's controller). - **"If you've committed a crime this turn" / "if you haven't cast a spell from your hand this turn"** — turn history `{ "kind": "thisTurn", "event": "crimesCommitted" }` counts crimes (one per spell, ability or trigger that targets an opponent, anything they control or a card in their graveyard, CR 700.13); "a spell from your hand" is the cast snapshot's `filter: { "castFrom": "hand" }` (CR 601.2a). - **"Clash with an opponent. If you win, …. Otherwise, that player gains control of enchanted creature."** — the `clash` branches run with the clashing opponent as `current`: "that player" there is `{ of: "player", mode: "all", player: "current" }` (the earlier selections stay the history — "that creature's controller" after a damage sentence still means the creature's controller).- **"You may reveal cards from the top of your library until you reveal a creature card. (If you do, ) put that card …"** and **"Sacrifice ~. If you do, reveal cards from the top of your library until …. Put that card …"** — an optional examination is `optional` → `digTop`; a conditional one is `ifDone` with the whole examination (its disposition sentences included) in the branch. - **"Whenever you tap a land for mana, add an additional {G}" / "Whenever enchanted land is tapped for mana, its controller adds …" / "Whenever a player taps a land for mana, that player adds one mana of any type that land produced"** — the trigger event `tappedForMana` (CR 605.1b): a permanent's {T} mana ability resolved; `filter` names the tapped permanent (`{ host: true }` for the enchanted land, `{ subtypes: ["Swamp"] }`), `by` who tapped it, and the context carries the mana it made — `{ "effect": "addMana", "mana": "{produced}" }` is "one mana of any type that land produced", `who: "triggeringController"` its controller. A targetless trigger that adds mana is itself a mana ability: it resolves at once, never on the stack, and the payment planner counts it (one enchanted Forest pays {1}{G}); anything else triggering on the event — "remove a +1/+1 counter from this creature", Manabarbs' damage — goes on the stack like any trigger. A plain tap that gained extra mana can no longer be taken back. - **"If you tap a permanent for mana, it produces twice as much of that mana instead" / "If a land is tapped for mana, it produces {B} instead of any other type and amount" / "… produces colorless mana instead of any other type"** (Mana Reflection, Contamination, Damping Sphere, Reality Twist, Pale Moon) — a mana-production replacement (CR 614.1a, 106.1): `{ "replaces": "event", "event": "addMana", "tappedForMana": true, … }` with `from` naming the tapped permanent (`{ filter: { types: ["Land"] } }`), `by`/`toPlayer` whose tap ("you tap" is `by: "you"`; "a land is tapped" is `toPlayer: "eachPlayer"`) and one of four shapes: `manaMultiply: 2` (twice as much of *that* mana — the colors stay), `manaExact: "{B}"` ("instead of any other type and amount" — the whole production is replaced), `manaColor: "C"` ("instead of any other type" — the amount stays; `"any"` is "a color of your choice"), or `manaExact: "{any}{any}{any}"` with `manaOneColor: true` ("three mana of a color of your choice"); `minAmount: 2` is "tapped for two or more mana". A list ("Plains produce {R}, Swamps produce {W}, …") is one replacement per subtype; "Until end of turn, if you tap a land for mana, …" is the same replacement as an `{ "effect": "replacement", "duration": "endOfTurn" }` one-shot. The engine replaces the production itself — not a trigger after it — so the payment planner offers the replaced mana (a Forest under Contamination pays {B} only; Mana Reflection's Sol Ring pays {C}{C}{C}{C}), "twice as much" of a multi-color choice is decided before doubling, and only the tapped permanent's own production is replaced — a triggered mana ability's mana (Wild Growth's {G}) is the Aura's, not the land's, and stays as printed. - **"Return it to the battlefield. It's an Aura enchantment with enchant creature you control and "…", and it loses all other abilities."** (Bronzehide Lion, Old-Growth Troll, Harold and Bob) — `moveTo` … `as: [ … ]`: continuous effects applied to each entering permanent (`{ mode: "affected" }`) *as it enters*, before it chooses what to enchant and before its enters triggers (CR 303.4f, 611.2a) — so it returns as an Aura, picks a legal host as it enters, and with nothing to enchant goes to the graveyard by state-based action (CR 704.5m). Order the parts as the card does: `becomeType` … `replace: true`, then `loseAbilities` ("loses all other abilities"), then `grantKeywordAbility` enchant and the quoted `grantAbility` — later grants outlast the loss (CR 613.7). A quoted static ("Enchanted Forest has '{T}: Add {G}{G}' and '…'") is the Aura's own static; the enchanted permanent named with a subtype is one permanent. - **"All creatures able to block ~ do so"** (Lure, Taunting Elf, Nemesis Mask's "equipped creature", Noble Quarry's "~ or enchanted creature") — the static part `{ type: "lure", to: }` (CR 509.1c): one blocking requirement per creature able to block the affected attacker, maximised with every other requirement at declare blockers — no able creature may be left out, an unable (tapped) creature is never required, and the lured attacker is assigned before other attackers. `blockers` narrows the kind: "All Walls able to block ~ do so" is `blockers: { subtypes: ["Wall"] }`. A trailing "…, and all creatures able to block it do so" is one more part of the same static; the one-shot "All creatures able to block target creature this turn do so" stays the `mustBlock` effect with `attacker`. - **"This creature loses this ability and becomes an Aura enchantment with enchant creature. Attach it to target creature. You may pay {W} to end this effect."** (Licids) — three primitives, not one card-shaped effect. `loseAbility` … `ability: "this"` removes the resolving ability from its source (CR 613.1f), leaving an inert slot so the other printed abilities keep their indices; `becomeType` … `replace: true` makes it an Aura and `grantKeywordAbility` gives it `enchant creature`; `attach` puts it on the target, so its "Enchanted creature …" statics reach the host. All of it sits inside `{ "effect": "endable", "cost": { "mana": "{W}" }, "then": [ … ] }` (CR 116.2c): every continuous effect `then` creates is one group, and the controller (or `who`) may take the **end effect** special action whenever they have priority and can pay — the group ends at once, the creature stops being an Aura and comes unattached by state-based action (CR 704.5n); an Aura-Licid whose host leaves goes to the graveyard (CR 704.5m). Durations inside `then` are `"permanent"`. - **"If another Human died under your control this turn" / "if an opponent cast a blue spell this turn" / "if a card left your graveyard this turn" / "if a +1/+1 counter was put on a creature you control this turn" / "as long as a creature attacked this combat"** — turn history is one algebra, not a phrase list: a `thisTurn` value is *event* × look-back `filter` × `who` × `counter` × `combat` × `lastTurn`, compared with `compare`. The engine logs every object event this turn with the object's characteristics **as the event happened** (CR 608.2h — a Human that died as a Human counts even if it is now a Zombie token elsewhere; an entering permanent's snapshot is its final characteristics after layers), so `filter` works on *every* object event: `creaturesDied`, `permanentsEntered`, `permanentsLeft`, `permanentsDestroyed`, `permanentsSacrificed`, `spellsCast`, `spellsCountered`, `cardsDrawn`, `cardsDiscarded`, `cardsExiled`, `cardsLeftGraveyard`, `cardsToGraveyard`, `permanentsToHand`, `creaturesAttacked`, `tokensCreated`, `countersPlaced` / `countersRemoved` (with `counter` for the kind). `who` is the player each event is attributed to (controller for enters / dies / left, caster for spells, owner for graveyard and hand events, the placer for counters); `{ "other": true }` in the filter is "another" (not the source); "an opponent cast three or more spells" is one opponent's count — `{ "kind": "anyOpponent", "condition": { … "who": "you" … } }` — while "an opponent cast a spell" may sum with `who: "eachOpponent"`. `combat: true` restricts to the current combat phase (CR 506.1, 500.8): a creature attacking again in an additional combat counts for that combat but not twice for the turn. Player-only events (`lifeGained`, `lifeLost`, `librariesSearched`, `diceRolled`, …) take `who` but no filter. - **"Each opponent who controls a creature …" / "each player who cast a spell this turn …" / "the player who controls the most creatures …" / "each player other than that player …" / "if a player has seven or more cards in hand"** — players are a selection algebra too. Any player selector has a structured form `{ "kind": , "where": , "except": , "most": , "fewest": }` (CR 608.2h: `where` and the values are read *as each candidate* — "you" inside them is that player): `{ "kind": "eachOpponent", "where": { "kind": "controls", "filter": { "types": ["Creature"] }, "min": 1 } }`, `{ "kind": "eachPlayer", "most": { "kind": "count", "filter": { "types": ["Creature"] }, "player": "you" } }` (ties included — `mostLife` / `mostCardsInHand` are its special cases), `{ "kind": "eachPlayer", "except": "you" }`. The condition `{ "kind": "anyPlayer", "who"?, "condition", "all"? }` is "a player …" / "each player …" over any set the same way (`anyOpponent` is its opponents-only case). Printed back: "each opponent who controls a creature", "the player who controls the most creatures", "a player has seven or more cards in hand". - **"If it was dealt damage this turn" / "an opponent was dealt 3 or more damage this turn" / "noncombat damage was dealt to an opponent this turn" / "damage from a red source" / "if excess damage was dealt this turn"** — `{ "kind": "damageDealt", "to"?, "from"?, "damageKind"?, "excess"?, "combat"?, "lastTurn"? }`: the damage actually dealt this turn (CR 120.1, after prevention and replacement) from the engine's damage log, narrowed by recipient (`to`: a player selector, or an object reference compared by identity — `{ "mode": "self" }` / `{ "mode": "affected" }` / `{ "mode": "triggering" }`; the same incarnation, so a dies trigger's "it" reads the creature that died, CR 400.7), source (`from`: a look-back filter on the source — `{ "self": true }` for "by this creature", `{ "colors": ["R"] }` for "a red source"), `damageKind` ("combat" / "noncombat"), `excess: true` (damage beyond lethal, CR 120.4a) and `combat: true` ("this combat"). It generalises `damageDealtToOpponents`, the `damagedThisTurn` / `dealtDamageThisTurn` flags and the resolution-scoped `excessDamageThisWay`; compare it with 0 for "was dealt damage" / "wasn't dealt damage". - **"Each other creature that shares a creature type with it" / "creatures with power less than that creature's power" / "all Equipment attached to it" / "each creature blocking it"** — filters relative to a selection reference, one field each (CR 608.2h): `sharesWith: { "property": "creatureType" | "cardType" | "permanentType" | "color" | "name" | "manaValue" | "controller", "with": , "negate"? }`, `comparedTo: { "property": "power" | "toughness" | "manaValue" | "powerPlusToughness", "op", "with": , "offset"? }`, `attachedToSelection: `, `combatWith: { "relation": "blocking" | "blockedBy" | "attacking" | "attackedBy", "of": }`. The reference is any selection — `{ "mode": "self" }`, `{ "mode": "affected" }` ("it" / "that creature" after an action), `{ "mode": "triggering" }`, `{ "mode": "host" }`, or a declared target slot (`{ "mode": "chosen", "slot": "that", … }` — the slot makes it a target of the spell, announced once and read by every clause). They subsume `sharesWithSource` / `sharesWithHost` / `sharesWithTarget`, `comparedToSource` / `comparedToTrigger`, `attachedToSource` / `attachedToReference`. A host destroyed earlier in the same resolution still identifies "Equipment attached to it" (the engine keeps the last attachment when a host leaves). - **"That creature's controller draws a card" (after "becomes blocked by a creature") / "that permanent's controller or that player creates a token" / "that player may copy this spell and may choose a new target for that copy" / "that creature's controller creates a token that's a copy of it" / "each player amasses Rats X" / "target opponent sacrifices a creature. If they can't, …" / "for each opponent who controls a creature, …"** — every slot that names a player takes the same `PlayerSelector`, never a closed list: `triggeringOtherController` / `triggeringOtherOwner` are the controller / owner of the event's *other* object (the blocker, the permanent dealt damage, by last known information, CR 603.10); `affectedController` after an "any target" is that player when the reference is a player (the Chain and Chandra wording "that player or that planeswalker's controller"); `copySpell.controller`, `createTokenCopy.who`, `amass.who`, `forEachPlayer.players` and the `ifDone` sacrifice's `who` accept any selector (`copySpell` keeps `"chosenOpponent"` for Demonstrate's resolution-time choice; a resolving spell can copy itself, CR 608.2 — the copy goes on the stack under the named player's control and they may retarget it; a copy token's creator controls it, CR 111.2; `amass` reads its amount as each amassing player). Printed back: "that creature's controller", "that player copies this spell and may choose a new target for that copy", "its controller creates a token that's a copy of …", "each player amasses Rats X", "If they can't, …", "for each opponent who controls a creature, …". - **"You gain 1 life for each card drawn this way" / "for each card revealed this way" / "for each counter put on a creature this way" / "for each counter removed this way"** — the this-way algebra covers draws, reveals and counters too: `{ "kind": "doneThisWay", "of": "drawn" | "revealed" | "countersPlaced" | "countersRemoved", "filter"? }` (CR 609.3 — only what *this* resolution actually did; the counter actions count counters, not objects, so two counters on one creature are 2), and `{ "mode": "thisWay", "action": "drawn" | "revealed" }` selects those cards ("exile the cards revealed this way"). - **"You gain hexproof until your next turn" / "Target player gains shroud until end of turn" / "You gain protection from everything until your next turn" / "You have protection from each of your opponents" / "You have protection from the chosen card name"** — a player can have hexproof, shroud and protection (CR 702.11d, 702.18d, 702.16b–e). A one-shot `grantKeyword` (or `grantKeywordAbility` with a `protection` keyword ability) whose target is a player gives that player the keyword for the `duration`; a static "You have protection from …" is the static part `{ "type": "playerProtection", "who", "from": }` (filters read from the source's controller: "each of your opponents" is `{ "filter": { "controller": "opponent" } }`, "the chosen card name" is `{ "filter": { "chosenName": true } }`). A player with shroud can't be the target of spells or abilities; hexproof stops only opponents' spells and abilities; protection stops targeting by matching spells and abilities, makes Auras from matching sources fall off (a Curse is put into its owner's graveyard), and prevents damage from matching sources unless damage can't be prevented. - **"Until your next turn, your life total can't change and you gain protection from everything. All permanents you control phase out"** (Teferi's Protection) — a `playerRule` effect (`lifeCantChange`, `duration: "untilYourNextTurn"`), a `grantKeyword` "Protection from everything" to `{ "of": "player", "mode": "all", "player": "you" }` with the same duration, and `phaseOut` over `{ "of": "object", "mode": "all", "filter": { "controller": "you" } }`. Auras, Equipment and Fortifications attached to a permanent that phases out phase out indirectly with it, whoever controls them, and phase in only along with it (CR 702.26g–h); everything that phased out directly under a player's control phases in as their untap step begins (CR 702.26a). - **"Spells and abilities your opponents control can't cause their controller to search their library" / "You control your opponents while they're searching their libraries" / "While an opponent is searching their library, they exile each card they find. You may play those cards for as long as they remain exiled, and you may spend mana as though it were mana of any color to cast them"** (Ashiok, Dream Render; Opposition Agent) — the static `playerRule` `cantSearchOwnLibrary` (a search their own effects would make of their own library doesn't happen: an optional one can't be chosen, a mandatory one still shuffles, other effects of the instruction still happen; CR 101.2, 701.23); the static `{ "type": "controlWhileSearching", "who": "eachOpponent" }` (the source's controller makes the choices of those players' searches of their own libraries — what they find, within the instruction, CR 722.2, 722.5, 701.23b; the most recent one applies, CR 722.1a); and the replacement `{ "replaces": "event", "event": "searchLibrary", "toPlayer": "eachOpponent", "ownLibrary": true, "zone": "exile", "then": [{ "effect": "exileMayPlay", "who": "you", "target": { "of": "object", "mode": "affected" }, "until": "forever", "anyMana": "color" }] }` (every card the search finds is exiled instead of going where the instruction puts it — the instruction's other effects and its shuffle still happen but can't see those cards; with several, the player controlling the search picks one, CR 616.1). - **"Flip a coin. If you win the flip, destroy target artifact" / "Clash with an opponent. If you win, …target…" / "Roll a d20. 1—10 | Destroy target creature"** — a target inside a `flipCoin`, `clash` or `rollDie` branch is chosen as the spell is cast or the ability is put on the stack, before the flip or roll (CR 601.2c, 603.3d); every die band shares the same target slot, and the spell fizzles if that target becomes illegal. - **"Create a 1/1 token that's attacking" / "…tapped and attacking"** — `createToken` (and `createTokenCopy`) with `attacking` puts the token onto the battlefield attacking but untapped; add `tapped: true` for "tapped and attacking" (CR 508.4). - **"You may cast it from your graveyard" / "you may cast this card from your graveyard" / "−2: You may cast target red instant or sorcery card from your graveyard"** (Oskar, Syrix, Sproutback Trudge, Chandra) — `castFree` with `payCost: true` casts the card during resolution *paying* its mana cost and additional costs (cost modifiers apply; the effect itself permits the zone and timing is ignored, CR 608.2g, 601.2f–h); if it can't be paid, nothing happens. A self / triggering card in the graveyard carries `zone: "graveyard"` ("cast it from your graveyard"). - **"The owner of target nonland permanent puts it into their library second from the top or on the bottom"** — `moveTo` library with `position: { "chooser": "owner", "options": [{ "fromTop": 2 }, "bottom"] }`: the owner picks one of the listed places (CR 401.4, 608.2d). - **"This ability also triggers if this card is in exile" / "… in your graveyard"** (Accident-Prone Apprentice, Albiorix, Steady Tortoise) — `triggersFrom` as a list (`["battlefield", "exile"]`): the triggered ability functions on the battlefield and in each listed zone (CR 113.6, 113.6k). - **"Return this creature and another target creature to their owners' hands" / "Return enchanted creature and this Aura to their owners' hands"** (Coastal Wizard, Lady Sun, Disappear) — `moveTo` hand with `andSelf: true`: the source moves together with the selected objects (CR 608.2c). - **"This ability costs {1} less to activate for each legendary creature you control" / "{2} less … if you control a Desert" / "{1}{U} less … during your turn" / "X less …, where X is your devotion to Abzan" / "{2} less … if it targets a creature with power 2 or less"** — an activated ability's own cost change is `costModifiers: [{ "amount", "reduceMana"?, "perValue"?, "condition"?, "targets"? }]` on the activated ability, and on the `equip`, `monstrosity`, `adapt` and `specialize` keyword abilities ("Equip {3}. This ability costs {1} less to activate for each other Equipment you control"). `amount` is the signed generic change per unit (negative reduces; a value for "X less, where X is …" is `-1 × max(0, X)`), `perValue` scales it, `condition` gates it (`isYourTurn` for "during your turn"), `reduceMana` is a colored part ("{1}{U} less" is `amount: -1, reduceMana: "{U}"`; beyond the cost's pips of that color the reduction comes off generic, CR 118.7), and `targets` applies it once when any announced target matches (CR 601.2c). Every change, together with all other activation cost changes, is totalled before the zero floor (CR 601.2f, 602.2b); legality checks before targets accept a target-dependent ability if its other costs are payable, and the payment then decides. - **"Whenever one or more creature cards are put into your graveyard from your library, put one of them onto the battlefield"** — a `oneOrMore` `zoneChange` trigger whose effect selects `{ "of": "object", "mode": "choose", "among": "triggering", "zone": "graveyard", "min": 1, "max": 1 }` (CR 603.2c, 608.2d): the choice is made on resolution among the cards of the triggering group that are still where the event put them; "put them onto the battlefield" is `mode: "triggering"` (the whole group). - **"Sacrifice a creature: … If the sacrificed creature was a Human, put a +1/+1 counter on this creature."** — an `if` effect with `{ "kind": "costPaidMatches", "cost": "sacrifice", "noun": "creature", "filter": { "subtypes": ["Human"] } }` (CR 601.2h, 608.2h): the objects sacrificed to pay the spell's or ability's cost are remembered as they last existed on the battlefield, and the condition holds when exactly one was sacrificed and it matches the filter. `noun` only picks the printed word ("the sacrificed permanent was an artifact"); a colour-only filter prints "was red". - **Prismatic (Arena, Alchemy)** — "Mana of any type can be spent to cast prismatic spells." It is the keyword `"Prismatic"` in `keywords`, printed or granted; "It perpetually gains prismatic" after a conjure is `grantKeyword` with `keyword: "Prismatic"`, `duration: "perpetual"` on the `affected` card. While casting, every mana symbol of the spell's cost (and additional costs paid as part of casting) can be paid with mana of any type, including colorless, as with spending mana as though it were any type (CR 609.4b analogue); the amount is unchanged, and mana-spending restrictions on the mana itself still apply. Losing prismatic (perpetually or by losing all abilities in a hidden zone) removes the permission. - **"Conjure a duplicate of target creature card … The duplicate perpetually gains …"** — `conjure` with `copyOf`, then any effect on `{ "of": "object", "mode": "created" }`: conjure records the conjured cards like created tokens, so "the duplicate(s)" names exactly them. - **"Untap target creature an opponent controls and gain control of it until end of turn. … When you lose control of the creature, tap it."** (Ray of Command, Magus of the Unseen, Ogre Geargrabber) — `untap` then `gainControl` on `affected`, and `{ "effect": "delayedTrigger", "about": { "of": "object", "mode": "affected" }, "trigger": { "event": "controlLost" }, "once": true, "effects": [{ "effect": "tap", "target": { "of": "object", "mode": "about" } }] }` (CR 603.7c). `controlLost` fires for the player who stopped controlling the permanent — when a control effect ends or another player gains control — and when it leaves the battlefield under their control. - **Chain cycle: "… Then that player or that permanent's controller may sacrifice a land of their choice. If the player does, they may copy this spell and may choose a new target for that copy."** — `mayPay` with `who: "affectedController"` (a player target is its own "controller") whose `then` is an `optional` with the same `who` around `copySpell` with `controller: "affectedController"` (CR 707.10c): the copy is controlled by the player who paid. - **Cast origin of a spell** — CR 601.2a: object filter `castFrom: ` / `notCastFrom: ` ("counter target spell cast from a graveyard", "target spell that wasn't cast from its owner's hand"). Also filters turn-history cast snapshots: `{ "kind": "thisTurn", "event": "spellsCast", "who": "you", "filter": { "castFrom": "hand" } }` reads "a spell from your hand"; `notCastFrom` reads "spells you've cast from anywhere other than your hand". A spell copied directly on the stack has no cast origin. When an ability copies a card in exile and lets you cast the copy, the cast originates in exile. Zethi’s attack uses `copyCard` with `optional: true` and `payManaCost: true`. Its controller chooses which copies to cast and their order during resolution. - **"… as you cast this spell"** — a cast-time snapshot (CR 601.2i, 608.2h): `{ "kind": "asCast", "value": }` ("where X is the number of creatures on the battlefield as you cast this spell"; with a divided amount the value is read while casting, 601.2d) or `{ "kind": "asCast", "condition": }` ("if you controlled a Faerie as you cast this spell"). Recorded when casting completes, kept by the permanent the spell becomes, inherited by copies (707.10); false / 0 for an object that wasn't cast. "You revealed a Dragon card" (the optional additional cost `reveal`) is `{ "kind": "revealedToCast", "filter": { "subtypes": ["Dragon"] } }`, typically `asCast` of `any` [revealedToCast, controls]. - **"Whenever you put one or more +1/+1 counters on a creature" / "Whenever you put a counter on a creature you don't control"** — the `countersPlaced` trigger with `placedBy: "you"` (any `Relation`), alongside `counter`, `eachCounter` and the subject `filter` (CR 122.1, 609.4): the placer is the controller of the spell or ability whose effect or cost put the counters, which need not be the permanent's controller, so an opponent's effect putting counters on your creature doesn't trigger it. - **"Counter target spell that targets a creature you control" / "… spell or ability that targets you or a creature you control"** — the stack-object target field `stackTargets: { object?: ObjectFilter, player?: Relation }` on `of: "spell" | "spellOrAbility"` targets (CR 115.10, 601.2c): the spell or ability must currently target at least one matching permanent (relative to this ability, so `{ self: true }` is "that targets this creature") or matching player; either part suffices. It is rechecked on resolution like any target restriction (CR 608.2b). - **"Counter target spell unless its controller pays {1} and 1 life" / "… discards their hand" / "… If they do, surveil 2"** — `counterUnlessPays` takes `cost: CostDef` instead of the generic-mana `amount` for any other payment, made by the spell's controller as the effect resolves (CR 118.12, 608.2c), and `ifPaid: EffectDef[]` for "If they do, …", run for the counterspell's controller when the payment is made. - **"Put your choice of a +1/+1, first strike, or trample counter on it"** ? `addCounters.counter` may be a list of counter kinds; the controller chooses one kind for each recipient as the effect resolves (CR 122.1, 608.2d). - **"For each kind of counter on target permanent or player, give that permanent or player another counter of that kind"** ? `addCounterEachKind` adds one counter of every kind already on the target (poison included), with no choice and without proliferating (CR 122.1, 701.34); an `of: "any"` target with `permanents: true` reads "target permanent or player" (CR 115.4). - **"Add one mana of any color among legendary permanents you control" / "For each color among permanents you control, add one mana of that color"** — `addMana` with `mana: "{any}"` and `colorsAmong: { filter, zone?, who?, each? }` (CR 105.1, 106.1a, 608.2h): the colors are those of the matching objects as the ability resolves (`zone: "graveyard", who: "you"` for "legendary creature cards in your graveyard"); with `each: true` one mana of every such color is added. With no such color it adds no mana (CR 106.5). - **"With toughness less than or equal to the number of Islands you control"** — `minToughnessValue` / `maxToughnessValue` on a filter, the toughness twins of `minPowerValue` / `maxPowerValue` (CR 208.1, 608.2h), evaluated for each candidate; "less than" is `{ kind: "math", op: "-", a: …, b: 1 }`. - **"The revealed card's power" / "the exiled card's mana value"** — `{ kind: "costPaid", cost: "reveal" | "exile", property, noun: "card" }`, like `sacrifice` / `discard`: the single card revealed or exiled to pay the cost, with its characteristics as the cost was paid (CR 601.2h, 602.2b, 608.2h). - **"Unless you pay {1} for each card in your hand" / "unless that player pays {X}, where X is this creature's power"** — a resolution-time cost's `genericAmount` value is computed as the instruction resolves and added to its generic mana (CR 107.3, 608.2h). "Counter target spell unless its controller pays {X}, where X is its mana value" reads the targeted spell itself. - **Rooms and doors (Duskmourn)** — a Room is a `layout: "split"` card whose two faces have the Room subtype; each face is a door. On the battlefield the permanent has only the characteristics (name, mana cost, colors, abilities) of its unlocked doors (CR 709.5). Casting one half puts the Room onto the battlefield with that door unlocked; a Room put onto the battlefield any other way has both doors locked. Unlocking a locked door is a sorcery-speed special action that pays that door's mana cost and doesn't use the stack. "When you unlock this door, …" is the trigger `{ "event": "doorUnlocked", "thisDoor": true }` on that face (it also triggers when the door unlocks as the Room enters after being cast); `roomUnlocked` fires once every door is unlocked. "Unlock a locked door of target Room you control" is `{ "effect": "unlockDoor", "target": … }`; "Lock or unlock a door of …" adds `lockOrUnlock: true`. The value `{ "kind": "unlockedDoors", "who": "you" }` counts unlocked doors among Rooms that player controls. - **"As this creature enters, "** — the replacement `{ "replaces": "asEnters", "effects": [...], "condition"?: … }` (CR 614.1c, 614.12): the effects are performed as part of the entry event, before the permanent is on the battlefield, so "sacrifice any number of permanents" / "exile all other creatures" can never select the entering permanent itself. Its own `entersWithCounters` reads the results in the same context: "It enters with a +1/+1 counter on it for each creature sacrificed this way" is `amount: { kind: "doneThisWay", of: "sacrificed" }`. With `condition` the action happens only if it holds as it would enter. - **Day and night set on entry** — "If it's neither day nor night, it becomes day as this creature enters" is `asEnters` with `condition: { kind: "dayNight", is: "neither" }` and the effect `{ "effect": "setDayNight", "to": "day" }` (CR 730.1); `setDayNight` is also "It becomes night." on a spell. "Whenever day becomes night or night becomes day" is the trigger event `dayNightChanges` (CR 730.2): it doesn't trigger the first time the game becomes day or night from neither, unlike `becomesDay` / `becomesNight`. - **"If X is 2 or less, it enters tapped" / "If X is 5 or more, it enters with an additional X +1/+1 counters"** — an `enters` event replacement or `entersWithCounters` with a `compare` condition on `{ kind: "var", name: "X" }`: X is the value chosen for the spell that became this permanent (CR 107.3m), 0 when it wasn't cast. - **"As this creature enters, you may … If you do, it enters with …"** — `asEnters` with an `optional` effect, plus `entersWithCounters` whose `condition` is `{ kind: "compare", a: { kind: "doneThisWay", of: "returned" }, op: ">=", b: 1 }` (or a `any` of that and another condition for "If you do or if you control a Dragon"). "Twice that many" is `{ kind: "math", op: "*", a: 2, b: { kind: "doneThisWay", of: "sacrificed" } }`; "roll X d6 … equal to the total of those results" is `{ kind: "dieResult", of: "total" }`. - **"When you cast a creature spell, that creature enters with an additional +1/+1 counter … on it"** — `{ "effect": "spellEntersWith", "target": { "of": "object", "mode": "triggering" }, "additional": true, "counters": [{ "counter": "+1/+1", "amount": 1 }, …], "tapped"?: true }` (CR 614.1c, 122.6): the counters join the permanent's own entry counters if that spell resolves; a spell that leaves the stack any other way is a new object (CR 400.7) and the effect is lost. Amounts are read as the effect resolves, with "it" being that spell ("where X is the number of colors of mana spent to cast it"). Usually the body of a `oneTimeBoon`. - **"This turn, each creature you control enters with an additional +1/+1 counter on it"** — a floating `{ "effect": "replacement", "duration": "endOfTurn", "replacement": { "replaces": "event", "event": "enters", "to": { "of": "object", "mode": "all", "filter": { … } }, "enterCounters": [{ "counter": "+1/+1", "amount": 1 }] } }` (CR 614.1c, 122.6): every matching object entering while it lasts — cast, put onto the battlefield, or a token — gets those counters on top of its own entry counters. - **"When this creature enters, if the gift was promised, …" / "If the gift wasn't promised, …"** — `{ "kind": "compare", "a": { "kind": "var", "name": "gift" }, "op": ">=", "b": 1 }` (or `"==", 0`) on the permanent's own trigger (CR 702.174): the permanent remembers whether its gift was promised as it was cast; a permanent that wasn't cast, or that changed zones since, never had a gift promised. - **"Whenever one or more cards leave your graveyard" / "Whenever you discard one or more cards" / "those creatures"** — `oneOrMore: true` groups matching objects from one simultaneous event, including `zoneChange`, `exiled`, `discards`, `sacrificed`, `tokenCreated`, `blocks` and `unblocked` (CR 603.2c). Mill, discard, sacrifice and multi-card exile costs preserve that boundary; two separate instructions still produce separate events. `{ "of": "object", "mode": "triggering" }` selects every member of that group, never a later object with the same id after another zone change (CR 400.7). `{ "kind": "triggeringCount" }` is the original group's size, even if a member leaves before resolution; `triggerAmount` remains the damage amount. `youAttack` also retains its declared attackers, excluding creatures later put onto the battlefield attacking. `perPlayer: true` groups discards, sacrifices and token creation by acting player, or attacks by attacked player. Batch conditions are checked after all members are collected; delayed triggers and additional-trigger effects retain the same whole group. - **"Whenever you play a land" / "whenever you activate an ability that isn't a mana ability" / "whenever a creature crews a Vehicle" / "whenever ~ phases out" / "whenever an opponent shuffles their library" / "whenever a spell or ability you control counters a spell"** — trigger events, each fired by the engine at the exact rules moment: `landPlayed` is the special action of playing a land (CR 305.1 — not "a land enters", which a put-onto-the-battlefield also fires), with `by`, a land `filter`, and `from` / `notFrom` for "from exile" / "from anywhere other than your hand"; `activatesAbility` fires after an activated ability is put on the stack (CR 602.2; mana abilities, CR 605, fire it too, so "that isn't a mana ability" is `abilityKind: "nonMana"` and the intervening "…, if it isn't a mana ability, …" is the trigger condition `{ "kind": "triggeringAbilityKind", "abilityKind": "nonMana" }` (CR 603.4); "copy that ability" is `copyAbility` with `{ "of": "ability", "mode": "triggeringOther" }`; and `abilityKind` also narrows to `loyalty` / `boast` / `exhaust` / `ninjutsu` / `powerUp` / `crew` / `saddle` / `cycling`; `filter` is the source, which must be on the battlefield unless it is `self`, CR 109.2); `crews` / `saddles` fire once per creature tapped to pay a Crew / Saddle cost (CR 702.122, 702.171) with the Vehicle / Mount as the trigger's other object (`triggeringOther`); `phasedOut` fires for each permanent that phases out, directly or indirectly with its host (CR 702.26d), and is seen by everything that was on the battlefield just before; `shufflesLibrary` fires whenever a player shuffles their library during the game (CR 701.24 — not the opening shuffle); `countered` fires when a spell is countered (CR 701.6a) with the countering spell or ability's controller as `by` and the countered spell as the triggering object. Printed back in the card's own words, including the merged "Whenever you play a land or cast a spell". - **"Whenever you attack with one or more Zombies"** — "Whenever you attack with one or more …" is `attacks` with `by: "you"` and `oneOrMore: true` (CR 508.1, 603.2c), and "twice that much life" is `{ "kind": "math", "op": "*", "a": 2, "b": { "kind": "triggeringCount" } }`. `triggeringOtherController` pays or is dealt damage as "that creature's controller" (CR 109.4). - **"~ has all activated abilities of all creature cards in all graveyards" / "gains all abilities of those creatures until end of turn"** — `gainAbilitiesOf`, a static (`{ type: "gainAbilitiesOf", to, from, kinds?: ["activated" | "triggered" | "static" | "keyword"] }`, layer 6) or a one-shot with a `target` and a `duration` (Necrotic Ooze, Experiment Kraj, Quicksilver Elemental): `from` is any selection — a zone set, a chosen target, the linked exiled cards (`{ mode: "linked", zone: "exile" }`); each gained ability refers to the object that has it, and nothing gains abilities from itself.- **"If it's the first combat phase of the turn" / "… of your turn"** — the condition `{ "kind": "phase", "is": "firstCombat" }` / `"firstCombatYourTurn"`: true only during the first combat phase begun this turn (CR 500.8, 506.1), so an added combat phase is never "first" and "untap … After this phase, there is an additional combat phase" can't loop; a skipped combat phase never began. Use it as an intervening-if trigger `condition` (CR 603.4) or inside `if` ("If it's the first combat phase of the turn, there is an additional combat phase after this phase"). - **"Separate them into two piles. An opponent chooses one. Put one pile into your hand and the other into your graveyard"** — `separatePiles` over any selection (`target`: the top cards of a library with `mode: "top"`, a graveyard, "those cards" with `mode: "affected"`), with `separator` (who divides: `"you"` / `"opponent"`), `chooser` (who picks), `faceDown` for "a face-down pile and a face-up pile", `reveal`, and per-pile programs `chosen` / `rest` whose `mode: "affected"` is "those cards" (Fact or Fiction, Bend or Break, Brilliant Ultimatum). - **"If enchanted creature would be destroyed, instead transform ~, unattach it, then that creature phases out" / "if ~ would die, instead …" / "if enchanted creature would be exiled, instead …"** — a zone-change replacement whose `instead` is a *program* and which names no `zone`: the move does not happen and the effects run in its place (no dies / leaves triggers fire for a move that never happened, CR 700.4). `{ "replaces": "event", "event": "dies" | "leavesBattlefield" | "toGraveyard", "to": …, "instead": [ … ], "then"?: [ … ] }`; `toZone: "exile"` on `leavesBattlefield` is "would be exiled". - **"Counters can't be put on ~ except by its own abilities" / "these counters can't be put on it by any other means"** — a `putCounters` replacement with `from` (the source of the placing effect): `{ "replaces": "event", "event": "putCounters", "to": { "mode": "self" }, "counter": "adaptation", "from": { "of": "object", "mode": "all", "filter": { "other": true } }, "prevent": true }`. - **"Until the next turn ends" / "until the stack is empty"** — the durations `untilEndOfNextTurn` (whoever's turn it is) and `untilStackEmpty` (the next time a player would receive priority with nothing on the stack). - **"Players can't untap more than two permanents during their untap steps" / "Each spell costs at least {3} to cast" / "Creatures entering the battlefield don't cause abilities to trigger"** — the statics `untapLimit` (`amount`, a `filter` for "more than one land", `who`; the active player picks which untap — Static Orb, Winter Orb, Smoke), `costFloor` (`amount`, spell `filter`, `who` — Trinisphere) and `suppressTriggers` (`events: ["enters" | "dies"]`, a permanent `filter` — Torpor Orb, Hushbringer). - **"No more than two creatures can attack you each combat" / "Creatures can't attack you unless their controller pays {2} for each creature they control that's attacking you" / "you may reselect which player or permanent target attacking creature is attacking"** — the static `attackLimit` (`amount`, `defending`; attacks on that player's planeswalkers don't count, and without `defending` it limits every attacker — Crawlspace, Silent Arbiter); `cantAttack` with `unlessPays` (a cost per creature attacking one of `defending`, with `planeswalkers` also their planeswalkers; `genericAmount` for "{X}, where X is …" — Ghostly Prison, Propaganda, Sphere of Safety): the attacking player pays the total while declaring attackers, or declares again (CR 508.1d, 508.1g-i); and the effect `reselectAttack` (Misleading Signpost: any player other than the creature's controller, or their planeswalker or battle, ignoring attack restrictions and costs; no attack trigger). - **"If this card is in your opening hand, you may begin the game with it on the battlefield" / "You may reveal this card from your opening hand. If you do, …" / "… you may exile it. If you do, …"** — the ability kind `openingHand` (CR 103.6): `action: "battlefield"` (default), `"reveal"` or `"exile"`, a `condition` read when the choice is offered ("if you're not the starting player"), `counters` it begins the game with (Gemstone Caverns' luck counter) and `then` effects that follow at once ("If you do, exile a card from your hand"). The Leylines, the Chancellors. - **"Whenever an opponent draws a card except the first one they draw in each of their draw steps"** — the `drawsCard` trigger's `exceptFirstInDrawStep: true` (Orcish Bowmasters). **"Choose a color. Add an amount of mana of that color equal to your devotion to that color"** — `devotion` with `colors: ["chosen"]` (Nykthos). **"The number of colors in your commander's color identity"** — `{ kind: "commanderIdentityColors" }` (War Room; 0 outside Commander). **"Spend this mana only to cast a creature spell of the chosen type. That spell can't be countered"** — a mana restriction with `uncounterable: true` (Cavern of Souls, Boseiju). **"Draw that many cards minus one"** — `discard` … `drawDiscardedOffset` (Dark Deal). **"Cast it by paying life equal to its mana value rather than paying its mana cost"** — `castFree` … `payLife: { "kind": "affected", "property": "manaValue" }` (Anrakyr the Traveller; always offered as a choice). **"An artifact card with mana cost {0} or {1}"** — the filter `manaCosts: ["{0}", "{1}"]` (Urza's Saga; a card with {X} or no cost does not match). - **"with toughness X or less" / "with total power 6 or less" / "with different names" / "with equal toughness"** — computed bounds and group constraints on a selection. `filter.minToughnessValue` / `maxToughnessValue` take any value (a var, `noted`, a count), resolved when the filter is checked (CR 208.1, 608.2h). On a `target`, `maxTotalPower` caps the chosen objects' summed power, `distinctBy` (`name` / `manaValue` / `controller` / `power`) requires pairwise-different values, and `equalBy` (`toughness` / `power` / `manaValue`) requires one shared value; all are validated on the whole selection when it is made (CR 601.2c, 608.2d), so an illegal group is refused rather than trimmed. - **"Casualty X. The copy isn't legendary and has starting loyalty X." / "If a card you didn't control would be put into an opponent's graveyard from anywhere, exile it instead. During your turn, you may play cards exiled with ~. If you cast a spell this way, pay life equal to its mana value rather than pay its mana cost." / "Whenever an opponent loses life for the first time during each of their turns"** — `{ keyword: "casualty", amount: "X", except: { notLegendary: true, loyalty: { kind: "var", name: "X" } } }`: the caster picks X as they cast (up to the sacrificed creature's power) and the copy is made with the `except` (CR 707.9; `copySpell` takes the same `except`) — Ob Nixilis, the Adversary. An event replacement `toGraveyard` with `to: { mode: "all", filter: { isToken: false, owner: "opponent", controller: "opponent" } }`, `zone: "exile"` and `link: true` exiles the card "with" the source (CR 400.7), and a static `playerRule` `playLinkedExile` with `condition: { kind: "isYourTurn" }` and `payLife: { kind: "affected", property: "manaValue" }` plays those cards for life instead of mana — a mandatory alternative cost (CR 118.9), lands free — Valgavoth, Terror Eater (the same `payLife` on `playFromLibrary` is Bolas's Citadel). A `lifeLost` trigger with `by: "opponent"`, `firstEachTurn: true` and `eventCondition: { kind: "anyPlayer", who: "triggeringPlayer", condition: { kind: "isYourTurn" } }` fires once per opponent's own turn, counting losses before the source arrived (CR 603.2) — Valgavoth, Harrower of Souls. - **"for each of its colors" / "the number of times ~ has mutated" / "your highest commander tax"** — values: `{ "kind": "affected", "property": "colors" }` counts the colors of the object an earlier effect acted on, using last-known information once it has left (CR 105.2, 608.2h); `{ "kind": "triggering", "property": "colors" }` counts the triggering spell's or permanent's colors; `timesMutated` is the number of creature cards merged under the source (CR 702.140); `{ "kind": "commanderTax", "op": "max", "who": "you" }` is {2} per previous cast from the command zone, highest among that player's commanders (CR 903.8). **1b. A registered native ability — only the ids this server ships.** `{ "effect": "native", "id": "", "params": { … }, "text": "" }` (also `{ "type": "native", "layer": "L6" }` as a static part, `{ "kind": "native" }` as a value or a condition, and `filter.native`) names an ability **implemented in the engine** by the game module — cards still contain no code, and a card naming an id the running engine doesn't know is rejected when it is saved and when a game is dealt. The ids that exist are listed, with their `params`, on the `native` page of each kind (`https://drawstep.xyz/wiki/mtg/effects/native.md`, `statics/native.md`, `values/native.md`, `conditions/native.md`) — generated from the registry itself; today: `magic.keepOnePerTypeSacrificeRest` ("for each player, choose one artifact, one creature, one enchantment and one planeswalker they control; then each player sacrifices all other nonland permanents they control" — Tragic Arrogance, Cataclysm). **Never invent an id**: a clause the vocabulary cannot say and no registered native implements goes to rung 2, not to a made-up native. A native that several cards need graduates to a vocabulary node (the engine's own extensibility plan, `research/10-extensibility.md`). - **"Counter target spell … If it was a legendary spell, …" / "for each spell countered this way"** — `{ "kind": "doneThisWay", "of": "countered" }` (with an optional `filter`) reads the spell this effect countered as it last existed on the stack (CR 701.6a, 608.2h). Only spells count; countering an ability isn't recorded, and a spell that couldn't be countered wasn't countered this way. - A spell's `stackRules` apply to that spell and its copies. Use an optional `condition` with the appropriate rules (`cantCounter`, `cantPreventDamage`, `cantCopy`, `splitSecond`). A copy uses its own controller and keeps its announced X and kicker payments. Use `castAnotherNamedSpell` when a resolving spell asks whether its controller cast another spell of a given name this game. For a spell that must come from its controller's hand, use `{ kind: "castFrom", zone: "hand", owner: "you" }`. - **Entry and attachment choices.** The Mimeoplasm's `entersAsCopy.exilePairForCounters` lets its controller exile two creature cards from any graveyards and choose which one to copy. The other card supplies the counter amount in exile. Sanctuary Blade's `asAttaches` stores its color on the Equipment when it attaches to a different creature. A protection grant reads that stored color. - **Casting and activation costs.** For Wayta, `matchingTargetCount` counts distinct targets matching the modifier. For Tezzeret, `firstOfPermanentType` counts earlier activations by that player, including mana abilities. Marshland Bloodcaster's `nextSpellHas` grants an alternative cost using the mana value of the spell being cast. A completed cast uses up the grant even when the player pays normally. - **Multiplayer resolution.** Use `forEachPlayer.atAnnouncement` when a spell or reflexive trigger declares a target for each eligible opponent. Use `shufflePermanentsAndReveal.battlefieldGroups` when each owner's shuffled permanents determine how many cards they reveal and each group of card types enters together across all players. Auras can enchant permanents from an earlier group. - For a choice each player makes as a permanent enters, use an option choice with `who: "eachPlayer"`. A static ability can select controllers by their `choseOption` condition. Each permanent keeps its own choices. - When another sacrifice must share a card type with a permanent just sacrificed, compare against the sacrificed permanent's battlefield characteristics using `sharesWith` and `thisWay`. Use `doneThisWay` with a player selector to check which opponent sacrificed. - For a printed limit on copies in a deck, keep the sentence in the card's Oracle text. The deck builder and validator enforce the self-named allowance. Reserve `tableRuling` for decisions players actually need to adjudicate during play. - For a ceiling on base power or toughness, use `maxBasePower` or `maxBaseToughness`. Combine the two filters with `anyOf` when either characteristic can qualify. Counters and other bonuses to current power or toughness do not change the base values. - For a death-or-command trigger such as Reyhan's, use `fromZones` to distinguish a direct move from the battlefield. Test counters on the departing creature and read the count from its last known state. - Use `boastActivationLimit` for a static change to how many times a creature can boast. Its normal attack requirement and activation costs still apply. After a `discover` effect, `var: discoverDifference` gives the discover number minus the mana value of the card discovered, or zero when no card was discovered. - **"Cast this spell only before the combat damage step"** — spell `onlyIf: { "kind": "phase", "is": "beforeCombatDamage" }`: the beginning phase, the precombat main phase, or the beginning of combat, declare attackers or declare blockers step, while no combat damage step has begun this turn (CR 510); the postcombat main phase and end step never qualify. - **"Seek … from among the top ten cards of your library, then shuffle"** — `seek` with `fromTop` (the candidates are only the top N cards as the effect starts; seeking puts random matching ones into your hand) and `shuffle: true` (shuffle afterwards, CR 701.24). **2. One step the table carries out: the `tableRuling` effect.** When a clause's *timing* is clear (a trigger, an activation, one step of a resolution) but its *action* is not in the vocabulary, keep the ability automated and put `{ "effect": "tableRuling", "text": "" }` where the step belongs (`prompts` adds questions whose answers the table records). The engine runs the trigger, the costs, the targets and the other effects, pauses at that step with the printed text, records the table's outcome and continues. In strict enforced play the step is inert and the card is flagged — never resolved by guesswork. **3. Not a game action: an on-demand table ruling.** Deck-construction and format sentences ("You may have creatures of these types of any color in a deck with ~ as commander") are checked when the deck is built, not during play. Write a standalone `{ "kind": "tableRuling", "ruling": "formatReference", "onDemand": true, "text": "" }` ability: it never pauses casting, entry or resolution; the table records it when someone asks. **4. Last resort: `unparsed`.** Only text that rewrites how *other* cards work with no capturable timing goes verbatim into `unparsed[]`; the card is then shown as partially enforced. Say in your note which rung you used. **No template cards.** A custom card is built from its own printed text, clause by clause, with the primitives above — never by copying another player's card that "looks similar": two cards that share a name or a mechanic routinely differ in a word ("each turn" vs "each combat", "exile" vs "reveal"), and the engine read-back is the check that the JSON says what *this* card says.