Disable auto-payment of mana for spells which care about mana color (#9173)

This commit is contained in:
Alex Vasile 2022-10-03 19:16:45 -04:00 committed by GitHub
parent 045b07c7cf
commit 6035f04140
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 174 additions and 20 deletions

View file

@ -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);
}
}