Name:Desperate Gambit
ManaCost:R
Types:Instant
A:SP$ ChooseSource | Choices$ Card.YouCtrl,Emblem.YouCtrl | RememberChosen$ True | SubAbility$ CoinFlip | SpellDescription$ Choose a source you control and flip a coin. If you win the flip, the next time that source would deal damage this turn, it deals double that damage instead. If you lose the flip, the next time it would deal damage this turn, prevent that damage.
SVar:CoinFlip:DB$ FlipACoin | WinSubAbility$ CreateWinEffect | LoseSubAbility$ CreateLossEffect | ConditionDefined$ Remembered | ConditionPresent$ Card | ConditionCompare$ GE1
# Winning Effect
SVar:CreateWinEffect:DB$ Effect | Name$ Desperate Gambit's Effect — Won The Flip | ReplacementEffects$ EventWinDamageDone | RememberObjects$ Remembered
SVar:EventWinDamageDone:Event$ DamageDone | ValidSource$ Card.IsRemembered,Emblem.IsRemembered | ReplaceWith$ DmgTwice | Description$ The next time source would deal damage this turn, it deals double that damage instead.
SVar:DmgTwice:DB$ ReplaceEffect | VarName$ DamageAmount | VarValue$ WinX | SubAbility$ ExileEffect
SVar:WinX:ReplaceCount$DamageAmount/Twice
# Losing Effect
SVar:CreateLossEffect:DB$ Effect | Name$ Desperate Gambit's Effect — Lost The Flip | ReplacementEffects$ EventLossDamageDone | RememberObjects$ Remembered
SVar:EventLossDamageDone:Event$ DamageDone | ValidSource$ Card.IsRemembered,Emblem.IsRemembered | ReplaceWith$ ExileEffect | PreventionEffect$ True | Description$ The next time it would deal damage this turn, prevent that damage.
SVar:ExileEffect:DB$ ChangeZone | Defined$ Self | Origin$ Command | Destination$ Exile
AI:RemoveDeck:All
Oracle:Choose a source you control and flip a coin. If you win the flip, the next time that source would deal damage this turn, it deals double that damage instead. If you lose the flip, the next time it would deal damage this turn, prevent that damage.
