# Drawstep engine · Replacements · `event` > Event — A general replacement effect: which event, which objects / players / sources, and what happens instead. Engine: Magic: The Gathering (`mtg`). This is one primitive of the Drawstep card vocabulary; field names and the discriminator are exact. Wiki page: https://drawstep.xyz/wiki/mtg/replacements#event ## Where it goes A replacement ability: `{ "kind": "replacement", "replacement": { "replaces": "event", … } }`. Printed words that point here (search aliases): if would deal damage prevent instead would die exile would draw would gain life twice that many counters tokens doubling redirect general replacement cr 614 while an opponent is searching their library they exile each card they find would be destroyed or exiled orevents would leave the battlefield return it to the battlefield under an opponent's control instead deals 0 combat damage to its owner counters can't be put on except by its own abilities can't be increased through any other means. ## Fields | Field | Type | Required | Description | |---|---|---|---| | `event` | `"damage" \| "draw" \| "drawBatch" \| "beginTurn" \| "beginStep" \| "dies" \| "toGraveyard" \| "leavesBattlefield" \| "enters" \| "destroy" \| "counter" \| "copySpell" \| "untap" \| "createTokens" \| "putCounters" \| …` | yes | CR 614-616: watch countering spells (701.6), damage, individual or batch draws (121.2a), turn/step beginnings (500, 614.10), zone changes and entry (614.12), token creation (111), counters (122), life and game loss (104), mana production or loss (106), searches (701.23), keyword actions (701), and dice/coin result sets (705-706) | | `to` | `TargetDef` | no | The object(s) the event would happen to (default: the source itself when toPlayer is absent — or, for a damage event with `from` written, whatever that source would damage): mode all + filter, self, host, or — created by the one-shot effect — chosen / affected | | `toPlayer` | `"you" \| "controller" \| "abilityController" \| "sourceController" \| "owner" \| "eachOpponent" \| "eachPlayer" \| "target" \| "triggeringPlayer" \| "defendingPlayer" \| "attackingPlayer" \| "activePlayer" \| "re …` | no | The player(s) the event would happen to: damaged, drawing, gaining / losing, milling; the controller tokens / counters would go to | | `from` | `TargetDef` | no | damage: the source must match ("a red source", "creatures", "sources you don't control", of: spell = "a spell"); mode choose = "a source of your choice", picked as the effect resolves. putCounters: the source of the effect placing the counters (mode all + filter other = "by a source other than this one"). With to self, counter and prevent: true that is "Adaptation counters can't be put on ~ except by its own abilities" — proliferate and every other spell or ability are stopped, the card's own abilities still put them (CR 122.1, 614.1a) | | `by` | `"you" \| "controller" \| "abilityController" \| "sourceController" \| "owner" \| "eachOpponent" \| "eachPlayer" \| "target" \| "triggeringPlayer" \| "defendingPlayer" \| "attackingPlayer" \| "activePlayer" \| "re …` | no | The controller of the effect creating tokens, placing counters, or countering a spell | | `lifeLossBy` | `"you" \| "controller" \| "abilityController" \| "sourceController" \| "owner" \| "eachOpponent" \| "eachPlayer" \| "target" \| "triggeringPlayer" \| "defendingPlayer" \| "attackingPlayer" \| "activePlayer" \| "re …` | no | Only life loss caused by a spell or ability controlled by these players. Payments of life have no causing controller | | `damageKind` | `"combat" \| "noncombat"` | no | damage: only combat / only noncombat damage | | `minAmount` | `ValueDef` | no | The event's amount must be at least this ("3 or more damage") | | `maxAmount` | `ValueDef` | no | CR 615.1a: only damage events no greater than this amount ("3 or less damage") | | `exactAmount` | `ValueDef` | no | CR 614.1a: only damage events of exactly this amount ("exactly 2 damage") | | `counter` | `string` | no | putCounters: only this kind of counter | | `extraTurnOnly` | `boolean` | no | CR 500.7 / 614.10: watch only extra turns | | `step` | `"untap" \| "draw"` | no | CR 502 / 504: step whose beginning is replaced | | `duringUntapStep` | `boolean` | no | CR 502.3: only during the object's controller's untap step | | `firstEachTurn` | `boolean` | no | CR 614.1a: first matching event each turn for each affected player | | `manaColor` | `string` | no | CR 106: transform retained or produced mana to this type, retaining spending restrictions; "any" = a color of the producer's choice, "chosen" = the color chosen as this ability resolved | | `coloredManaOnly` | `boolean` | no | CR 106.1: transform colored mana only | | `manaFromColors` | `string[]` | no | CR 106.1: transform only mana of these types ("instead of white mana") | | `manaPlayers` | `"you" \| "controller" \| "abilityController" \| "sourceController" \| "owner" \| "eachOpponent" \| "eachPlayer" \| "target" \| "triggeringPlayer" \| "defendingPlayer" \| "attackingPlayer" \| "activePlayer" \| "re …` | no | CR 106.1: produce the same mana for these players instead | | `manaAdditional` | `string[]` | no | CR 106.1: extra mana types produced in the same event | | `manaMultiply` | `number` | no | CR 106.1, 614.1a: "it produces twice as much of that mana instead" — every unit produced that many times, of the same type | | `manaExact` | `string` | no | CR 106.1, 614.1a: "it produces {B} instead of any other type and amount" — the whole production becomes exactly this mana string ({any} = a color of the producer's choice) | | `manaOneColor` | `boolean` | no | With manaExact {any}…: every unit is the same chosen color ("three mana of a color of your choice") | | `tappedForMana` | `boolean` | no | CR 605.1b wording "is tapped for mana" / "you tap … for mana": only mana a {T} mana ability of the source produces, not rituals or other abilities | | `enterController` | `"you" \| "controller" \| "abilityController" \| "sourceController" \| "owner" \| "eachOpponent" \| "eachPlayer" \| "target" \| "triggeringPlayer" \| "defendingPlayer" \| "attackingPlayer" \| "activePlayer" \| "re …` | no | CR 614.12 / 616.1b: enters under this player's control instead | | `chooseEnterController` | `boolean` | no | CR 614.12, 616.1b: "enters under the control of an opponent of your choice" — the replacement's controller chooses one of the players enterController names (no targeting) as it would enter | | `enterTapped` | `boolean` | no | CR 614.1c: enters tapped instead | | `enterAttacking` | `boolean` | no | CR 508.4: enters attacking a legal defender instead | | `enterCounters` | `({ counter: string; amount: ValueDef })[]` | no | CR 614.1c, 122.6: it enters with these additional counters ("this turn, each creature you control enters with an additional +1/+1 counter on it") | | `enterAs` | `EffectDef[]` | no | CR 614.1c, 614.12: continuous effects the entering permanent gets as it enters (target `{ mode: "affected" }`, duration permanent), before its enters abilities trigger — "enters … as a Mutant in addition to its other types" (becomeType), "it becomes a 7/7 Dinosaur creature in addition to its other types" (becomeType + setPT) | | `tokenReplace` | `object[]` | no | CR 111 / 614.1a: each replaced token becomes one of each spec | | `tokenChoices` | `object[]` | no | CR 111 / 614.1a: choose one token spec for the whole event | | `tokenAdditional` | `object[]` | no | CR 111 / 614.1a: keep the tokens and add that many of each spec | | `tokenAdditionalOnce` | `object[]` | no | CR 614.1a, 614.5, 616.1: add one of each spec to this same creation event; prior replacements do not apply again | | `shuffleOwnedIntoLibrary` | `boolean` | no | CR 104.4 / 614.1a: shuffle the affected player's hand, graveyard and all owned permanents into their library | | `randomResults` | `{ add?: number; multiply?: number; ignore?: "lowest" \| "chosen"; chooser?: "you" \| "replacedPlayer"; perDie?: boolean; oneDie?: boolean; sum?: boolean }` | no | CR 706.6 / 705: enlarge a result set, ignore results before triggers, or use its sum | | `dieSides` | `number` | no | CR 706: only dice with this many sides | | `searchTop` | `number` | no | CR 701.23: restrict the searchable library domain to its top N cards | | `ownLibrary` | `boolean` | no | searchLibrary: only a search of the searching player's own library ("while an opponent is searching their library"). With zone, every card that search finds goes to that zone instead of where the instruction would put it; the instruction's other effects can't see them, and `then` runs on them as `affected` (Opposition Agent: zone exile, then exileMayPlay). Several such effects: the player controlling the search chooses one (CR 616.1) | | `regenerate` | `boolean` | no | CR 614.8 / 701.19: regenerate now instead of destruction, unless prohibited | | `removeDamage` | `boolean` | no | CR 701.8: remove all marked damage instead of destruction | | `removeCounterToUntap` | `string` | no | CR 122.2 / 614.1a: remove one counter instead of untapping; untap only when a counter was actually removed | | `removeAllCounters` | `string` | no | CR 122.2: remove all counters of this kind instead | | `tokenFilter` | `ObjectFilter` | no | createTokens: only tokens matching this filter ("one or more Treasure tokens") | | `fromZone` | `"battlefield" \| "hand" \| "graveyard" \| "library" \| "exile" \| "stack" \| "command"` | no | toGraveyard / enters: the object must move from this zone | | `toZone` | `"battlefield" \| "hand" \| "graveyard" \| "library" \| "exile" \| "stack" \| "command"` | no | leavesBattlefield: the object would move to this zone ("if enchanted creature would be exiled" = exile) | | `orEvents` | `({ event: "damage" \| "draw" \| "drawBatch" \| "beginTurn" \| "beginStep" \| "dies" \| "toGraveyard" \| "leavesBattlefield" \| "enters" \| "destroy" \| "counter" \| "copySpell" \| "untap" \| "createTokens" \| "putC …` | no | CR 614.1a: further events the same replacement watches — "if enchanted creature would be destroyed or exiled" = event destroy + orEvents [{ event: leavesBattlefield, toZone: exile }]. All other match fields (to, toPlayer, condition, …) and all result fields are shared; the replacement still applies only once to one event (CR 614.5) | | `discarded` | `boolean` | no | CR 701.9a: toGraveyard — only a discard | | `causedBy` | `"opponent"` | no | CR 701.9a, 614.1a: only an event a spell or ability an opponent controls causes | | `notCast` | `boolean` | no | enters: only permanents that weren't cast | | `exceptFirstInDrawStep` | `boolean` | no | draw: not the first card the player draws in each of their draw steps | | `condition` | `ConditionDef` | no | Checked as the event would happen ("while you have 5 or less life", "if you control a creature") | | `optional` | `boolean` | no | "You may … instead" (draw / createTokens / lifeGain) | | `prevent` | `boolean` | no | The event doesn't happen at all | | `preventAmount` | `ValueDef` | no | CR 615.1a / 615.6: prevent this much of each damage event. Math over replaced.amount supports half that damage with rounding | | `preventAllBut` | `ValueDef` | no | damage: prevent all but this much | | `multiply` | `number` | no | "twice that much" = 2 | | `add` | `ValueDef` | no | "that much plus N" | | `newTargets` | `boolean` | no | CR 707.10c: allow new targets for extra spell copies supplied by this copySpell replacement, even when original copies retain their targets | | `addDieRoll` | `number` | no | CR 614.1a / 706: add the result of a die with this many sides to damage, with normal roll replacements and triggers | | `half` | `"up" \| "down"` | no | "half that damage, rounded up / down" | | `set` | `ValueDef` | no | The amount becomes this instead | | `redirectTo` | `TargetDef` | no | damage: dealt to this object or player instead | | `lifeFloor` | `ValueDef` | no | damage to a player: can't reduce the life total below this | | `zone` | `"battlefield" \| "hand" \| "graveyard" \| "library" \| "exile" \| "stack" \| "command"` | no | Zone-change events: the object goes here instead. searchLibrary with ownLibrary: the found cards go here instead | | `position` | `"top" \| "bottom"` | no | With `zone: "library"`: top or bottom | | `shuffle` | `boolean` | no | With zone library: shuffle it in | | `link` | `boolean` | no | CR 400.7: a card moved to exile (or the command zone) by this replacement is "exiled with" the source — linked to that incarnation of it, so the source's playLinkedExile / castLinkedExile permission and `linked` selections cover it (Valgavoth, Terror Eater: "exile it instead. During your turn, you may play cards exiled with Valgavoth") | | `instead` | `EffectDef[]` | no | Effects that happen instead of the event (the event itself doesn't). On dies / toGraveyard / leavesBattlefield with no zone written, the zone change does not happen and these run in its place ("if enchanted creature would be destroyed, instead it phases out"); a moveTo of the replaced permanent with destination battlefield there returns it to the battlefield as a new object (CR 400.7) — "If ~ would leave the battlefield, return it to the battlefield under an opponent's control instead" (controller: opponent): its counters, damage, attachments and the effects on it are gone, enters abilities trigger and leaves abilities don't | | `then` | `EffectDef[]` | no | Effects that also happen right after the (modified or prevented) event | ## Minimal form ```json {"replaces":"event","event":"damage","causedBy":"opponent"} ``` The engine reads that minimal form as: “if a source would deal damage to ~, that damage is dealt as normal”. ## Stock examples - **Iter99 Draw Doubler** — “” ```json {"replaces":"event","event":"draw","toPlayer":"you","multiply":2} ``` - **Combat Prevention Study** — “” ```json {"replaces":"event","event":"damage","to":{"of":"object","mode":"all"},"toPlayer":"eachPlayer","damageKind":"combat","prevent":true} ``` - **Prevention Shield Study** — “” ```json {"replaces":"event","event":"damage","toPlayer":"you","prevent":true,"then":[{"effect":"gainLife","amount":1}]} ``` ## Related - [Replacements](https://drawstep.xyz/wiki/mtg/replacements.md) — the whole topic - [Filters & targets](https://drawstep.xyz/wiki/mtg/targets.md) — how `target` / `filter` select objects and players (selection algebra) - [Values](https://drawstep.xyz/wiki/mtg/values.md) — every number kind an `amount` accepts - [Effects](https://drawstep.xyz/wiki/mtg/effects.md) — the steps a nested `effects` / `then` list may contain - [Start here](https://drawstep.xyz/wiki/mtg/start.md) — the rules, the output contract and the index of every primitive