mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
fixed cost modifying effects requiring snow mana unnecessarily (fixes #6000)
This commit is contained in:
parent
928058a192
commit
9170df1344
1 changed files with 15 additions and 1 deletions
|
@ -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<ManaCost> 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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue