Name:Out of the Tombs
ManaCost:2 B
Types:Enchantment
T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerZones$ Battlefield | Execute$ BuildCounter | TriggerDescription$ At the beginning of your upkeep, put two eon counters on CARDNAME, then mill cards equal to the number of eon counters on it.
SVar:BuildCounter:DB$ PutCounter | CounterType$ EON | CounterNum$ 2 | Defined$ Self | SubAbility$ DBMill
SVar:DBMill:DB$ Mill | NumCards$ X
SVar:X:Count$CardCounters.EON
R:Event$ Draw | ActiveZones$ Battlefield | ValidPlayer$ You | IsPresent$ Card.YouOwn | PresentZone$ Library | PresentCompare$ EQ0 | ReplaceWith$ Reanimate | Description$ If you would draw a card while your library has no cards in it, instead return a creature card from your graveyard to the battlefield. If you can't, you lose the game.
SVar:Reanimate:DB$ ChangeZone | Origin$ Graveyard | Destination$ Battlefield | ChangeType$ Creature.YouOwn | ChangeNum$ 1 | Mandatory$ True | SelectPrompt$ Choose a creature card to return to the battlefield | Hidden$ True | RememberChanged$ True | SubAbility$ DBLoseGame
SVar:DBLoseGame:DB$ LosesGame | Defined$ You | ConditionDefined$ Remembered | ConditionPresent$ Card | ConditionCompare$ EQ0 | SubAbility$ DBCleanup
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
DeckHas:Ability$Graveyard|Mill|Counters
Oracle:At the beginning of your upkeep, put two eon counters on Out of the Tombs, then mill cards equal to the number of eon counters on it.\nIf you would draw a card while your library has no cards in it, instead return a creature card from your graveyard to the battlefield. If you can't, you lose the game.
