From 6035f04140bf34203b81db107e315f43445f21c0 Mon Sep 17 00:00:00 2001 From: Alex Vasile <48962821+Alex-Vasile@users.noreply.github.com> Date: Mon, 3 Oct 2022 19:16:45 -0400 Subject: [PATCH] Disable auto-payment of mana for spells which care about mana color (#9173) --- .../src/mage/player/human/HumanPlayer.java | 30 +++++++++++++--- .../src/mage/cards/c/CankerousThirst.java | 13 +++++++ Mage.Sets/src/mage/cards/c/CauldronsGift.java | 6 ++++ .../src/mage/cards/d/DawnglowInfusion.java | 3 -- Mage.Sets/src/mage/cards/d/DryadsCaress.java | 1 - .../src/mage/cards/m/MythosOfBrokkos.java | 5 +++ .../src/mage/cards/m/MythosOfIlluna.java | 5 +++ .../src/mage/cards/m/MythosOfNethroi.java | 5 +++ .../src/mage/cards/m/MythosOfSnapdax.java | 5 +++ Mage.Sets/src/mage/cards/o/OnceAndFuture.java | 6 ++++ Mage.Sets/src/mage/cards/o/Outmuscle.java | 6 ++++ .../src/mage/cards/r/RepelIntruders.java | 1 - Mage.Sets/src/mage/cards/r/RollingSpoil.java | 1 - Mage.Sets/src/mage/cards/v/VigorMortis.java | 11 ++++-- .../main/java/mage/abilities/AbilityImpl.java | 20 ++++++++--- .../condition/CompoundCondition.java | 5 +++ .../mage/abilities/condition/Condition.java | 4 +++ .../condition/LockedInCondition.java | 5 +++ .../condition/common/AdamantCondition.java | 5 +++ .../common/ManaWasSpentCondition.java | 4 +++ .../ConditionalContinuousEffect.java | 2 +- ...ditionalInterveningIfTriggeredAbility.java | 5 +++ .../mage/abilities/effects/EffectImpl.java | 1 + .../abilities/keyword/ModularAbility.java | 5 +++ .../abilities/keyword/SunburstAbility.java | 5 +++ Mage/src/main/java/mage/cards/CardImpl.java | 35 +++++++++++++++++-- 26 files changed, 174 insertions(+), 20 deletions(-) diff --git a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java index 1cc1ee0da1..b49eef285d 100644 --- a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java @@ -465,9 +465,20 @@ public class HumanPlayer extends PlayerImpl { return true; } - if (Outcome.PutManaInPool == outcome) { - if (currentlyUnpaidMana != null - && ManaUtil.tryToAutoSelectAManaColor(choice, currentlyUnpaidMana)) { + // Try to autopay for mana + if (Outcome.PutManaInPool == outcome && currentlyUnpaidMana != null) { + // Check check if the spell being paid for cares about the color of mana being paid + // See: https://github.com/magefree/mage/issues/9070 + boolean caresAboutManaColor = false; + if (!game.getStack().isEmpty() && game.getStack().getFirst() instanceof Spell) { + Spell spellBeingCast = (Spell) game.getStack().getFirst(); + if (!spellBeingCast.isResolving() && spellBeingCast.getControllerId().equals(this.getId())) { + CardImpl card = (CardImpl) game.getCard(spellBeingCast.getSourceId()); + caresAboutManaColor = card.caresAboutManaColor(game); + } + } + + if (!caresAboutManaColor && ManaUtil.tryToAutoSelectAManaColor(choice, currentlyUnpaidMana)) { return true; } } @@ -1537,7 +1548,18 @@ public class HumanPlayer extends PlayerImpl { if (zone != null) { LinkedHashMap useableAbilities = getUseableManaAbilities(object, zone, game); if (!useableAbilities.isEmpty()) { - useableAbilities = ManaUtil.tryToAutoPay(unpaid, useableAbilities); // eliminates other abilities if one fits perfectly + // Added to ensure that mana is not being autopaid for spells that care about the color of mana being paid + // See https://github.com/magefree/mage/issues/9070 + boolean caresAboutManaColor = false; + if (abilityToCast.getAbilityType() == AbilityType.SPELL) { + CardImpl card = (CardImpl) game.getCard(abilityToCast.getSourceId()); + caresAboutManaColor = card.caresAboutManaColor(game); + } + + // Don't auto-pay if the spell cares about the color + if (!caresAboutManaColor) { + useableAbilities = ManaUtil.tryToAutoPay(unpaid, useableAbilities); // eliminates other abilities if one fits perfectly + } currentlyUnpaidMana = unpaid; activateAbility(useableAbilities, object, game); currentlyUnpaidMana = null; diff --git a/Mage.Sets/src/mage/cards/c/CankerousThirst.java b/Mage.Sets/src/mage/cards/c/CankerousThirst.java index 0bbf88c19b..803f6f9d18 100644 --- a/Mage.Sets/src/mage/cards/c/CankerousThirst.java +++ b/Mage.Sets/src/mage/cards/c/CankerousThirst.java @@ -2,6 +2,8 @@ package mage.cards.c; import java.util.UUID; import mage.abilities.Ability; +import mage.abilities.condition.CompoundCondition; +import mage.abilities.condition.Condition; import mage.abilities.condition.common.ManaWasSpentCondition; import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.OneShotEffect; @@ -50,6 +52,12 @@ public final class CankerousThirst extends CardImpl { class CankerousThirstEffect extends OneShotEffect { + // Only used for getCondition + private static final Condition condition = new CompoundCondition( + new ManaWasSpentCondition(ColoredManaSymbol.B), + new ManaWasSpentCondition(ColoredManaSymbol.G) + ); + public CankerousThirstEffect() { super(Outcome.Benefit); this.staticText = "If {B} was spent to cast this spell, you may have target creature get -3/-3 until end of turn. If {G} was spent to cast this spell, you may have target creature get +3/+3 until end of turn"; @@ -88,4 +96,9 @@ class CankerousThirstEffect extends OneShotEffect { } return false; } + + @Override + public Condition getCondition() { + return condition; + } } diff --git a/Mage.Sets/src/mage/cards/c/CauldronsGift.java b/Mage.Sets/src/mage/cards/c/CauldronsGift.java index 2e5145bc2b..4539c51228 100644 --- a/Mage.Sets/src/mage/cards/c/CauldronsGift.java +++ b/Mage.Sets/src/mage/cards/c/CauldronsGift.java @@ -1,6 +1,7 @@ package mage.cards.c; import mage.abilities.Ability; +import mage.abilities.condition.Condition; import mage.abilities.condition.common.AdamantCondition; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; @@ -88,4 +89,9 @@ class CauldronsGiftEffect extends OneShotEffect { } return true; } + + @Override + public Condition getCondition() { + return AdamantCondition.BLACK; + } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/d/DawnglowInfusion.java b/Mage.Sets/src/mage/cards/d/DawnglowInfusion.java index fc5a75c042..029e6fb807 100644 --- a/Mage.Sets/src/mage/cards/d/DawnglowInfusion.java +++ b/Mage.Sets/src/mage/cards/d/DawnglowInfusion.java @@ -22,7 +22,6 @@ public final class DawnglowInfusion extends CardImpl { public DawnglowInfusion(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{X}{G/W}"); - // You gain X life if {G} was spent to cast Dawnglow Infusion and X life if {W} was spent to cast it. DynamicValue xValue = ManacostVariableValue.REGULAR; this.getSpellAbility().addEffect(new ConditionalOneShotEffect( @@ -32,8 +31,6 @@ public final class DawnglowInfusion extends CardImpl { new GainLifeEffect(xValue), new ManaWasSpentCondition(ColoredManaSymbol.W), "and X life if {W} was spent to cast this spell")); this.getSpellAbility().addEffect(new InfoEffect("(Do both if {G}{W} was spent.)")); - - } private DawnglowInfusion(final DawnglowInfusion card) { diff --git a/Mage.Sets/src/mage/cards/d/DryadsCaress.java b/Mage.Sets/src/mage/cards/d/DryadsCaress.java index c0464eb2ad..d0bb8b4535 100644 --- a/Mage.Sets/src/mage/cards/d/DryadsCaress.java +++ b/Mage.Sets/src/mage/cards/d/DryadsCaress.java @@ -27,7 +27,6 @@ public final class DryadsCaress extends CardImpl { super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{4}{G}{G}"); // You gain 1 life for each creature on the battlefield. - this.getSpellAbility().addEffect(new GainLifeEffect(new PermanentsOnBattlefieldCount(filter))); //If {W} was spent to cast Dryad's Caress, untap all creatures you control. diff --git a/Mage.Sets/src/mage/cards/m/MythosOfBrokkos.java b/Mage.Sets/src/mage/cards/m/MythosOfBrokkos.java index 430751fadf..bf73a35ea2 100644 --- a/Mage.Sets/src/mage/cards/m/MythosOfBrokkos.java +++ b/Mage.Sets/src/mage/cards/m/MythosOfBrokkos.java @@ -88,4 +88,9 @@ class MythosOfBrokkosEffect extends OneShotEffect { Cards cards = new CardsImpl(targetCard.getTargets()); return player.moveCards(cards, Zone.HAND, source, game); } + + @Override + public Condition getCondition() { + return condition; + } } diff --git a/Mage.Sets/src/mage/cards/m/MythosOfIlluna.java b/Mage.Sets/src/mage/cards/m/MythosOfIlluna.java index c1be42fde4..0f91420dcd 100644 --- a/Mage.Sets/src/mage/cards/m/MythosOfIlluna.java +++ b/Mage.Sets/src/mage/cards/m/MythosOfIlluna.java @@ -86,6 +86,11 @@ class MythosOfIllunaEffect extends OneShotEffect { } return effect.apply(game, source); } + + @Override + public Condition getCondition() { + return condition; + } } enum MythosOfIllunaCondition implements Condition { diff --git a/Mage.Sets/src/mage/cards/m/MythosOfNethroi.java b/Mage.Sets/src/mage/cards/m/MythosOfNethroi.java index ecb84cd8ba..cb2152248c 100644 --- a/Mage.Sets/src/mage/cards/m/MythosOfNethroi.java +++ b/Mage.Sets/src/mage/cards/m/MythosOfNethroi.java @@ -68,4 +68,9 @@ class MythosOfNethroiEffect extends OneShotEffect { } return permanent.destroy(source, game, false); } + + @Override + public Condition getCondition() { + return condition; + } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/m/MythosOfSnapdax.java b/Mage.Sets/src/mage/cards/m/MythosOfSnapdax.java index faef852fea..9195528ca7 100644 --- a/Mage.Sets/src/mage/cards/m/MythosOfSnapdax.java +++ b/Mage.Sets/src/mage/cards/m/MythosOfSnapdax.java @@ -121,4 +121,9 @@ class MythosOfSnapdaxEffect extends OneShotEffect { } return true; } + + @Override + public Condition getCondition() { + return condition; + } } diff --git a/Mage.Sets/src/mage/cards/o/OnceAndFuture.java b/Mage.Sets/src/mage/cards/o/OnceAndFuture.java index 346e34f2f5..146003b013 100644 --- a/Mage.Sets/src/mage/cards/o/OnceAndFuture.java +++ b/Mage.Sets/src/mage/cards/o/OnceAndFuture.java @@ -1,6 +1,7 @@ package mage.cards.o; import mage.abilities.Ability; +import mage.abilities.condition.Condition; import mage.abilities.condition.common.AdamantCondition; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.ExileSpellEffect; @@ -96,4 +97,9 @@ class OnceAndFutureEffect extends OneShotEffect { player.putCardsOnTopOfLibrary(new CardsImpl(card2), game, source, false); return new ExileSpellEffect().apply(game, source); } + + @Override + public Condition getCondition() { + return AdamantCondition.GREEN; + } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/o/Outmuscle.java b/Mage.Sets/src/mage/cards/o/Outmuscle.java index 5702c8a189..d4724b8f1f 100644 --- a/Mage.Sets/src/mage/cards/o/Outmuscle.java +++ b/Mage.Sets/src/mage/cards/o/Outmuscle.java @@ -1,6 +1,7 @@ package mage.cards.o; import mage.abilities.Ability; +import mage.abilities.condition.Condition; import mage.abilities.condition.common.AdamantCondition; import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.OneShotEffect; @@ -85,4 +86,9 @@ class OutmuscleEffect extends OneShotEffect { game.getState().processAction(game); return creature.fight(permanent, source, game); } + + @Override + public Condition getCondition() { + return AdamantCondition.GREEN; + } } diff --git a/Mage.Sets/src/mage/cards/r/RepelIntruders.java b/Mage.Sets/src/mage/cards/r/RepelIntruders.java index a3956709f5..05a421df30 100644 --- a/Mage.Sets/src/mage/cards/r/RepelIntruders.java +++ b/Mage.Sets/src/mage/cards/r/RepelIntruders.java @@ -23,7 +23,6 @@ public final class RepelIntruders extends CardImpl { public RepelIntruders(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{W/U}"); - // Create two 1/1 white Kithkin Soldier creature tokens if {W} was spent to cast Repel Intruders. Counter up to one target creature spell if {U} was spent to cast Repel Intruders. TargetSpell target = new TargetSpell(0, 1, new FilterCreatureSpell()); target.setRequired(false); diff --git a/Mage.Sets/src/mage/cards/r/RollingSpoil.java b/Mage.Sets/src/mage/cards/r/RollingSpoil.java index 783a697907..15e322bc6b 100644 --- a/Mage.Sets/src/mage/cards/r/RollingSpoil.java +++ b/Mage.Sets/src/mage/cards/r/RollingSpoil.java @@ -22,7 +22,6 @@ public final class RollingSpoil extends CardImpl { public RollingSpoil(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{2}{G}{G}"); - // Destroy target land. this.getSpellAbility().addEffect(new DestroyTargetEffect()); this.getSpellAbility().addTarget(new TargetLandPermanent()); diff --git a/Mage.Sets/src/mage/cards/v/VigorMortis.java b/Mage.Sets/src/mage/cards/v/VigorMortis.java index 5be2dccf0c..efb3e501a0 100644 --- a/Mage.Sets/src/mage/cards/v/VigorMortis.java +++ b/Mage.Sets/src/mage/cards/v/VigorMortis.java @@ -2,6 +2,7 @@ package mage.cards.v; import java.util.UUID; import mage.abilities.Ability; +import mage.abilities.condition.Condition; import mage.abilities.condition.common.ManaWasSpentCondition; import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.common.InfoEffect; @@ -34,7 +35,6 @@ public final class VigorMortis extends CardImpl { this.getSpellAbility().addEffect(new ReturnFromGraveyardToBattlefieldTargetEffect()); this.getSpellAbility().addEffect(new InfoEffect("If {G} was spent to cast this spell, that creature enters the battlefield with an additional +1/+1 counter on it")); this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD)); - } private VigorMortis(final VigorMortis card) { @@ -49,6 +49,8 @@ public final class VigorMortis extends CardImpl { class VigorMortisReplacementEffect extends ReplacementEffectImpl { + private static final Condition condition = new ManaWasSpentCondition(ColoredManaSymbol.G); + VigorMortisReplacementEffect() { super(Duration.EndOfStep, Outcome.BoostCreature); } @@ -65,7 +67,7 @@ class VigorMortisReplacementEffect extends ReplacementEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { if (event.getTargetId().equals(getTargetPointer().getFirst(game, source))) { - return new ManaWasSpentCondition(ColoredManaSymbol.G).apply(game, source); + return condition.apply(game, source); } return false; } @@ -89,4 +91,9 @@ class VigorMortisReplacementEffect extends ReplacementEffectImpl { public VigorMortisReplacementEffect copy() { return new VigorMortisReplacementEffect(this); } + + @Override + public Condition getCondition() { + return condition; + } } diff --git a/Mage/src/main/java/mage/abilities/AbilityImpl.java b/Mage/src/main/java/mage/abilities/AbilityImpl.java index 04df2b976a..1b8ab1f5e8 100644 --- a/Mage/src/main/java/mage/abilities/AbilityImpl.java +++ b/Mage/src/main/java/mage/abilities/AbilityImpl.java @@ -2,6 +2,8 @@ package mage.abilities; import mage.MageIdentifier; import mage.MageObject; +import mage.abilities.common.EntersBattlefieldAbility; +import mage.abilities.condition.Condition; import mage.abilities.costs.*; import mage.abilities.costs.common.PayLifeCost; import mage.abilities.costs.mana.ManaCost; @@ -39,10 +41,7 @@ import mage.util.ThreadLocalStringBuilder; import mage.watchers.Watcher; import org.apache.log4j.Logger; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.UUID; +import java.util.*; /** * @author BetaSteward_at_googlemail.com @@ -1429,4 +1428,17 @@ public abstract class AbilityImpl implements Ability { this.identifier = identifier; return this; } + + /** + * Needed for disabling auto-mana payments for things like Sunburst. + * + * @return true if the ability is impacted by the color of the mana used to pay for it. + */ + public boolean caresAboutManaColor() { + return this.getEffects().stream() + .filter(Objects::nonNull) + .map(Effect::getCondition) + .filter(Objects::nonNull) + .anyMatch(Condition::caresAboutManaColor); + } } diff --git a/Mage/src/main/java/mage/abilities/condition/CompoundCondition.java b/Mage/src/main/java/mage/abilities/condition/CompoundCondition.java index 9a6e077d36..54d770e5c5 100644 --- a/Mage/src/main/java/mage/abilities/condition/CompoundCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/CompoundCondition.java @@ -38,4 +38,9 @@ public class CompoundCondition implements Condition { return text; } + @Override + public boolean caresAboutManaColor() { + return conditions.stream().anyMatch(Condition::caresAboutManaColor); + } + } diff --git a/Mage/src/main/java/mage/abilities/condition/Condition.java b/Mage/src/main/java/mage/abilities/condition/Condition.java index b5b3566e9a..b5a03c083f 100644 --- a/Mage/src/main/java/mage/abilities/condition/Condition.java +++ b/Mage/src/main/java/mage/abilities/condition/Condition.java @@ -25,4 +25,8 @@ public interface Condition extends Serializable { default String getManaText() { return "{" + this.getClass().getSimpleName() + "}"; } + + default boolean caresAboutManaColor() { + return false; + } } diff --git a/Mage/src/main/java/mage/abilities/condition/LockedInCondition.java b/Mage/src/main/java/mage/abilities/condition/LockedInCondition.java index 9517cb4ba3..8af8d3cc15 100644 --- a/Mage/src/main/java/mage/abilities/condition/LockedInCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/LockedInCondition.java @@ -42,4 +42,9 @@ public class LockedInCondition implements Condition { return condition; } + @Override + public boolean caresAboutManaColor() { + return condition.caresAboutManaColor(); + } + } diff --git a/Mage/src/main/java/mage/abilities/condition/common/AdamantCondition.java b/Mage/src/main/java/mage/abilities/condition/common/AdamantCondition.java index c7ec8b47b8..b748b50283 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/AdamantCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/AdamantCondition.java @@ -54,4 +54,9 @@ public enum AdamantCondition implements Condition { } return payment.getColor(coloredManaSymbol) > 2; } + + @Override + public boolean caresAboutManaColor() { + return true; + } } diff --git a/Mage/src/main/java/mage/abilities/condition/common/ManaWasSpentCondition.java b/Mage/src/main/java/mage/abilities/condition/common/ManaWasSpentCondition.java index c96cdf07e4..a670f9e690 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/ManaWasSpentCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/ManaWasSpentCondition.java @@ -45,4 +45,8 @@ public class ManaWasSpentCondition implements Condition { return "{" + coloredManaSymbol.toString() + "} was spent to cast it"; } + @Override + public boolean caresAboutManaColor() { + return true; + } } diff --git a/Mage/src/main/java/mage/abilities/decorator/ConditionalContinuousEffect.java b/Mage/src/main/java/mage/abilities/decorator/ConditionalContinuousEffect.java index bf6f98ae75..905e3f3c9f 100644 --- a/Mage/src/main/java/mage/abilities/decorator/ConditionalContinuousEffect.java +++ b/Mage/src/main/java/mage/abilities/decorator/ConditionalContinuousEffect.java @@ -195,6 +195,6 @@ public class ConditionalContinuousEffect extends ContinuousEffectImpl { @Override public Condition getCondition() { - return condition; + return condition == null ? baseCondition : condition; } } diff --git a/Mage/src/main/java/mage/abilities/decorator/ConditionalInterveningIfTriggeredAbility.java b/Mage/src/main/java/mage/abilities/decorator/ConditionalInterveningIfTriggeredAbility.java index 35d020e6ef..eb69a7bca3 100644 --- a/Mage/src/main/java/mage/abilities/decorator/ConditionalInterveningIfTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/decorator/ConditionalInterveningIfTriggeredAbility.java @@ -128,4 +128,9 @@ public class ConditionalInterveningIfTriggeredAbility extends TriggeredAbilityIm public int getSourceObjectZoneChangeCounter() { return ability.getSourceObjectZoneChangeCounter(); } + + @Override + public boolean caresAboutManaColor() { + return condition.caresAboutManaColor(); + } } diff --git a/Mage/src/main/java/mage/abilities/effects/EffectImpl.java b/Mage/src/main/java/mage/abilities/effects/EffectImpl.java index e27858f214..ca8fc97101 100644 --- a/Mage/src/main/java/mage/abilities/effects/EffectImpl.java +++ b/Mage/src/main/java/mage/abilities/effects/EffectImpl.java @@ -125,4 +125,5 @@ public abstract class EffectImpl implements Effect { public String getConcatPrefix() { return this.concatPrefix; } + } diff --git a/Mage/src/main/java/mage/abilities/keyword/ModularAbility.java b/Mage/src/main/java/mage/abilities/keyword/ModularAbility.java index 726f241eee..4b716fe1b9 100644 --- a/Mage/src/main/java/mage/abilities/keyword/ModularAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/ModularAbility.java @@ -100,6 +100,11 @@ public class ModularAbility extends DiesSourceTriggeredAbility { } return sb.toString(); } + + @Override + public boolean caresAboutManaColor() { + return sunburst; + } } class ModularStaticAbility extends StaticAbility { diff --git a/Mage/src/main/java/mage/abilities/keyword/SunburstAbility.java b/Mage/src/main/java/mage/abilities/keyword/SunburstAbility.java index 58726302db..9398296f57 100644 --- a/Mage/src/main/java/mage/abilities/keyword/SunburstAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/SunburstAbility.java @@ -46,6 +46,11 @@ public class SunburstAbility extends EntersBattlefieldAbility { return isCreature ? ruleCreature : ruleNonCreature; } + @Override + public boolean caresAboutManaColor() { + return true; + } + } class SunburstEffect extends OneShotEffect { diff --git a/Mage/src/main/java/mage/cards/CardImpl.java b/Mage/src/main/java/mage/cards/CardImpl.java index eda028ffc5..4757dcc29a 100644 --- a/Mage/src/main/java/mage/cards/CardImpl.java +++ b/Mage/src/main/java/mage/cards/CardImpl.java @@ -6,8 +6,7 @@ import mage.Mana; import mage.abilities.*; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.common.continuous.HasSubtypesSourceEffect; -import mage.abilities.keyword.ChangelingAbility; -import mage.abilities.keyword.FlashbackAbility; +import mage.abilities.keyword.*; import mage.abilities.mana.ActivatedManaAbilityImpl; import mage.cards.repository.PluginClassloaderRegistery; import mage.constants.*; @@ -30,7 +29,6 @@ import org.apache.log4j.Logger; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.*; -import mage.abilities.keyword.ReconfigureAbility; public abstract class CardImpl extends MageObjectImpl implements Card { @@ -902,4 +900,35 @@ public abstract class CardImpl extends MageObjectImpl implements Card { return subType.getSubTypeSet() == SubTypeSet.CreatureType && this.getAbilities().containsClass(ChangelingAbility.class); } + + /** + * This is used for disabling auto-payments for any any cards which care about the color + * of the mana used to cast it beyond color requirements. E.g. Sunburst, Adamant, Flamespout. + *

+ * This is not about which colors are in the mana costs. + *

+ * E.g. "Pentad Prism" {2} will return true since it has Sunburst, but "Abbey Griffin" {3}{W} will + * return false since the mana spent on the generic cost has no impact on the card. + * + * @return Whether the given spell cares about the mana color used to pay for it. + */ + public boolean caresAboutManaColor(Game game) { + // SunburstAbility + if (abilities.containsClass(SunburstAbility.class)) { + return true; + } + + // Look at each individual ability + // ConditionalInterveningIfTriggeredAbility (e.g. Ogre Savant) + // Spellability with ManaWasSpentCondition (e.g. Firespout) + // Modular (only Arcbound Wanderer) + for (Ability ability : getAbilities(game)) { + if (((AbilityImpl) ability).caresAboutManaColor()) { + return true; + } + } + + // Only way to get here is if none of the effects on the card care about mana color. + return false; + } }