From 9170df13449223da5bf89e1bb79e216989863b4e Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 25 Sep 2019 17:32:49 -0400 Subject: [PATCH] fixed cost modifying effects requiring snow mana unnecessarily (fixes #6000) --- Mage/src/main/java/mage/util/CardUtil.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Mage/src/main/java/mage/util/CardUtil.java b/Mage/src/main/java/mage/util/CardUtil.java index 851d83c8de..85770a50a3 100644 --- a/Mage/src/main/java/mage/util/CardUtil.java +++ b/Mage/src/main/java/mage/util/CardUtil.java @@ -9,12 +9,14 @@ import mage.abilities.costs.VariableCost; import mage.abilities.costs.mana.*; import mage.cards.Card; import mage.constants.EmptyNames; +import mage.filter.Filter; import mage.game.Game; import mage.game.permanent.Permanent; import mage.game.permanent.token.Token; import mage.util.functions.CopyTokenFunction; import java.text.SimpleDateFormat; +import java.util.Objects; import java.util.UUID; /** @@ -87,6 +89,10 @@ public final class CardUtil { ManaCosts adjustedCost = new ManaCostsImpl<>(); boolean updated = false; for (ManaCost manaCost : manaCosts) { + if (manaCost instanceof SnowManaCost) { + adjustedCost.add(manaCost); + continue; + } Mana mana = manaCost.getOptions().get(0); int colorless = mana != null ? mana.getGeneric() : 0; if (restToReduce != 0 && colorless > 0) { @@ -107,7 +113,15 @@ public final class CardUtil { if (!updated && reduceCount < 0) { adjustedCost.add(new GenericManaCost(-reduceCount)); } - adjustedCost.setSourceFilter(manaCosts.getSourceFilter()); + Filter filter = manaCosts.stream() + .filter(manaCost -> !(manaCost instanceof SnowManaCost)) + .map(ManaCost::getSourceFilter) + .filter(Objects::nonNull) + .findFirst() + .orElse(null); + if (filter != null) { + adjustedCost.setSourceFilter(filter); + } return adjustedCost; }