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

@ -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.
* <p>
* This is <b>not</b> about which colors are in the mana costs.
* <p>
* 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;
}
}