Name:Tainted Pact
ManaCost:1 B
Types:Instant
A:SP$ Repeat | RepeatSubAbility$ DBRepeat | RepeatCheckSVar$ TaintedCheck | RepeatSVarCompare$ EQ0 | RepeatDefined$ Imprinted | RepeatPresent$ Card.sharesNameWith Remembered | RepeatCompare$ EQ0 | SubAbility$ DBCleanup | StackDescription$ SpellDescription | SpellDescription$ Exile the top card of your library. You may put that card into your hand unless it has the same name as another card exiled this way. Repeat this process until you put a card into your hand or you exile two cards with the same name, whichever comes first.
SVar:DBRepeat:DB$ Pump | RememberObjects$ Imprinted | SubAbility$ DBForget
SVar:DBForget:DB$ Cleanup | ClearImprinted$ True | SubAbility$ DBExile
SVar:DBExile:DB$ Dig | Defined$ You | DigNum$ 1 | ChangeNum$ All | DestinationZone$ Exile | Imprint$ True | SubAbility$ DBReturnToHand
SVar:DBReturnToHand:DB$ ChangeZone | ConditionCheckSVar$ CheckName | ConditionSVarCompare$ EQ0 | Origin$ Exile | Destination$ Hand | Defined$ Imprinted | Optional$ True | SubAbility$ LibraryCheck
SVar:LibraryCheck:DB$ StoreSVar | SVar$ TaintedCheck | Type$ Number | Expression$ 1 | ConditionCheckSVar$ X | ConditionSVarCompare$ EQ0
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True | ClearImprinted$ True | SubAbility$ DBReset
SVar:DBReset:DB$ StoreSVar | SVar$ TaintedCheck | Type$ Number | Expression$ 0
SVar:TaintedCheck:Count$ValidHand Card.IsImprinted
SVar:CheckName:Imprinted$Valid Card.sharesNameWith Remembered
SVar:X:Count$InYourLibrary.Card
Oracle:Exile the top card of your library. You may put that card into your hand unless it has the same name as another card exiled this way. Repeat this process until you put a card into your hand or you exile two cards with the same name, whichever comes first.
