Name:Power Leak
ManaCost:1 U
Types:Enchantment Aura
K:Enchant enchantment
A:SP$ Attach | Cost$ 1 U | ValidTgts$ Enchantment | AILogic$ Curse
T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ Player.EnchantedController | Execute$ DBPay | TriggerZones$ Battlefield | TriggerDescription$ At the beginning of the upkeep of enchanted enchantment's controller, that player may pay any amount of mana. CARDNAME deals 2 damage to that player. Prevent X of that damage, where X is the amount of mana that player paid this way.
R:Event$ DamageDone | ActiveZones$ Battlefield | ValidSource$ Card.Self | ReplaceWith$ DBReplace | PreventionEffect$ True | Secondary$ True
SVar:DBReplace:DB$ ReplaceDamage | Amount$ PaidAmount
SVar:DBPay:DB$ ChooseNumber | Defined$ EnchantedController | ChooseAnyNumber$ True | ListTitle$ amount of mana to pay | AILogic$ PowerLeakMaxMana.2 | SubAbility$ DBStore
SVar:DBStore:DB$ StoreSVar | SVar$ PaidAmount | Type$ CountSVar | Expression$ Y | UnlessCost$ Y | UnlessPayer$ EnchantedController | UnlessSwitched$ True | SubAbility$ DBDmg
SVar:DBDmg:DB$ DealDamage | Defined$ EnchantedController | NumDmg$ 2 | SubAbility$ DBReset | StackDescription$ None
SVar:DBReset:DB$ StoreSVar | SVar$ PaidAmount | Type$ Number | Expression$ 0
SVar:Y:Count$ChosenNumber
SVar:PaidAmount:Number$0
Oracle:Enchant enchantment\nAt the beginning of the upkeep of enchanted enchantment's controller, that player may pay any amount of mana. Power Leak deals 2 damage to that player. Prevent X of that damage, where X is the amount of mana that player paid this way.
