diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java index 05414e0dcfa..29fcfe0873f 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java @@ -1354,7 +1354,10 @@ public class ComputerUtilMana { manaToAdd = 1; } - String xColor = sa.getParamOrDefault("XColor", "1"); + String xColor = sa.getXColor(); + if (xColor == null) { + xColor = "1"; + } if (card.hasKeyword("Spend only colored mana on X. No more than one mana of each color may be spent this way.")) { xColor = "WUBRGX"; } diff --git a/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java b/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java index 72a10b7f736..eabc0ce7fca 100644 --- a/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/DamageDealAi.java @@ -23,6 +23,7 @@ import forge.ai.ComputerUtilMana; import forge.ai.PlayerControllerAi; import forge.ai.SpecialCardAi; import forge.ai.SpellAbilityAi; +import forge.card.MagicColor; import forge.card.mana.ManaCost; import forge.game.Game; import forge.game.GameEntity; @@ -1011,7 +1012,7 @@ public class DamageDealAi extends DamageAiBase { Player opponent = ai.getWeakestOpponent(); // TODO: somehow account for the possible cost reduction? - int dmg = ComputerUtilMana.determineLeftoverMana(sa, ai, saTgt.getParam("XColor"), false); + int dmg = ComputerUtilMana.determineLeftoverMana(sa, ai, MagicColor.toShortString(saTgt.getParam("XColor")), false); while (!ComputerUtilMana.canPayManaCost(sa, ai, dmg, false) && dmg > 0) { // TODO: ideally should never get here, currently put here as a precaution for complex mana base cases where the miscalculation might occur. Will remove later if it proves to never trigger. diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbility.java b/forge-game/src/main/java/forge/game/spellability/SpellAbility.java index a7b9356d611..10332f5429f 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbility.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbility.java @@ -28,6 +28,7 @@ import com.google.common.collect.*; import forge.GameCommand; import forge.card.CardStateName; import forge.card.ColorSet; +import forge.card.MagicColor; import forge.card.mana.ManaCost; import forge.game.CardTraitBase; import forge.game.ForgeScript; @@ -2417,6 +2418,23 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit xManaCostPaid = n; } + public String getXColor() { + if (!hasParam("XColor")) { + return null; + } + + StringBuilder sb = new StringBuilder(); + String parts[] = getParam("XColor").split(","); + for (String col : parts) { + // color word used + if (col.length() > 2) { + col = MagicColor.toShortString(col); + } + sb.append(col); + } + return sb.toString(); + } + public boolean canCastTiming(Player activator) { return canCastTiming(getHostCard(), activator); } diff --git a/forge-gui/res/cardsfolder/a/atalya_samite_master.txt b/forge-gui/res/cardsfolder/a/atalya_samite_master.txt index fcf2351abc8..8fd6e287531 100644 --- a/forge-gui/res/cardsfolder/a/atalya_samite_master.txt +++ b/forge-gui/res/cardsfolder/a/atalya_samite_master.txt @@ -2,7 +2,7 @@ Name:Atalya, Samite Master ManaCost:3 W W Types:Legendary Creature Human Cleric PT:2/3 -A:AB$ Charm | Cost$ X T | XColor$ W | Choices$ PreventDamage,GainLife | CharmNum$ 1 +A:AB$ Charm | Cost$ X T | XColor$ White | Choices$ PreventDamage,GainLife | CharmNum$ 1 SVar:PreventDamage:DB$ PreventDamage | ValidTgts$ Creature | TgtPrompt$ Select target creature | Amount$ X | SpellDescription$ Prevent the next X damage that would be dealt to target creature this turn. SVar:GainLife:DB$ GainLife | LifeAmount$ X | Defined$ You | SpellDescription$ You gain X life. SVar:X:Count$xPaid diff --git a/forge-gui/res/cardsfolder/c/consume_spirit.txt b/forge-gui/res/cardsfolder/c/consume_spirit.txt index 5bae59327a1..9091beba75b 100644 --- a/forge-gui/res/cardsfolder/c/consume_spirit.txt +++ b/forge-gui/res/cardsfolder/c/consume_spirit.txt @@ -1,7 +1,7 @@ Name:Consume Spirit ManaCost:X 1 B Types:Sorcery -A:SP$ DealDamage | Cost$ X 1 B | XColor$ B | ValidTgts$ Creature,Player,Planeswalker | TgtPrompt$ Select any target | NumDmg$ X | SubAbility$ DBGainLife | SpellDescription$ Spend only black mana on X. Consume Spirit deals X damage to any target and you gain X life. +A:SP$ DealDamage | Cost$ X 1 B | XColor$ Black | ValidTgts$ Creature,Player,Planeswalker | TgtPrompt$ Select any target | NumDmg$ X | SubAbility$ DBGainLife | SpellDescription$ Spend only black mana on X. Consume Spirit deals X damage to any target and you gain X life. SVar:DBGainLife:DB$ GainLife | Defined$ You | LifeAmount$ X SVar:X:Count$xPaid Oracle:Spend only black mana on X.\nConsume Spirit deals X damage to any target and you gain X life. diff --git a/forge-gui/res/cardsfolder/c/crimson_hellkite.txt b/forge-gui/res/cardsfolder/c/crimson_hellkite.txt index 33237e11b7e..45a62dfb859 100644 --- a/forge-gui/res/cardsfolder/c/crimson_hellkite.txt +++ b/forge-gui/res/cardsfolder/c/crimson_hellkite.txt @@ -2,7 +2,7 @@ Name:Crimson Hellkite ManaCost:6 R R R Types:Creature Dragon PT:6/6 -A:AB$ DealDamage | Cost$ T X | XColor$ R | ValidTgts$ Creature | TgtPrompt$ Select target creature | NumDmg$ X | SpellDescription$ Crimson Hellkite deals X damage to target creature. Spend only red mana on X. +A:AB$ DealDamage | Cost$ T X | XColor$ Red | ValidTgts$ Creature | TgtPrompt$ Select target creature | NumDmg$ X | SpellDescription$ Crimson Hellkite deals X damage to target creature. Spend only red mana on X. K:Flying SVar:X:Count$xPaid Oracle:Flying\n{X}, {T}: Crimson Hellkite deals X damage to target creature. Spend only red mana on X. diff --git a/forge-gui/res/cardsfolder/c/crypt_rats.txt b/forge-gui/res/cardsfolder/c/crypt_rats.txt index 99e37ae47a8..2e58d738eaa 100644 --- a/forge-gui/res/cardsfolder/c/crypt_rats.txt +++ b/forge-gui/res/cardsfolder/c/crypt_rats.txt @@ -2,6 +2,6 @@ Name:Crypt Rats ManaCost:2 B Types:Creature Rat PT:1/1 -A:AB$ DamageAll | Cost$ X | XColor$ B | NumDmg$ X | ValidCards$ Creature | ValidPlayers$ Player | ValidDescription$ each creature and each player. | SpellDescription$ Crypt Rats deals X damage to each creature and each player. Spend only black mana on X. +A:AB$ DamageAll | Cost$ X | XColor$ Black | NumDmg$ X | ValidCards$ Creature | ValidPlayers$ Player | ValidDescription$ each creature and each player. | SpellDescription$ Crypt Rats deals X damage to each creature and each player. Spend only black mana on X. SVar:X:Count$xPaid Oracle:{X}: Crypt Rats deals X damage to each creature and each player. Spend only black mana on X. diff --git a/forge-gui/res/cardsfolder/d/drain_life.txt b/forge-gui/res/cardsfolder/d/drain_life.txt index d1a46e4affa..90d62e26553 100644 --- a/forge-gui/res/cardsfolder/d/drain_life.txt +++ b/forge-gui/res/cardsfolder/d/drain_life.txt @@ -1,7 +1,7 @@ Name:Drain Life ManaCost:X 1 B Types:Sorcery -A:SP$ StoreSVar | Cost$ X 1 B | XColor$ B | ValidTgts$ Creature,Player,Planeswalker | TgtPrompt$ Select any target | SVar$ Limit | Type$ Targeted | Expression$ CardToughness | SubAbility$ StoreTgtPW | ConditionDefined$ Targeted | ConditionPresent$ Card.Creature | ConditionCompare$ GE1 | SpellDescription$ Spend only black mana on X. CARDNAME deals X damage to any target. You gain life equal to the damage dealt, but not more life than the player's life total before the damage was dealt, the planeswalker's loyalty before the damage was dealt, or the creature's toughness. +A:SP$ StoreSVar | Cost$ X 1 B | XColor$ Black | ValidTgts$ Creature,Player,Planeswalker | TgtPrompt$ Select any target | SVar$ Limit | Type$ Targeted | Expression$ CardToughness | SubAbility$ StoreTgtPW | ConditionDefined$ Targeted | ConditionPresent$ Card.Creature | ConditionCompare$ GE1 | SpellDescription$ Spend only black mana on X. CARDNAME deals X damage to any target. You gain life equal to the damage dealt, but not more life than the player's life total before the damage was dealt, the planeswalker's loyalty before the damage was dealt, or the creature's toughness. SVar:StoreTgtPW:DB$ StoreSVar | SVar$ Limit | Type$ Targeted | Expression$ CardCounters.LOYALTY | SubAbility$ StoreTgtP | ConditionDefined$ Targeted | ConditionPresent$ Card.Planeswalker | ConditionCheckSVar$ Loyalty | ConditionSVarCompare$ LTLimit SVar:StoreTgtP:DB$ StoreSVar | SVar$ Limit | Type$ Count | Expression$ TargetedLifeTotal | SubAbility$ DBDamage | ConditionDefined$ Targeted | ConditionPresent$ Card.Creature,Card.Planeswalker | ConditionCompare$ EQ0 SVar:DBDamage:DB$ DealDamage | Defined$ Targeted | NumDmg$ X | SubAbility$ DBGainLife | AILogic$ XLifeDrain diff --git a/forge-gui/res/cardsfolder/p/primitive_justice.txt b/forge-gui/res/cardsfolder/p/primitive_justice.txt index c5090d6c04c..d1177288c82 100644 --- a/forge-gui/res/cardsfolder/p/primitive_justice.txt +++ b/forge-gui/res/cardsfolder/p/primitive_justice.txt @@ -3,10 +3,10 @@ ManaCost:1 R Types:Sorcery A:SP$ Destroy | Cost$ X 1 R | XColor$ RG | AnnounceTitle$ how many times to pay the additional cost | Announce$ AdditionalCostPayTimes | ValidTgts$ Artifact | TgtPrompt$ Select target artifact | TargetMin$ TargetNum | TargetMax$ TargetNum | SubAbility$ DBGainLife | SpellDescription$ Destroy target artifact. For each additional {1}{R} you paid, destroy another target artifact. For each additional {1}{G} you paid, destroy another target artifact, and you gain 1 life. S:Mode$ RaiseCost | ValidCard$ Card.Self | Type$ Spell | Amount$ IncreaseCost | EffectZone$ All | Description$ As an additional cost to cast this spell, you may pay {1}{R} and/or {1}{G} any number of times. -SVar:DBGainLife:DB$ GainLife | Defined$ You | LifeAmount$ GreenManaPaid +SVar:DBGainLife:DB$ GainLife | Defined$ You | LifeAmount$ GManaPaid SVar:AdditionalCostPayTimes:Number$0 SVar:TargetNum:SVar$AdditionalCostPayTimes/Plus.1 SVar:IncreaseCost:SVar$AdditionalCostPayTimes SVar:X:SVar$AdditionalCostPayTimes -SVar:GreenManaPaid:Count$xColorPaid G +SVar:GManaPaid:Count$xColorPaid G Oracle:As an additional cost to cast this spell, you may pay {1}{R} and/or {1}{G} any number of times.\nDestroy target artifact. For each additional {1}{R} you paid, destroy another target artifact. For each additional {1}{G} you paid, destroy another target artifact, and you gain 1 life. diff --git a/forge-gui/res/cardsfolder/s/soul_burn.txt b/forge-gui/res/cardsfolder/s/soul_burn.txt index e8ed5834ce2..ee544149bfa 100644 --- a/forge-gui/res/cardsfolder/s/soul_burn.txt +++ b/forge-gui/res/cardsfolder/s/soul_burn.txt @@ -1,15 +1,15 @@ Name:Soul Burn ManaCost:X 2 B Types:Sorcery -A:SP$ StoreSVar | Cost$ X 2 B | XColor$ BR | ValidTgts$ Creature,Player,Planeswalker | TgtPrompt$ Select any target | SVar$ Limit | Type$ Targeted | Expression$ CardToughness | SubAbility$ StoreTgtPW | ConditionDefined$ Targeted | ConditionPresent$ Card.Creature | ConditionCompare$ GE1 | SpellDescription$ Spend only black and/or red mana on X. CARDNAME deals X damage to target creature or player. You gain life equal to the damage dealt, but not more than the amount of {B} spent on X, the player's life total before the damage was dealt, the planeswalker's loyalty before the damage was dealt, or the creature's toughness. +A:SP$ StoreSVar | Cost$ X 2 B | XColor$ Black,Red | ValidTgts$ Creature,Player,Planeswalker | TgtPrompt$ Select any target | SVar$ Limit | Type$ Targeted | Expression$ CardToughness | SubAbility$ StoreTgtPW | ConditionDefined$ Targeted | ConditionPresent$ Card.Creature | ConditionCompare$ GE1 | SpellDescription$ Spend only black and/or red mana on X. CARDNAME deals X damage to target creature or player. You gain life equal to the damage dealt, but not more than the amount of {B} spent on X, the player's life total before the damage was dealt, the planeswalker's loyalty before the damage was dealt, or the creature's toughness. SVar:StoreTgtPW:DB$ StoreSVar | SVar$ Limit | Type$ Targeted | Expression$ CardCounters.LOYALTY | SubAbility$ StoreTgtP | ConditionDefined$ Targeted | ConditionPresent$ Card.Planeswalker | ConditionCheckSVar$ Loyalty | ConditionSVarCompare$ LTLimit SVar:StoreTgtP:DB$ StoreSVar | SVar$ Limit | Type$ Count | Expression$ TargetedLifeTotal | SubAbility$ DBDamage | ConditionDefined$ Targeted | ConditionPresent$ Card.Creature,Card.Planeswalker | ConditionCompare$ EQ0 SVar:DBDamage:DB$ DealDamage | Defined$ Targeted | NumDmg$ X | SubAbility$ DBGainLife | AILogic$ XLifeDrain SVar:DBGainLife:DB$ GainLife | Defined$ You | LifeAmount$ DrainedLifeCard SVar:X:Count$xPaid -SVar:DrainedLifeCard:SVar$BlackManaPaid/LimitMax.Limit +SVar:DrainedLifeCard:SVar$BManaPaid/LimitMax.Limit SVar:Limit:Count$xPaid SVar:Loyalty:Targeted$CardCounters.LOYALTY -SVar:BlackManaPaid:Count$xColorPaid B +SVar:BManaPaid:Count$xColorPaid B DeckHints:Color$Red Oracle:Spend only black and/or red mana on X.\nSoul Burn deals X damage to any target. You gain life equal to the damage dealt, but not more than the amount of {B} spent on X, the player's life total before the damage was dealt, the planeswalker's loyalty before the damage was dealt, or the creature's toughness. diff --git a/forge-gui/src/main/java/forge/player/HumanPlay.java b/forge-gui/src/main/java/forge/player/HumanPlay.java index f92473ef39d..bf7fc5da0e7 100644 --- a/forge-gui/src/main/java/forge/player/HumanPlay.java +++ b/forge-gui/src/main/java/forge/player/HumanPlay.java @@ -634,7 +634,7 @@ public class HumanPlay { ManaCostBeingPaid toPay = new ManaCostBeingPaid(realCost, mc.getRestriction()); String xInCard = source.getSVar("X"); - String xColor = ability.getParam("XColor"); + String xColor = ability.getXColor(); if (source.hasKeyword("Spend only colored mana on X. No more than one mana of each color may be spent this way.")) { xColor = "WUBRGX"; }