# Drawstep engine wiki — How the engine reads a card > Zones, the stack, layers, triggers, the replacement pipeline and decision prompts — what happens to your JSON at the table. Engine: Magic: The Gathering (`mtg`). Page: https://drawstep.xyz/wiki/mtg/overview · Raw Markdown: https://drawstep.xyz/wiki/mtg/overview.md · Complete AI pack (every topic in one document, with the output contract and worked examples): https://drawstep.xyz/wiki/drawstep-mtg-ai-pack.md. This page is generated from Drawstep's card schema; field names and discriminators are exact. A card definition is one JSON object; anything the vocabulary cannot express goes verbatim into `unparsed` instead of being approximated. ## How the engine reads a card Every card in Drawstep — stock or custom — is a **declarative JSON document** interpreted by one rules engine. Cards never carry code; the engine reads the same vocabulary for a 1993 common and for a card you wrote this morning, so a custom card gets exactly the same enforcement as a printed one. Here is what happens to your JSON at the table. **Campaign extensions.** Roguelike campaigns use this same engine and card vocabulary. Modified physical cards receive campaign-scoped definitions, while initial passive powers use validated emblem definitions in the command zone. The server opts a campaign table into these packages and its starting-life values; its journal and replay retain them. Ordinary tables keep their normal setup, and the original card library is unchanged. **Authoring a roguelike campaign.** Use the [campaign authoring guide](https://drawstep.xyz/campaign-authoring.md), [campaign JSON schema](https://drawstep.xyz/campaign.schema.json) and an exported campaign alongside this reference. The campaign schema owns generated routes and optional freeform authored graphs (`roguelike.acts[].route`: canvas height, node positions and directed connections), persistent life/gold, reward categories, Discovery quantity ranges, draft and deck rules, ascensions, mastery, saves, artwork and palettes. These are not new card abilities. Put life recovery, victory gold and extra lives in campaign packages; put in-battle abilities in complete validated emblem/card definitions using this reference. An Augment replaces one physical instance, including while it is in reserve; commander and land eligibility must be explicit. Choosing several Augments in one cache requires different targets. Tier II ascension replaces tier I; equip one mastery package. Never invent a new engine effect to encode these campaign transitions, overwrite a stock card, or copy campaign-only powers into ordinary games. Prices, exact XP curves, commander lists and decks are authored content, not fixed engine semantics. **Portable campaign images.** Campaign management accepts JSON or a ZIP containing `campaign.json` and referenced PNG/JPEG/WebP/GIF images under `assets/`. The JSON format is unchanged; ZIP image paths are rewritten to local uploads only after a developer or admin reviews and applies the import. Preserve image files and crop settings when editing an exported ZIP. Music/sounds stay linked, stock library art is not bundled, and ZIP transfer adds no engine effects. See the campaign authoring guide for limits and the complete workflow. **Table decisions and shortcuts.** The table generates instructions from the exact declarative ability/effect that needs a choice, including legal restrictions and fixed trigger amounts. These instructions do not grant visibility or change the legal response. Custom cards use the same controls as stock cards. Describe real mechanics in the schema; do not author UI commands or an "infinite" resource value. Shortcuts describe a finite result, list the demonstrated sequence and let each opponent choose an earlier response point. The server verifies ordinary engine inputs and records them for replay; unverified, hidden/random or resource-consuming sequences stay manual. A verification limit never implies a draw. **Living campaign backdrops.** Every format accepts optional `backgroundScene` over `backgroundUrl` (image or animated GIF), with `backgroundDim`. Overview → Living backdrop edits up to 12 ordered ambient layers: dust, fireflies, embers, snow, rain, stars, bubbles, petals, fog, glow, rays and aurora. Layers have color, opacity, density, size, speed, placement and blending controls; presets and non-destructive image framing/camera controls share the actual player preview. System reduced motion and a device-local pause keep GIFs and effects still. Quality caps rendering work. Settings are cosmetic, version-pinned and exported with campaign JSON/ZIP; match table themes remain separate. See the campaign guide for all schema fields. **Commander campaign acquisition.** The Severed Atlas opts into `cardAcquisition`: 20 free basics plus a 79-card enforced-library draft guided toward 38 lands, contextual power tiers, enemy/library rewards, and saved reroll currency. Tiers use curated commander decks, thematic affinity, roles, popularity and supported two-to-four-card combos throughout the commander's colors, even without the commander as a piece. Finishing lines and infinite-resource engines set rarity floors; all partners must be legal and enforced. A separate fast-mana bonus weighs early mana output against casting/activation/material costs, setup, restrictions and the commander's mana needs. Cards show the resulting Fast mana +N contribution alongside combo/fit explanations, not bracket labels. Ordinary rocks and filters do not get this extra bonus; unknown variable production is not assumed to be maximized. Every full commander draft round reserves two distinct authored commander seeds across its packets, and each reward section reserves one when eligible picks remain in its own pool. Rerolls preserve these guarantees, rarity weights and land targets; other slots retain full-library discovery. Commander mechanics exposes seededDraftSlots (0–4, default 2) and seededRewardSlots (0–3, default 1). Starter/kit foundations, additional picks, nonbasic reference lands and matching decks supply seeds, shown with Commander seed badges. Enemy spoils never invent cards outside the defeated decks; saved offers stay unchanged. `startingRerolls` defaults to 5; `encounter.rewards.rerollReward` overrides the normal/boss victory defaults of 2/3. A reroll costs one and unused currency carries forward. Easy/Medium/Hard is fixed when starting a new save; composer `difficultySettings` tunes bot ceilings and rarity boosts. New commander unlocks draft at their difficulty's starting odds; returning to an unlocked commander restores its saved deck. Typed-land eligibility is checked. Composer **Commander mechanics** configures optional `cardAcquisition.rules`: included basics/land target, focused packets, loot reservations, enemy commander drops, start/end rarity weights, progression, victory currency defaults and sanctuary returns. Act provisions and legacy reward pools do not drive procedural loot; starter/kit lists remain rarity guidance. The simulation is an authored-deck benchmark and does not model acquisition or campaign difficulty. These are campaign transitions, not card effects. See the campaign guide for quotas, scoring, rarity curves, legacy-version compatibility and save behavior. **Zones.** An object is always in exactly one zone: `library`, `hand`, `battlefield`, `graveyard`, `exile`, `stack` or `command`. Moving between zones creates a new object (CR 400.7); filters and targets name the zone they look in (`zone`, default battlefield). A graveyard departure also triggers when the card returns to the battlefield or is cast from there. Thran Vigil groups simultaneous departures and can target a creature that just returned during your end step. **Casting and the stack.** Casting a spell or activating an ability puts it on the stack with its choices made (CR 601.2): modes (`modes`, `chooseMin/Max`), targets (every TargetDef in `mode: "chosen"` prompts the controller and is checked for legality), X (`{ "kind": "var", "name": "X" }`), and costs (`cost`, `additionalCost`, keyword alternative costs). Players then receive priority in turn; when all pass, the top object resolves: its `effects` run **in order**, each target is re-checked (an illegal target makes that part fizzle, CR 608.2b), nested lists (`if.then`, `optional.then`, `mayPay`) run only when their guard holds. **Prowl (CR 702.76a).** A spell with prowl can use its alternative cost after a source you controlled dealt combat damage to a player this turn and shared at least one of the spell's creature types at the time of damage. First-strike damage qualifies; damage to creatures or planeswalkers and noncombat damage do not. Hunting Velociraptor grants Dinosaur spells prowl {2}{R}, including Etali, Primal Conqueror cast from the command zone; commander tax still applies. The qualifying damage lasts for the turn and is not consumed by a cast. Printed prowl and a currently active spell-keyword grant use the same requirement. Existing games retain their recorded rules version; the corrected casting check applies to new games. **Triggered abilities.** The engine emits an event for everything that happens (an object entered, a creature died, a player drew, combat damage was dealt, …). Each `{ kind: "triggered", trigger }` watches one `event`, narrowed by `by` (whose action / turn), `filter` (which object — `self: true` for the card itself) and an intervening-if `condition`. Triggers wait until a player would receive priority, then go on the stack in APNAP order (CR 603.3); `optional: true` makes them "you may". **Static abilities and layers.** A `{ kind: "static" }` ability does not use the stack: it applies continuously while its source is on the battlefield (or, with `eminence`, in the command zone) and its `condition` holds. Every static part is applied through the CR 613 layer system — copy (1), control (2), text (3), type (4), color (5), abilities (6), power/toughness (7a–7d) — ordered by dependency and then timestamp, so authors never encode ordering. One printed ability that touches several layers (Humility: lose all abilities *and* base P/T 1/1) is one static with several `effects`, so its parts stay together (CR 613.6). One-shot effects with a `duration` (`modifyPT`, `grantKeyword`, `becomeCopy`, …) create timestamped continuous effects that go through the same layers. **Replacement effects.** Before an event happens it passes through a replacement pipeline: each applicable `{ kind: "replacement" }` may rewrite or cancel it (enters tapped, enters with counters, damage prevention, "if ~ would die, exile it instead", "if you would draw a card, instead …"). Each replacement applies at most once per event. The affected player or controller chooses among competing replacements (CR 616). For Ojer Axonil, compare the incoming damage with its current power each time you determine which effects still apply. Temple of Power counts the noncombat damage actually dealt by red sources you controlled at the time, including damage to permanents. **State-based actions** (lethal damage, zero toughness, 0 life, 10 poison, legend rule, Aura attachment legality, planeswalker loyalty 0, …) are checked whenever a player would receive priority. You never write them; they follow from the characteristics you declare. **Winota's private look.** When a non-Human creature you control attacks, Winota shows you the top six cards in library order. Acknowledge the look, then choose a Human creature to enter tapped and attacking or skip the choice. If none qualifies, acknowledging the look puts all six on the bottom in random order. Opponents and spectators see only the Human that enters. **Decision prompts.** Whenever the engine needs a human choice it suspends and sends a typed request to the right seat — choose targets, choose modes, yes/no (`optional`), choose a number (X), order triggers or blockers, select cards from a zone (`searchLibrary`, `digTop`), pay or decline a cost (`mayPay`, `unlessPays`). Your JSON decides *when* a prompt appears: `mode: "chosen"` prompts at cast time, `mode: "choose"` prompts on resolution, `mode: "all"` never prompts. **Composition.** The vocabulary is not a menu of finished effects; it is a small set of primitives whose axes are **independent**, and any value on one axis combines with any value on another. What varies on each family: - *Effects* carry `who` (any player selector), `target` (the selection algebra — `of` × `mode` × `zone` × `player` / `playerTarget` × `filter` × `min` / `max` × `chooser`; see **Filters & targets**), `amount` (any ValueDef) and `duration`. The control-flow effects — `if`, `optional`, `mayPay`, `unlessPays`, `forEachPlayer`, `forEachObject`, `repeat`, `choose`, `ifDone`, `delayedTrigger`, `reflexiveTrigger` — nest *any* list of effects, so "do X; if you do, Y", "for each opponent, Z" and "when that creature dies this turn, …" are structure, not primitives. - *Values* compose: `count` of any filter in any zone for any player, `math` over any values, `affected` / `triggering` / `doneThisWay` / `costPaid` reading what earlier steps selected or paid. - *Conditions* combine with `all` / `any` / `not`, and the same ConditionDef serves `if` effects, intervening-if triggers, "as long as" statics, `onlyIf` activations and replacement `unless`. - *Triggers* are `event` × `filter` × `by` × `condition` × `triggersFrom` (the zone the ability works from) × `onceEachTurn` / `onlyOnce` × `optional`. - *Statics* are a layer effect × `to` (the same TargetDef algebra) × `condition`; *replacements* are `replaces` × filter × `optional` / `firstEachTurn` × any effects in their `instead` / `then`; *costs* are any combination of parts in one object, reused by keywords, `mayPay` and `unlessPays`. - *Back-references* — `affected`, `thisWay`, `triggering`, `triggeringOther`, `about`, `created`, `linked` — make any earlier selection the input of a later effect, so multi-step text chains without new vocabulary. A new mechanic is therefore almost always a new *combination*. Compose it first; the validator says whether it holds and **Explain** reads it back. Only when a composition genuinely cannot express a clause does the honesty ladder apply. **Honesty.** A card is "fully enforced" when every printed line is expressed in the vocabulary. The engine leaves room for mechanics the vocabulary lacks without ever approximating them — see **Custom mechanics** for the ladder: a `tableRuling` *effect* keeps an ability automated and pauses at the one step the table carries out; an `onDemand` table ruling records a deck-construction or format sentence without pausing play; anything whose timing cannot be captured either stays verbatim in `unparsed[]`, and the table shows the card as *partially enforced*. Approximating ("close enough") is never acceptable — a card that does something different from its text is a bug at the table. **Natives and adjudication.** Two more things sit beside the vocabulary. A **native** (`{ "effect": "native", "id": … }`, also as a static part, a value, a condition or a filter) is an ability the game module implements in the engine under a registered id — the card still carries no code, and an id the running engine has not registered is rejected when the card is saved and when the game is dealt, so a card can never name one that does not exist. **Adjudication** is a table feature, not card vocabulary: while a `tableRuling` step has the engine paused, any seat may propose a bounded manual change (move cards, counters, life, tap, a token, attach, control, transform, a note) and the other players approve or reject it; the engine applies an approved change with its own primitives, then runs state-based actions and triggers, and logs it. The card stays *partially enforced* — the ladder is unchanged, the table just has hands — and nothing about it is written in a card.