mirror of
https://github.com/magefree/mage.git
synced 2026-01-10 12:52:06 -08:00
Disable auto-payment of mana for spells which care about mana color (#9173)
This commit is contained in:
parent
045b07c7cf
commit
6035f04140
26 changed files with 174 additions and 20 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,4 +38,9 @@ public class CompoundCondition implements Condition {
|
|||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean caresAboutManaColor() {
|
||||
return conditions.stream().anyMatch(Condition::caresAboutManaColor);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,4 +25,8 @@ public interface Condition extends Serializable {
|
|||
default String getManaText() {
|
||||
return "{" + this.getClass().getSimpleName() + "}";
|
||||
}
|
||||
|
||||
default boolean caresAboutManaColor() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,4 +42,9 @@ public class LockedInCondition implements Condition {
|
|||
return condition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean caresAboutManaColor() {
|
||||
return condition.caresAboutManaColor();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,4 +54,9 @@ public enum AdamantCondition implements Condition {
|
|||
}
|
||||
return payment.getColor(coloredManaSymbol) > 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean caresAboutManaColor() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,4 +45,8 @@ public class ManaWasSpentCondition implements Condition {
|
|||
return "{" + coloredManaSymbol.toString() + "} was spent to cast it";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean caresAboutManaColor() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -195,6 +195,6 @@ public class ConditionalContinuousEffect extends ContinuousEffectImpl {
|
|||
|
||||
@Override
|
||||
public Condition getCondition() {
|
||||
return condition;
|
||||
return condition == null ? baseCondition : condition;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,4 +128,9 @@ public class ConditionalInterveningIfTriggeredAbility extends TriggeredAbilityIm
|
|||
public int getSourceObjectZoneChangeCounter() {
|
||||
return ability.getSourceObjectZoneChangeCounter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean caresAboutManaColor() {
|
||||
return condition.caresAboutManaColor();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,4 +125,5 @@ public abstract class EffectImpl implements Effect {
|
|||
public String getConcatPrefix() {
|
||||
return this.concatPrefix;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,6 +100,11 @@ public class ModularAbility extends DiesSourceTriggeredAbility {
|
|||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean caresAboutManaColor() {
|
||||
return sunburst;
|
||||
}
|
||||
}
|
||||
|
||||
class ModularStaticAbility extends StaticAbility {
|
||||
|
|
|
|||
|
|
@ -46,6 +46,11 @@ public class SunburstAbility extends EntersBattlefieldAbility {
|
|||
return isCreature ? ruleCreature : ruleNonCreature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean caresAboutManaColor() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SunburstEffect extends OneShotEffect {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue