# Drawstep engine · Effects · `digTop` > Dig top — e.g. “look at the top a card of your library. Put up to one of them into your hand. Put the rest on the bottom of your library”. 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/effects#digTop ## Where it goes One step of an ability's `effects[]` (a spell's, a trigger's, an activated ability's, a mode's): `{ "effect": "digTop", … }`. Steps resolve in order. Printed words that point here (search aliases): look at the top cards of your library put one in hand rest on bottom impulse. ## Fields | Field | Type | Required | Description | |---|---|---|---| | `exile` | `boolean` | no | CR 406.1, 608.2c: exile the examined cards before picks, then route the uncast cards with restTo | | `amount` | `ValueDef` | no | How many / how much (integer or ValueDef) | | `until` | `ObjectFilter` | no | Stop when a card matching this filter is revealed | | `untilCount` | `ValueDef` | no | How many matching cards to find before stopping | | `reveal` | `boolean` | no | Reveal the cards found / taken | | `who` | `"you" \| "controller" \| "abilityController" \| "sourceController" \| "owner" \| "eachOpponent" \| "eachPlayer" \| "target" \| "triggeringPlayer" \| "defendingPlayer" \| "attackingPlayer" \| "activePlayer" \| "re …` | no | Which player(s) — a player selector (default `you`) | | `target` | `PlayerTargetDef` | no | What it acts on (TargetDef) | | `chooser` | `"you" \| "controller" \| "abilityController" \| "sourceController" \| "owner" \| "eachOpponent" \| "eachPlayer" \| "target" \| "triggeringPlayer" \| "defendingPlayer" \| "attackingPlayer" \| "activePlayer" \| "re …` | no | Who chooses among the cards looked at (defaults to the digging player) | | `piles` | `{ separator?: "you" \| "opponent" \| "target"; chooser?: "you" \| "opponent"; faceDown?: boolean }` | no | Partition into two possibly empty piles, then choose one. Picks apply to that pile; all unpicked cards use restTo. faceDown hides the first pile from its chooser (CR 700.3a-d) | | `picks` | `({ position?: "top" \| "bottom"; faceDown?: boolean; take: number \| "all" \| "any"; min?: number; filter?: ObjectFilter; destination?: "battlefield" \| "hand" \| "graveyard" \| "library" \| "exile" \| "stack …` | no | What the player takes from the cards looked at: each pick `{ take, filter?, destination?, position?, tapped?, … }` | | `take` | `number` | no | How many cards this pick takes | | `min` | `number` | no | Minimum number of selections / required amount | | `optional` | `boolean` | no | "You may": the player chooses whether to do it | | `filter` | `ObjectFilter` | no | Which objects (ObjectFilter; set fields AND together) | | `restTo` | `"bottom" \| "graveyard" \| "hand" \| "exile" \| "shuffle" \| "top"` | no | Where the unpicked cards go (default the bottom of the library) | | `restOrder` | `"random" \| "chosen"` | no | Order of the unpicked cards: `random` or `chosen` by the player | | `restFaceDown` | `boolean` | no | Unpicked cards go to their zone face down | | `shuffleFirst` | `boolean` | no | CR 701.24a: shuffle the library after the examination, then place the rest by identity ("Then shuffle and put the cards you looked at this way on top in any order") | | `link` | `boolean` | no | CR 406.3 / 607.2a: cards this examination exiles (the rest or a pick) are "exiled with" the source, so "cast a card exiled with ~" finds them | | `pool` | `boolean` | no | CR 608.2c-d: with several examining players, the picks choose among all their examined cards together ("Choose one of the revealed creature cards"); the rest go to their owners' zones | | `destination` | `"battlefield" \| "hand" \| "graveyard" \| "library" \| "exile" \| "stack" \| "command"` | no | Zone the objects are put into | | `withCounters` | `object \| object[]` | no | CR 122.6, 614.1c: all matching additional counters are placed as the permanent enters, before triggers | | `tapped` | `boolean` | no | Tapped (true) or untapped (false); on an effect that puts something onto the battlefield, it enters tapped | ## Minimal form ```json {"effect":"digTop"} ``` The engine reads that minimal form as: “look at the top a card of your library. Put up to one of them into your hand. Put the rest on the bottom of your library”. ## Stock examples - **Iteration 35 random-selected** — “” ```json {"effect":"digTop","amount":4,"picks":[{"position":"top","take":2,"destination":"library","order":"random"}],"restTo":"graveyard"} ``` - **Iteration 35 selected-order** — “” ```json {"effect":"digTop","amount":4,"picks":[{"position":"top","take":2,"min":0,"destination":"library","order":"chosen"}],"restTo":"graveyard"} ``` - **Iteration 35 attacking** — “” ```json {"effect":"digTop","amount":4,"picks":[{"take":1,"filter":{"types":["Creature"]},"destination":"battlefield","tapped":true,"attacking":true}],"restTo":"bottom","restOrder":"random"} ``` ## Related - [Effects](https://drawstep.xyz/wiki/mtg/effects.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