mirror of
https://github.com/correl/mage.git
synced 2024-11-22 03:00:11 +00: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
|
@ -465,9 +465,20 @@ public class HumanPlayer extends PlayerImpl {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (Outcome.PutManaInPool == outcome) {
|
||||
if (currentlyUnpaidMana != null
|
||||
&& ManaUtil.tryToAutoSelectAManaColor(choice, currentlyUnpaidMana)) {
|
||||
// Try to autopay for mana
|
||||
if (Outcome.PutManaInPool == outcome && currentlyUnpaidMana != null) {
|
||||
// Check check if the spell being paid for cares about the color of mana being paid
|
||||
// See: https://github.com/magefree/mage/issues/9070
|
||||
boolean caresAboutManaColor = false;
|
||||
if (!game.getStack().isEmpty() && game.getStack().getFirst() instanceof Spell) {
|
||||
Spell spellBeingCast = (Spell) game.getStack().getFirst();
|
||||
if (!spellBeingCast.isResolving() && spellBeingCast.getControllerId().equals(this.getId())) {
|
||||
CardImpl card = (CardImpl) game.getCard(spellBeingCast.getSourceId());
|
||||
caresAboutManaColor = card.caresAboutManaColor(game);
|
||||
}
|
||||
}
|
||||
|
||||
if (!caresAboutManaColor && ManaUtil.tryToAutoSelectAManaColor(choice, currentlyUnpaidMana)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1537,7 +1548,18 @@ public class HumanPlayer extends PlayerImpl {
|
|||
if (zone != null) {
|
||||
LinkedHashMap<UUID, ActivatedManaAbilityImpl> useableAbilities = getUseableManaAbilities(object, zone, game);
|
||||
if (!useableAbilities.isEmpty()) {
|
||||
useableAbilities = ManaUtil.tryToAutoPay(unpaid, useableAbilities); // eliminates other abilities if one fits perfectly
|
||||
// Added to ensure that mana is not being autopaid for spells that care about the color of mana being paid
|
||||
// See https://github.com/magefree/mage/issues/9070
|
||||
boolean caresAboutManaColor = false;
|
||||
if (abilityToCast.getAbilityType() == AbilityType.SPELL) {
|
||||
CardImpl card = (CardImpl) game.getCard(abilityToCast.getSourceId());
|
||||
caresAboutManaColor = card.caresAboutManaColor(game);
|
||||
}
|
||||
|
||||
// Don't auto-pay if the spell cares about the color
|
||||
if (!caresAboutManaColor) {
|
||||
useableAbilities = ManaUtil.tryToAutoPay(unpaid, useableAbilities); // eliminates other abilities if one fits perfectly
|
||||
}
|
||||
currentlyUnpaidMana = unpaid;
|
||||
activateAbility(useableAbilities, object, game);
|
||||
currentlyUnpaidMana = null;
|
||||
|
|
|
@ -2,6 +2,8 @@ package mage.cards.c;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.CompoundCondition;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.condition.common.ManaWasSpentCondition;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
|
@ -50,6 +52,12 @@ public final class CankerousThirst extends CardImpl {
|
|||
|
||||
class CankerousThirstEffect extends OneShotEffect {
|
||||
|
||||
// Only used for getCondition
|
||||
private static final Condition condition = new CompoundCondition(
|
||||
new ManaWasSpentCondition(ColoredManaSymbol.B),
|
||||
new ManaWasSpentCondition(ColoredManaSymbol.G)
|
||||
);
|
||||
|
||||
public CankerousThirstEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "If {B} was spent to cast this spell, you may have target creature get -3/-3 until end of turn. If {G} was spent to cast this spell, you may have target creature get +3/+3 until end of turn";
|
||||
|
@ -88,4 +96,9 @@ class CankerousThirstEffect extends OneShotEffect {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Condition getCondition() {
|
||||
return condition;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package mage.cards.c;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.condition.common.AdamantCondition;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
|
@ -88,4 +89,9 @@ class CauldronsGiftEffect extends OneShotEffect {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Condition getCondition() {
|
||||
return AdamantCondition.BLACK;
|
||||
}
|
||||
}
|
|
@ -22,7 +22,6 @@ public final class DawnglowInfusion extends CardImpl {
|
|||
public DawnglowInfusion(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{X}{G/W}");
|
||||
|
||||
|
||||
// You gain X life if {G} was spent to cast Dawnglow Infusion and X life if {W} was spent to cast it.
|
||||
DynamicValue xValue = ManacostVariableValue.REGULAR;
|
||||
this.getSpellAbility().addEffect(new ConditionalOneShotEffect(
|
||||
|
@ -32,8 +31,6 @@ public final class DawnglowInfusion extends CardImpl {
|
|||
new GainLifeEffect(xValue),
|
||||
new ManaWasSpentCondition(ColoredManaSymbol.W), "and X life if {W} was spent to cast this spell"));
|
||||
this.getSpellAbility().addEffect(new InfoEffect("<i>(Do both if {G}{W} was spent.)</i>"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
private DawnglowInfusion(final DawnglowInfusion card) {
|
||||
|
|
|
@ -27,7 +27,6 @@ public final class DryadsCaress extends CardImpl {
|
|||
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{4}{G}{G}");
|
||||
|
||||
// You gain 1 life for each creature on the battlefield.
|
||||
|
||||
this.getSpellAbility().addEffect(new GainLifeEffect(new PermanentsOnBattlefieldCount(filter)));
|
||||
|
||||
//If {W} was spent to cast Dryad's Caress, untap all creatures you control.
|
||||
|
|
|
@ -88,4 +88,9 @@ class MythosOfBrokkosEffect extends OneShotEffect {
|
|||
Cards cards = new CardsImpl(targetCard.getTargets());
|
||||
return player.moveCards(cards, Zone.HAND, source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Condition getCondition() {
|
||||
return condition;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,6 +86,11 @@ class MythosOfIllunaEffect extends OneShotEffect {
|
|||
}
|
||||
return effect.apply(game, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Condition getCondition() {
|
||||
return condition;
|
||||
}
|
||||
}
|
||||
|
||||
enum MythosOfIllunaCondition implements Condition {
|
||||
|
|
|
@ -68,4 +68,9 @@ class MythosOfNethroiEffect extends OneShotEffect {
|
|||
}
|
||||
return permanent.destroy(source, game, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Condition getCondition() {
|
||||
return condition;
|
||||
}
|
||||
}
|
|
@ -121,4 +121,9 @@ class MythosOfSnapdaxEffect extends OneShotEffect {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Condition getCondition() {
|
||||
return condition;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package mage.cards.o;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.condition.common.AdamantCondition;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.ExileSpellEffect;
|
||||
|
@ -96,4 +97,9 @@ class OnceAndFutureEffect extends OneShotEffect {
|
|||
player.putCardsOnTopOfLibrary(new CardsImpl(card2), game, source, false);
|
||||
return new ExileSpellEffect().apply(game, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Condition getCondition() {
|
||||
return AdamantCondition.GREEN;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package mage.cards.o;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.condition.common.AdamantCondition;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
|
@ -85,4 +86,9 @@ class OutmuscleEffect extends OneShotEffect {
|
|||
game.getState().processAction(game);
|
||||
return creature.fight(permanent, source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Condition getCondition() {
|
||||
return AdamantCondition.GREEN;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ public final class RepelIntruders extends CardImpl {
|
|||
public RepelIntruders(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{W/U}");
|
||||
|
||||
|
||||
// Create two 1/1 white Kithkin Soldier creature tokens if {W} was spent to cast Repel Intruders. Counter up to one target creature spell if {U} was spent to cast Repel Intruders.
|
||||
TargetSpell target = new TargetSpell(0, 1, new FilterCreatureSpell());
|
||||
target.setRequired(false);
|
||||
|
|
|
@ -22,7 +22,6 @@ public final class RollingSpoil extends CardImpl {
|
|||
public RollingSpoil(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{2}{G}{G}");
|
||||
|
||||
|
||||
// Destroy target land.
|
||||
this.getSpellAbility().addEffect(new DestroyTargetEffect());
|
||||
this.getSpellAbility().addTarget(new TargetLandPermanent());
|
||||
|
|
|
@ -2,6 +2,7 @@ package mage.cards.v;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.condition.common.ManaWasSpentCondition;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.common.InfoEffect;
|
||||
|
@ -34,7 +35,6 @@ public final class VigorMortis extends CardImpl {
|
|||
this.getSpellAbility().addEffect(new ReturnFromGraveyardToBattlefieldTargetEffect());
|
||||
this.getSpellAbility().addEffect(new InfoEffect("If {G} was spent to cast this spell, that creature enters the battlefield with an additional +1/+1 counter on it"));
|
||||
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD));
|
||||
|
||||
}
|
||||
|
||||
private VigorMortis(final VigorMortis card) {
|
||||
|
@ -49,6 +49,8 @@ public final class VigorMortis extends CardImpl {
|
|||
|
||||
class VigorMortisReplacementEffect extends ReplacementEffectImpl {
|
||||
|
||||
private static final Condition condition = new ManaWasSpentCondition(ColoredManaSymbol.G);
|
||||
|
||||
VigorMortisReplacementEffect() {
|
||||
super(Duration.EndOfStep, Outcome.BoostCreature);
|
||||
}
|
||||
|
@ -65,7 +67,7 @@ class VigorMortisReplacementEffect extends ReplacementEffectImpl {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getTargetId().equals(getTargetPointer().getFirst(game, source))) {
|
||||
return new ManaWasSpentCondition(ColoredManaSymbol.G).apply(game, source);
|
||||
return condition.apply(game, source);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -89,4 +91,9 @@ class VigorMortisReplacementEffect extends ReplacementEffectImpl {
|
|||
public VigorMortisReplacementEffect copy() {
|
||||
return new VigorMortisReplacementEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Condition getCondition() {
|
||||
return condition;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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…
Reference in a new issue