diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java index fef8fd99075..24abb2866b3 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java @@ -513,6 +513,21 @@ public class ComputerUtilMana { // extraMana, sa.getHostCard(), sa.toUnsuppressedString(), StringUtils.join(paymentPlan, "\n\t")); // } + // See if it's possible to pay with something that was left in the mana pool in corner cases, + // e.g. Gemstone Caverns with a Luck counter on it generating colored mana (which fails to be + // processed correctly on a per-ability basis, leaving floating mana in the pool) + if (!cost.isPaid() && !manapool.isEmpty()) { + for (ManaCostShard shard : cost.getDistinctShards()) { + for (byte color : MagicColor.WUBRGC) { + manapool.tryPayCostWithColor(color, sa, cost); + } + if (cost.isPaid()) { + break; + } + } + } + + // The cost is still unpaid, so refund the mana and report if (!cost.isPaid()) { refundMana(manaSpentToPay, ai, sa); if (test) { diff --git a/forge-gui/res/cardsfolder/g/gamble.txt b/forge-gui/res/cardsfolder/g/gamble.txt index 5f2b1808fbc..83a1d72dbde 100644 --- a/forge-gui/res/cardsfolder/g/gamble.txt +++ b/forge-gui/res/cardsfolder/g/gamble.txt @@ -3,6 +3,8 @@ ManaCost:R Types:Sorcery A:SP$ ChangeZone | Cost$ R | Origin$ Library | Destination$ Hand | ChangeType$ Card | ChangeNum$ 1 | SubAbility$ DBDiscard | Mandatory$ True | SpellDescription$ Search your library for a card, put that card into your hand, discard a card at random, then shuffle your library. SVar:DBDiscard:DB$Discard | Defined$ You | NumCards$ 1 | Mode$ Random -SVar:RemAIDeck:True +SVar:NeedsToPlayVar:Z GE2 +SVar:Z:Count$InYourHand +SVar:RemRandomDeck:True SVar:Picture:http://www.wizards.com/global/images/magic/general/gamble.jpg Oracle:Search your library for a card, put that card into your hand, discard a card at random, then shuffle your library. diff --git a/forge-gui/res/cardsfolder/g/gangrenous_goliath.txt b/forge-gui/res/cardsfolder/g/gangrenous_goliath.txt index d98ddfcd63b..8137c207ce1 100644 --- a/forge-gui/res/cardsfolder/g/gangrenous_goliath.txt +++ b/forge-gui/res/cardsfolder/g/gangrenous_goliath.txt @@ -3,6 +3,6 @@ ManaCost:3 B B Types:Creature Zombie Giant PT:4/4 A:AB$ ChangeZone | Cost$tapXType<3/Cleric> | Origin$ Graveyard | Destination$ Hand | ActivationZone$ Graveyard | SpellDescription$ Return CARDNAME from your graveyard to your hand. -Var:RemAIDeck:True +SVar:RemRandomDeck:True SVar:Picture:http://www.wizards.com/global/images/magic/general/gangrenous_goliath.jpg Oracle:Tap three untapped Clerics you control: Return Gangrenous Goliath from your graveyard to your hand. diff --git a/forge-gui/res/cardsfolder/g/gate_smasher.txt b/forge-gui/res/cardsfolder/g/gate_smasher.txt index 3050cc5d0ee..e3d0cfe7f1a 100644 --- a/forge-gui/res/cardsfolder/g/gate_smasher.txt +++ b/forge-gui/res/cardsfolder/g/gate_smasher.txt @@ -5,7 +5,6 @@ Text:CARDNAME can be attached only to a creature with toughness 4 or greater. K:Equip 3 K:CantEquip Creature.toughnessLT4 S:Mode$ Continuous | Affected$ Creature.EquippedBy | AddPower$ 3 | AddKeyword$ Trample | Description$ Equipped creature gets +3/+0 and has trample. -SVar:RemAIDeck:True SVar:RemRandomDeck:True SVar:Picture:http://www.wizards.com/global/images/magic/general/gate_smasher.jpg Oracle:Gate Smasher can be attached only to a creature with toughness 4 or greater.\nEquipped creature gets +3/+0 and has trample.\nEquip {3} diff --git a/forge-gui/res/cardsfolder/g/gemstone_caverns.txt b/forge-gui/res/cardsfolder/g/gemstone_caverns.txt index 0413f430f5a..adae0dd08b5 100644 --- a/forge-gui/res/cardsfolder/g/gemstone_caverns.txt +++ b/forge-gui/res/cardsfolder/g/gemstone_caverns.txt @@ -2,12 +2,13 @@ Name:Gemstone Caverns ManaCost:no cost Types:Legendary Land K:MayEffectFromOpeningHand:FromOpeningHand:!PlayFirst -SVar:FromOpeningHand:AB$ ChangeZone | Cost$ 0 | Defined$ Self | Origin$ Hand | Destination$ Battlefield | SubAbility$ LuckCounter | SpellDescription$ If CARDNAME is in your opening hand and you're not playing first, you may begin the game with CARDNAME on the battlefield with a luck counter on it. +SVar:FromOpeningHand:DB$ ChangeZone | Defined$ Self | Origin$ Hand | Destination$ Battlefield | SubAbility$ LuckCounter | SpellDescription$ If CARDNAME is in your opening hand and you're not playing first, you may begin the game with CARDNAME on the battlefield with a luck counter on it. SVar:LuckCounter:DB$ PutCounter | CounterType$ LUCK | CounterNum$ 1 | Defined$ Self | SubAbility$ ExileFromHand SVar:ExileFromHand:DB$ ChangeZone | Origin$ Hand | Destination$ Exile | ChangeType$ Card | ChangeNum$ 1 | Mandatory$ True | SpellDescription$ If you do, exile a card from your hand. -A:AB$ Mana | Cost$ T | Produced$ C | ConditionCheckSVar$ CheckCounter | ConditionSVarCompare$ EQ0 | SubAbility$ DBMana | SpellDescription$ Add {C} to your mana pool. If CARDNAME has a luck counter on it, instead add one mana of any color to your mana pool. -SVar:DBMana:DB$ Mana | Produced$ Any | ConditionCheckSVar$ CheckCounter | ConditionSVarCompare$ GE1 +A:AB$ Mana | Cost$ T | Produced$ C | ConditionCheckSVar$ CheckCounter | ConditionSVarCompare$ EQ0 | SubAbility$ DBMana | References$ CheckCounter | SpellDescription$ Add {C} to your mana pool. If CARDNAME has a luck counter on it, instead add one mana of any color to your mana pool. +SVar:DBMana:DB$ Mana | Produced$ Any | ConditionCheckSVar$ CheckCounter | ConditionSVarCompare$ GE1 | References$ CheckCounter SVar:CheckCounter:Count$CardCounters.LUCK +#TODO: The AI is not yet fully aware that this card can generate any color of mana at any time if it has a luck counter on it. SVar:RemAIDeck:True SVar:Picture:http://www.wizards.com/global/images/magic/general/gemstone_caverns.jpg Oracle:If Gemstone Caverns is in your opening hand and you're not playing first, you may begin the game with Gemstone Caverns on the battlefield with a luck counter on it. If you do, exile a card from your hand.\n{T}: Add {C} to your mana pool. If Gemstone Caverns has a luck counter on it, instead add one mana of any color to your mana pool. diff --git a/forge-gui/res/cardsfolder/g/genesis_wave.txt b/forge-gui/res/cardsfolder/g/genesis_wave.txt index e362722ffd6..f70ec178f5e 100644 --- a/forge-gui/res/cardsfolder/g/genesis_wave.txt +++ b/forge-gui/res/cardsfolder/g/genesis_wave.txt @@ -3,6 +3,7 @@ ManaCost:X G G G Types:Sorcery A:SP$ Dig | Cost$ X G G G | DigNum$ X | Reveal$ True | AnyNumber$ True | ChangeValid$ Permanent.cmcLEX | DestinationZone$ Battlefield | DestinationZone2$ Graveyard | References$ X | SpellDescription$ Reveal the top X cards of your library. You may put any number of permanent cards with converted mana cost X or less from among them onto the battlefield. Then put all cards revealed this way that weren't put onto the battlefield into your graveyard. SVar:X:Count$xPaid -SVar:RemAIDeck:True +SVar:NeedsToPlayVar:Z GE6 +SVar:Z:Count$Valid Land.YouCtrl+untapped SVar:Picture:http://www.wizards.com/global/images/magic/general/genesis_wave.jpg Oracle:Reveal the top X cards of your library. You may put any number of permanent cards with converted mana cost X or less from among them onto the battlefield. Then put all cards revealed this way that weren't put onto the battlefield into your graveyard. diff --git a/forge-gui/res/cardsfolder/g/ghosts_of_the_innocent.txt b/forge-gui/res/cardsfolder/g/ghosts_of_the_innocent.txt index 42240d341f7..95c7e2de59e 100644 --- a/forge-gui/res/cardsfolder/g/ghosts_of_the_innocent.txt +++ b/forge-gui/res/cardsfolder/g/ghosts_of_the_innocent.txt @@ -6,5 +6,5 @@ R:Event$ DamageDone | ActiveZones$ Battlefield | ValidTarget$ Player,Creature | SVar:DmgHalfDown:DB$ ReplaceEffect | VarName$ DamageAmount | VarValue$ X | References$ X SVar:X:ReplaceCount$DamageAmount/HalfDown SVar:Picture:http://www.wizards.com/global/images/magic/general/ghosts_of_the_innocent.jpg -SVar:RemAIDeck:True +SVar:RemRandomDeck:True Oracle:If a source would deal damage to a creature or player, it deals half that damage, rounded down, to that creature or player instead. diff --git a/forge-gui/res/cardsfolder/g/gilded_lotus.txt b/forge-gui/res/cardsfolder/g/gilded_lotus.txt index 0fc5646bbc9..55873dd3372 100644 --- a/forge-gui/res/cardsfolder/g/gilded_lotus.txt +++ b/forge-gui/res/cardsfolder/g/gilded_lotus.txt @@ -2,6 +2,5 @@ Name:Gilded Lotus ManaCost:5 Types:Artifact A:AB$ Mana | Cost$ T | Produced$ Any | Amount$ 3 | SpellDescription$ Add three mana of any one color to your mana pool. -SVar:RemAIDeck:True SVar:Picture:http://www.wizards.com/global/images/magic/general/gilded_lotus.jpg Oracle:{T}: Add three mana of any one color to your mana pool. diff --git a/forge-gui/res/cardsfolder/g/glimmerpoint_stag.txt b/forge-gui/res/cardsfolder/g/glimmerpoint_stag.txt index 2e1b437297c..11d39dc6af4 100644 --- a/forge-gui/res/cardsfolder/g/glimmerpoint_stag.txt +++ b/forge-gui/res/cardsfolder/g/glimmerpoint_stag.txt @@ -8,6 +8,5 @@ SVar:TrigExile:DB$ ChangeZone | ValidTgts$ Permanent.Other | Mandatory$ True | T SVar:DelTrig:DB$ DelayedTrigger | Mode$ Phase | Phase$ End of Turn | Execute$ TrigBounce | TriggerDescription$ Return exiled permanent to the battlefield. | RememberObjects$ Remembered | SubAbility$ DBCleanup SVar:TrigBounce:DB$ ChangeZone | Origin$ Exile | Destination$ Battlefield | Defined$ DelayTriggerRemembered SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True -SVar:RemAIDeck:True SVar:Picture:http://www.wizards.com/global/images/magic/general/glimmerpoint_stag.jpg Oracle:Vigilance\nWhen Glimmerpoint Stag enters the battlefield, exile another target permanent. Return that card to the battlefield under its owner's control at the beginning of the next end step. diff --git a/forge-gui/res/cardsfolder/g/goblin_lyre.txt b/forge-gui/res/cardsfolder/g/goblin_lyre.txt index a993b8198e1..5958fc60d56 100644 --- a/forge-gui/res/cardsfolder/g/goblin_lyre.txt +++ b/forge-gui/res/cardsfolder/g/goblin_lyre.txt @@ -2,8 +2,8 @@ Name:Goblin Lyre ManaCost:3 Types:Artifact A:AB$ FlipACoin | Cost$ Sac<1/CARDNAME> | WinSubAbility$ DBDamageOpp | LoseSubAbility$ DBDamageYou | ValidTgts$ Opponent | TgtPrompt$ Choose target opponent | SpellDescription$ Flip a coin. If you win the flip, Goblin Lyre deals damage to target opponent equal to the number of creatures you control. If you lose the flip, Goblin Lyre deals damage to you equal to the number of creatures that opponent controls. -SVar:DBDamageOpp:DB$ DealDamage | Cost$ 0 | Defined$ Targeted | NumDmg$ X | References$ X -SVar:DBDamageYou:DB$ DealDamage | Cost$ 0 | Defined$ You | NumDmg$ Y | References$ Y +SVar:DBDamageOpp:DB$ DealDamage | Defined$ Targeted | NumDmg$ X | References$ X +SVar:DBDamageYou:DB$ DealDamage | Defined$ You | NumDmg$ Y | References$ Y SVar:X:Count$Valid Creature.YouCtrl SVar:Y:Count$Valid Creature.OppCtrl SVar:RemAIDeck:True diff --git a/forge-gui/res/cardsfolder/g/goblin_psychopath.txt b/forge-gui/res/cardsfolder/g/goblin_psychopath.txt index f95b5e21d5d..d0aedb5ccaa 100644 --- a/forge-gui/res/cardsfolder/g/goblin_psychopath.txt +++ b/forge-gui/res/cardsfolder/g/goblin_psychopath.txt @@ -10,6 +10,6 @@ SVar:EventDamageDone:Event$ DamageDone | ValidSource$ Card.EffectSource | Replac SVar:DamageYou:DB$ ReplaceEffect | VarName$ Affected | VarValue$ You | VarType$ Player | SubAbility$ ExileEffect SVar:ExileEffect:DB$ ChangeZone | Defined$ Self | Origin$ Command | Destination$ Exile SVar:PsychoX:ReplaceCount$DamageAmount -SVar:RemAIDeck:True +SVar:RemRandomDeck:True SVar:Picture:http://www.wizards.com/global/images/magic/general/goblin_psychopath.jpg Oracle:Whenever Goblin Psychopath attacks or blocks, flip a coin. If you lose the flip, the next time it would deal combat damage this turn, it deals that damage to you instead. diff --git a/forge-gui/res/cardsfolder/g/grave_peril.txt b/forge-gui/res/cardsfolder/g/grave_peril.txt index 8e240af000e..cf5d691b858 100644 --- a/forge-gui/res/cardsfolder/g/grave_peril.txt +++ b/forge-gui/res/cardsfolder/g/grave_peril.txt @@ -2,9 +2,9 @@ Name:Grave Peril ManaCost:1 B Types:Enchantment T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Creature.nonBlack |TriggerZones$ Battlefield | Execute$ TrigSac | TriggerDescription$ When a nonblack creature enters the battlefield, sacrifice Grave Peril. If you do, destroy that creature. -SVar:TrigSac:AB$SacrificeAll | Cost$ 0 | ValidCards$ Card.Self | SubAbility$ DBDestroy | RememberSacrificed$ True -SVar:DBDestroy:DB$Destroy | Cost$ 0 | Defined$ TriggeredCard | ConditionDefined$ Remembered | ConditionPresent$ Card +SVar:TrigSac:DB$ SacrificeAll | ValidCards$ Card.Self | SubAbility$ DBDestroy | RememberSacrificed$ True +SVar:DBDestroy:DB$ Destroy | Defined$ TriggeredCard | ConditionDefined$ Remembered | ConditionPresent$ Card SVar:NonStackingEffect:True -SVar:RemAIDeck:True +SVar:RemRandomDeck:True SVar:Picture:http://www.wizards.com/global/images/magic/general/grave_peril.jpg Oracle:When a nonblack creature enters the battlefield, sacrifice Grave Peril. If you do, destroy that creature. diff --git a/forge-gui/res/cardsfolder/g/grollub.txt b/forge-gui/res/cardsfolder/g/grollub.txt index 8ed7829f742..33f8e7bd252 100644 --- a/forge-gui/res/cardsfolder/g/grollub.txt +++ b/forge-gui/res/cardsfolder/g/grollub.txt @@ -3,8 +3,8 @@ ManaCost:2 B Types:Creature Beast PT:3/3 T:Mode$ DamageDoneOnce | ValidTarget$ Card.Self | Execute$ TrigGain | TriggerZones$ Battlefield | TriggerDescription$ Whenever CARDNAME is dealt damage, each opponent gains that much life. -SVar:TrigGain:AB$ GainLife | Cost$ 0 | Defined$ Player.Opponent | LifeAmount$ X | References$ X +SVar:TrigGain:DB$ GainLife | Defined$ Player.Opponent | LifeAmount$ X | References$ X SVar:X:TriggerCount$DamageAmount -SVar:RemAIDeck:True +SVar:RemRandomDeck:True SVar:Picture:http://www.wizards.com/global/images/magic/general/grollub.jpg Oracle:Whenever Grollub is dealt damage, each opponent gains that much life.