Name:Birthing Ritual
ManaCost:1 G
Types:Enchantment
T:Mode$ Phase | TriggerZones$ Battlefield | Phase$ End of Turn | ValidPlayer$ You | IsPresent$ Creature.YouCtrl | Execute$ TrigPeek | TriggerDescription$ At the beginning of your end step, if you control a creature, look at the top seven cards of your library. Then you may sacrifice a creature. If you do, you may put a creature card with mana value X or less from among those cards onto the battlefield, where X is 1 plus the sacrificed creature's mana value. Put the rest on the bottom of your library in a random order.
SVar:TrigPeek:DB$ PeekAndReveal | Defined$ You | NoReveal$ True | PeekAmount$ 7 | SubAbility$ DBSacrifice
SVar:DBSacrifice:DB$ Sacrifice | SacValid$ Creature | Optional$ True | RememberSacrificed$ True | SubAbility$ DBDig
SVar:DBDig:DB$ Dig | DigNum$ 7 | ConditionDefined$ Remembered | ConditionPresent$ Card | ChangeValid$ Creature.cmcLEX | ChangeNum$ 1 | SubAbility$ DBDigBis | Optional$ True | DestinationZone$ Battlefield | RestRandomOrder$ True
SVar:DBDigBis:DB$ Dig | DigNum$ 7 | ConditionDefined$ Remembered | ConditionPresent$ Card | ConditionCompare$ EQ0 | ChangeValid$ Card.cmcLEX | ChangeNum$ 0 | SubAbility$ DBCleanup | Optional$ True | DestinationZone$ Library | RestRandomOrder$ True
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
SVar:X:Remembered$CardManaCost/Plus.1
DeckHas:Ability$Sacrifice
Oracle:At the beginning of your end step, if you control a creature, look at the top seven cards of your library. Then you may sacrifice a creature. If you do, you may put a creature card with mana value X or less from among those cards onto the battlefield, where X is 1 plus the sacrificed creature's mana value. Put the rest on the bottom of your library in a random order.
