Name:Indomitable Creativity
ManaCost:X R R R
Types:Sorcery
A:SP$ Destroy | ValidTgts$ Artifact,Creature | TargetMin$ X | TargetMax$ X | TgtPrompt$ Select X target artifacts and/or creatures | Origin$ Battlefield | Destination$ Graveyard | RememberDestroyed$ True | SubAbility$ DBTransform | StackDescription$ Destroy {c:Targeted}. | SpellDescription$ Destroy X target artifacts and/or creatures. For each permanent destroyed this way, its controller reveals cards from the top of their library until an artifact or creature card is revealed and exiles that card. Those players put the exiled cards onto the battlefield, then shuffle.
SVar:DBTransform:DB$ RepeatEach | UseImprinted$ True | DefinedCards$ DirectRemembered | ChooseOrder$ True | RepeatSubAbility$ DBReveal | SubAbility$ DBPutOnBattlefield | StackDescription$ For each permanent destroyed this way, its controller reveals cards from the top of their library until an artifact or creature card is revealed and exiles that card. Those players put the exiled cards onto the battlefield, then shuffle their libraries.
SVar:DBReveal:DB$ DigUntil | Defined$ ImprintedController | Amount$ 1 | Valid$ Artifact,Creature | ValidDescription$ artifact or creature | RevealedDestination$ Library | RevealedLibraryPosition$ 0 | RevealRandomOrder$ True | FoundDestination$ Exile | RememberFound$ True | SubAbility$ DBForget
SVar:DBForget:DB$ Pump | ForgetObjects$ Imprinted | SubAbility$ DBCleanup
SVar:DBCleanup:DB$ Cleanup | ClearImprinted$ True
SVar:DBPutOnBattlefield:DB$ ChangeZoneAll | ChangeType$ Card.IsRemembered | Origin$ Exile | Destination$ Battlefield | SubAbility$ DBShuffle
SVar:DBShuffle:DB$ Shuffle | Defined$ ParentTargetedController | SubAbility$ DBCleanRemembered | StackDescription$ None
SVar:DBCleanRemembered:DB$ Cleanup | ClearRemembered$ True
SVar:X:Count$xPaid
Oracle:Destroy X target artifacts and/or creatures. For each permanent destroyed this way, its controller reveals cards from the top of their library until an artifact or creature card is revealed and exiles that card. Those players put the exiled cards onto the battlefield, then shuffle.
