Remove duplicate code for X costs (#12551)

* Replace "([a-zA-Z]+).getManaCostsToPay().getX()" with CardUtil.getSourceCostsTag(game, $1, "X", 0)
Fix Disrupting Shoal

* Change final card .getX() calls

* Condense all ManacostVariableValue enum values into "instance"

* Further removal of getX, Display X symbol for non-mana X cards

* Fix test

* Fully remove ManaCosts.getX

* Replace all different X dynamic values with GetXValue

* Remove individual cards checking getAmount for X values (leaving cost reduction that does not use X)

* Add null check for game object inside getSourceCostsTagsMap

* fix build errors

* fix Vicious Betrayal

* text fix
This commit is contained in:
ssk97 2024-07-22 22:57:47 -07:00 committed by GitHub
parent 1cb902fc43
commit e8808c3ae3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
509 changed files with 1322 additions and 1571 deletions

View file

@ -8,7 +8,7 @@ import mage.abilities.Abilities;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode; import mage.abilities.Mode;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.Effects; import mage.abilities.effects.Effects;
import mage.abilities.hint.HintUtils; import mage.abilities.hint.HintUtils;
@ -743,18 +743,10 @@ public class CardView extends SimpleCardView {
} }
// icon - x cost // icon - x cost
if (showCard != null if (showCard != null && showAbility != null
&& showCard.getManaCost().containsX() && (showCard.getManaCost().containsX() || CardUtil.checkSourceCostsTagExists(game, showAbility, "X"))
&& showAbility != null
&& (showZone.match(Zone.BATTLEFIELD) || showZone.match(Zone.STACK))) { && (showZone.match(Zone.BATTLEFIELD) || showZone.match(Zone.STACK))) {
int costX; int costX = GetXValue.instance.calculate(game, showAbility, null);
if (showCard instanceof Permanent) {
// permanent on battlefield (can show x icon multiple turns, so use end_game source)
costX = ManacostVariableValue.END_GAME.calculate(game, showAbility, null);
} else {
// other like Stack (can show x icon on stack only, so use normal source)
costX = ManacostVariableValue.REGULAR.calculate(game, showAbility, null);
}
this.cardIcons.add(CardIconImpl.variableCost(costX)); this.cardIcons.add(CardIconImpl.variableCost(costX));
} }

View file

@ -3,11 +3,9 @@ package mage.view;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Mode; import mage.abilities.Mode;
import mage.abilities.Modes; import mage.abilities.Modes;
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.hint.Hint; import mage.abilities.hint.Hint;
import mage.abilities.hint.HintUtils; import mage.abilities.hint.HintUtils;
import mage.abilities.icon.CardIconImpl;
import mage.cards.Card; import mage.cards.Card;
import mage.constants.AbilityType; import mage.constants.AbilityType;
import mage.constants.CardType; import mage.constants.CardType;
@ -16,7 +14,6 @@ import mage.game.Game;
import mage.game.stack.StackAbility; import mage.game.stack.StackAbility;
import mage.game.stack.StackObject; import mage.game.stack.StackObject;
import mage.target.Target; import mage.target.Target;
import mage.target.targetpointer.FixedTarget;
import mage.target.targetpointer.TargetPointer; import mage.target.targetpointer.TargetPointer;
import mage.util.GameLog; import mage.util.GameLog;

View file

@ -4,7 +4,7 @@ import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.CostAdjuster; import mage.abilities.costs.CostAdjuster;
import mage.abilities.costs.common.DiscardTargetCost; import mage.abilities.costs.common.DiscardTargetCost;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.InfoEffect; import mage.abilities.effects.common.InfoEffect;
import mage.abilities.effects.common.discard.LookTargetHandChooseDiscardEffect; import mage.abilities.effects.common.discard.LookTargetHandChooseDiscardEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -15,6 +15,7 @@ import mage.filter.StaticFilters;
import mage.game.Game; import mage.game.Game;
import mage.target.common.TargetCardInHand; import mage.target.common.TargetCardInHand;
import mage.target.common.TargetOpponent; import mage.target.common.TargetOpponent;
import mage.util.CardUtil;
import java.util.UUID; import java.util.UUID;
@ -34,7 +35,7 @@ public final class AbandonHope extends CardImpl {
this.addAbility(ability); this.addAbility(ability);
// Look at target opponent's hand and choose X cards from it. That player discards those cards. // Look at target opponent's hand and choose X cards from it. That player discards those cards.
this.getSpellAbility().addEffect(new LookTargetHandChooseDiscardEffect(false, ManacostVariableValue.REGULAR)); this.getSpellAbility().addEffect(new LookTargetHandChooseDiscardEffect(false, GetXValue.instance));
this.getSpellAbility().addTarget(new TargetOpponent()); this.getSpellAbility().addTarget(new TargetOpponent());
this.getSpellAbility().setCostAdjuster(AbandonHopeAdjuster.instance); this.getSpellAbility().setCostAdjuster(AbandonHopeAdjuster.instance);
} }
@ -54,7 +55,7 @@ enum AbandonHopeAdjuster implements CostAdjuster {
@Override @Override
public void adjustCosts(Ability ability, Game game) { public void adjustCosts(Ability ability, Game game) {
int xValue = ability.getManaCostsToPay().getX(); int xValue = CardUtil.getSourceCostsTag(game, ability, "X", 0);
if (xValue > 0) { if (xValue > 0) {
ability.addCost(new DiscardTargetCost(new TargetCardInHand(xValue, xValue, StaticFilters.FILTER_CARD_CARDS))); ability.addCost(new DiscardTargetCost(new TargetCardInHand(xValue, xValue, StaticFilters.FILTER_CARD_CARDS)));
} }

View file

@ -1,7 +1,7 @@
package mage.cards.a; package mage.cards.a;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect; import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
@ -75,7 +75,7 @@ class AbuelosAwakeningEffect extends ReturnFromGraveyardToBattlefieldTargetEffec
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
int counterAmount = ManacostVariableValue.REGULAR.calculate(game, source, this); int counterAmount = GetXValue.instance.calculate(game, source, this);
for (UUID targetId : getTargetPointer().getTargets(game, source)) { for (UUID targetId : getTargetPointer().getTargets(game, source)) {
AbuelosAwakeningContinuousEffect continuousEffect = new AbuelosAwakeningContinuousEffect(); AbuelosAwakeningContinuousEffect continuousEffect = new AbuelosAwakeningContinuousEffect();
continuousEffect.setTargetPointer(new FixedTarget(targetId, game)); continuousEffect.setTargetPointer(new FixedTarget(targetId, game));

View file

@ -16,6 +16,7 @@ import mage.game.Game;
import mage.target.common.TargetCardInHand; import mage.target.common.TargetCardInHand;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import mage.target.targetadjustment.XTargetsCountAdjuster; import mage.target.targetadjustment.XTargetsCountAdjuster;
import mage.util.CardUtil;
import java.util.UUID; import java.util.UUID;
@ -58,7 +59,7 @@ enum AetherTideCostAdjuster implements CostAdjuster {
@Override @Override
public void adjustCosts(Ability ability, Game game) { public void adjustCosts(Ability ability, Game game) {
int xValue = ability.getManaCostsToPay().getX(); int xValue = CardUtil.getSourceCostsTag(game, ability, "X", 0);
if (xValue > 0) { if (xValue > 0) {
ability.addCost(new DiscardTargetCost(new TargetCardInHand(xValue, xValue, StaticFilters.FILTER_CARD_CREATURES))); ability.addCost(new DiscardTargetCost(new TargetCardInHand(xValue, xValue, StaticFilters.FILTER_CARD_CREATURES)));
} }

View file

@ -17,6 +17,7 @@ import mage.filter.common.FilterCreatureCard;
import mage.game.Game; import mage.game.Game;
import mage.target.common.TargetCardInYourGraveyard; import mage.target.common.TargetCardInYourGraveyard;
import mage.target.targetadjustment.TargetAdjuster; import mage.target.targetadjustment.TargetAdjuster;
import mage.util.CardUtil;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -74,7 +75,7 @@ enum AgadeemsAwakeningAdjuster implements TargetAdjuster {
@Override @Override
public void adjustTargets(Ability ability, Game game) { public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear(); ability.getTargets().clear();
ability.addTarget(new AgadeemsAwakeningTarget(ability.getManaCostsToPay().getX())); ability.addTarget(new AgadeemsAwakeningTarget(CardUtil.getSourceCostsTag(game, ability, "X", 0)));
} }
} }

View file

@ -1,7 +1,5 @@
package mage.cards.a; package mage.cards.a;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
@ -18,6 +16,9 @@ import mage.players.Player;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
import java.util.UUID;
/** /**
* @author Cguy7777 * @author Cguy7777
@ -72,7 +73,7 @@ class AggressiveBiomancyEffect extends OneShotEffect {
source.getControllerId(), source.getControllerId(),
null, null,
false, false,
source.getManaCostsToPay().getX()); CardUtil.getSourceCostsTag(game, source, "X", 0));
effect.addAdditionalAbilities(fightAbility); effect.addAdditionalAbilities(fightAbility);
effect.setTargetPointer(new FixedTarget(creatureToCopy, game)); effect.setTargetPointer(new FixedTarget(creatureToCopy, game));
return effect.apply(game, source); return effect.apply(game, source);

View file

@ -3,7 +3,7 @@ package mage.cards.a;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Mode; import mage.abilities.Mode;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.GainLifeTargetEffect; import mage.abilities.effects.common.GainLifeTargetEffect;
import mage.abilities.effects.common.PreventDamageToTargetEffect; import mage.abilities.effects.common.PreventDamageToTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -23,9 +23,9 @@ public final class AlabasterPotion extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{W}{W}"); super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{W}{W}");
// Choose one - Target player gains X life; or prevent the next X damage that would be dealt to any target this turn. // Choose one - Target player gains X life; or prevent the next X damage that would be dealt to any target this turn.
this.getSpellAbility().addEffect(new GainLifeTargetEffect(ManacostVariableValue.REGULAR)); this.getSpellAbility().addEffect(new GainLifeTargetEffect(GetXValue.instance));
this.getSpellAbility().addTarget(new TargetPlayer()); this.getSpellAbility().addTarget(new TargetPlayer());
Mode mode = new Mode(new PreventDamageToTargetEffect(Duration.EndOfTurn, false, true, ManacostVariableValue.REGULAR)); Mode mode = new Mode(new PreventDamageToTargetEffect(Duration.EndOfTurn, false, true, GetXValue.instance));
mode.addTarget(new TargetAnyTarget()); mode.addTarget(new TargetAnyTarget());
this.getSpellAbility().addMode(mode); this.getSpellAbility().addMode(mode);
} }

View file

@ -1,14 +1,16 @@
package mage.cards.a; package mage.cards.a;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.costs.mana.VariableManaCost; import mage.abilities.costs.mana.VariableManaCost;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.*; import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
@ -18,6 +20,9 @@ import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetCard; import mage.target.TargetCard;
import mage.util.CardUtil;
import java.util.UUID;
/** /**
* *
@ -73,7 +78,7 @@ class AladdinsLampEffect extends ReplacementEffectImpl {
return false; return false;
} }
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, source.getManaCostsToPay().getX())); Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, CardUtil.getSourceCostsTag(game, source, "X", 0)));
controller.lookAtCards(source, null, cards, game); controller.lookAtCards(source, null, cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to stay at the top of library")); TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to stay at the top of library"));
if (controller.choose(outcome, cards, target, source, game)) { if (controller.choose(outcome, cards, target, source, game)) {

View file

@ -7,7 +7,7 @@ import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.SacrificeTargetCost; import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.keyword.InvestigateEffect; import mage.abilities.effects.keyword.InvestigateEffect;
@ -43,11 +43,11 @@ public final class AlquistProftMasterSleuth extends CardImpl {
// {X}{W}{U}{U}, {T}, Sacrifice a Clue: You draw X cards and gain X life. // {X}{W}{U}{U}, {T}, Sacrifice a Clue: You draw X cards and gain X life.
Ability ability = new SimpleActivatedAbility( Ability ability = new SimpleActivatedAbility(
new DrawCardSourceControllerEffect(ManacostVariableValue.REGULAR, "you"), new ManaCostsImpl<>("{X}{W}{U}{U}") new DrawCardSourceControllerEffect(GetXValue.instance, "you"), new ManaCostsImpl<>("{X}{W}{U}{U}")
); );
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
ability.addCost(new SacrificeTargetCost(StaticFilters.FILTER_CONTROLLED_CLUE)); ability.addCost(new SacrificeTargetCost(StaticFilters.FILTER_CONTROLLED_CLUE));
ability.addEffect(new GainLifeEffect(ManacostVariableValue.REGULAR).setText("and gain X life")); ability.addEffect(new GainLifeEffect(GetXValue.instance).setText("and gain X life"));
this.addAbility(ability); this.addAbility(ability);
} }

View file

@ -1,9 +1,6 @@
package mage.cards.a; package mage.cards.a;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.condition.common.SpellMasteryCondition; import mage.abilities.condition.common.SpellMasteryCondition;
@ -16,6 +13,11 @@ import mage.filter.common.FilterLandCard;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.util.CardUtil;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
/** /**
* *
@ -61,7 +63,7 @@ class AnimistsAwakeningEffect extends OneShotEffect {
return false; return false;
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl();
int xValue = source.getManaCostsToPay().getX(); int xValue = CardUtil.getSourceCostsTag(game, source, "X", 0);
cards.addAllCards(controller.getLibrary().getTopCards(game, xValue)); cards.addAllCards(controller.getLibrary().getTopCards(game, xValue));
if (!cards.isEmpty()) { if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getIdName(), cards, game); controller.revealCards(sourceObject.getIdName(), cards, game);

View file

@ -2,7 +2,7 @@ package mage.cards.a;
import mage.MageObjectReference; import mage.MageObjectReference;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileThenReturnTargetEffect; import mage.abilities.effects.common.ExileThenReturnTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -60,7 +60,7 @@ class AnotherRoundEffect extends OneShotEffect {
return false; return false;
} }
int xValue = ManacostVariableValue.REGULAR.calculate(game, source, this); int xValue = GetXValue.instance.calculate(game, source, this);
TargetControlledCreaturePermanent target = TargetControlledCreaturePermanent target =
new TargetControlledCreaturePermanent( new TargetControlledCreaturePermanent(
0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE,

View file

@ -18,6 +18,7 @@ import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.util.CardUtil;
import java.util.UUID; import java.util.UUID;
@ -75,7 +76,7 @@ class AnthroplasmEffect extends OneShotEffect {
//Remove all +1/+1 counters //Remove all +1/+1 counters
permanent.removeAllCounters(CounterType.P1P1.getName(), source, game); permanent.removeAllCounters(CounterType.P1P1.getName(), source, game);
//put X +1/+1 counters //put X +1/+1 counters
permanent.addCounters(CounterType.P1P1.createInstance(source.getManaCostsToPay().getX()), source.getControllerId(), source, game); permanent.addCounters(CounterType.P1P1.createInstance(CardUtil.getSourceCostsTag(game, source, "X", 0)), source.getControllerId(), source, game);
return true; return true;
} }
return false; return false;

View file

@ -7,7 +7,7 @@ import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.DamageAllEffect; import mage.abilities.effects.common.DamageAllEffect;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.keyword.ChannelAbility; import mage.abilities.keyword.ChannelAbility;
@ -43,13 +43,13 @@ public final class ArashiTheSkyAsunder extends CardImpl {
this.toughness = new MageInt(5); this.toughness = new MageInt(5);
// {X}{G}, {tap}: Arashi, the Sky Asunder deals X damage to target creature with flying. // {X}{G}, {tap}: Arashi, the Sky Asunder deals X damage to target creature with flying.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(ManacostVariableValue.REGULAR), new ManaCostsImpl<>("{X}{G}")); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(GetXValue.instance), new ManaCostsImpl<>("{X}{G}"));
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
ability.addTarget(new TargetPermanent(filter)); ability.addTarget(new TargetPermanent(filter));
this.addAbility(ability); this.addAbility(ability);
// Channel - {X}{G}{G}, Discard Arashi: Arashi deals X damage to each creature with flying. // Channel - {X}{G}{G}, Discard Arashi: Arashi deals X damage to each creature with flying.
this.addAbility(new ChannelAbility("{X}{G}{G}", new DamageAllEffect(ManacostVariableValue.REGULAR, filter))); this.addAbility(new ChannelAbility("{X}{G}{G}", new DamageAllEffect(GetXValue.instance, filter)));
} }
private ArashiTheSkyAsunder(final ArashiTheSkyAsunder card) { private ArashiTheSkyAsunder(final ArashiTheSkyAsunder card) {

View file

@ -3,7 +3,7 @@ package mage.cards.a;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.AttacksWithCreaturesTriggeredAbility; import mage.abilities.common.AttacksWithCreaturesTriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.PopulateEffect; import mage.abilities.effects.common.PopulateEffect;
@ -66,7 +66,7 @@ class ArborealAllianceEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
return new CreateTokenEffect( return new CreateTokenEffect(
new SylvanOfferingTreefolkToken(ManacostVariableValue.ETB.calculate(game, source, this)) new SylvanOfferingTreefolkToken(GetXValue.instance.calculate(game, source, this))
).apply(game, source); ).apply(game, source);
} }
} }

View file

@ -14,6 +14,7 @@ import mage.filter.FilterCard;
import mage.filter.predicate.Predicates; import mage.filter.predicate.Predicates;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.util.CardUtil;
import java.util.UUID; import java.util.UUID;
@ -73,7 +74,7 @@ class AscendFromAvernusEffect extends OneShotEffect {
return false; return false;
} }
Cards cards = new CardsImpl(player.getGraveyard().getCards(filter, game)); Cards cards = new CardsImpl(player.getGraveyard().getCards(filter, game));
cards.removeIf(uuid -> game.getCard(uuid).getManaValue() > source.getManaCostsToPay().getX()); cards.removeIf(uuid -> game.getCard(uuid).getManaValue() > CardUtil.getSourceCostsTag(game, source, "X", 0));
return player.moveCards(cards, Zone.BATTLEFIELD, source, game); return player.moveCards(cards, Zone.BATTLEFIELD, source, game);
} }
} }

View file

@ -2,8 +2,6 @@ package mage.cards.a;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility; import mage.abilities.LoyaltyAbility;
import mage.abilities.costs.VariableCostImpl;
import mage.abilities.costs.common.PayVariableLoyaltyCost;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.AddCardSubTypeTargetEffect; import mage.abilities.effects.common.continuous.AddCardSubTypeTargetEffect;
import mage.cards.*; import mage.cards.*;
@ -111,9 +109,7 @@ class AshiokNightmareWeaverPutIntoPlayEffect extends OneShotEffect {
return false; return false;
} }
int cmc = CardUtil.castStream( int cmc = CardUtil.getSourceCostsTag(game, source, "X", 0);
source.getCosts().stream(), PayVariableLoyaltyCost.class
).mapToInt(VariableCostImpl::getAmount).sum();
FilterCard filter = new FilterCreatureCard("creature card with mana value " + cmc); FilterCard filter = new FilterCreatureCard("creature card with mana value " + cmc);
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, cmc)); filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, cmc));

View file

@ -1,6 +1,6 @@
package mage.cards.a; package mage.cards.a;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect; import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
import mage.abilities.effects.keyword.AmassEffect; import mage.abilities.effects.keyword.AmassEffect;
import mage.abilities.keyword.DoubleStrikeAbility; import mage.abilities.keyword.DoubleStrikeAbility;
@ -33,7 +33,7 @@ public final class AssaultOnOsgiliath extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{R}{R}{R}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{R}{R}{R}");
// Amass Orcs X, then Goblins and Orcs you control gain double strike and haste until end of turn. // Amass Orcs X, then Goblins and Orcs you control gain double strike and haste until end of turn.
this.getSpellAbility().addEffect(new AmassEffect(ManacostVariableValue.REGULAR, SubType.ORC)); this.getSpellAbility().addEffect(new AmassEffect(GetXValue.instance, SubType.ORC));
this.getSpellAbility().addEffect(new GainAbilityControlledEffect( this.getSpellAbility().addEffect(new GainAbilityControlledEffect(
DoubleStrikeAbility.getInstance(), Duration.EndOfTurn, filter DoubleStrikeAbility.getInstance(), Duration.EndOfTurn, filter
).setText(", then Goblins and Orcs you control gain double strike")); ).setText(", then Goblins and Orcs you control gain double strike"));

View file

@ -10,7 +10,7 @@ import mage.abilities.costs.VariableCost;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.costs.mana.VariableManaCost; import mage.abilities.costs.mana.VariableManaCost;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.PreventDamageToTargetEffect; import mage.abilities.effects.common.PreventDamageToTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -41,7 +41,7 @@ public final class AtalyaSamiteMaster extends CardImpl {
this.toughness = new MageInt(3); this.toughness = new MageInt(3);
// {X}, {tap}: Choose one - Prevent the next X damage that would be dealt to target creature this turn; or you gain X life. Spend only white mana on X. // {X}, {tap}: Choose one - Prevent the next X damage that would be dealt to target creature this turn; or you gain X life. Spend only white mana on X.
PreventDamageToTargetEffect effect = new PreventDamageToTargetEffect(Duration.EndOfTurn, false, true, ManacostVariableValue.REGULAR); PreventDamageToTargetEffect effect = new PreventDamageToTargetEffect(Duration.EndOfTurn, false, true, GetXValue.instance);
effect.setText("Prevent the next X damage that would be dealt to target creature this turn. Spend only white mana on X."); effect.setText("Prevent the next X damage that would be dealt to target creature this turn. Spend only white mana on X.");
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl<>("{X}")); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl<>("{X}"));
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
@ -54,7 +54,7 @@ public final class AtalyaSamiteMaster extends CardImpl {
ability.addTarget(new TargetCreaturePermanent()); ability.addTarget(new TargetCreaturePermanent());
// or you gain X life // or you gain X life
Mode mode = new Mode(new GainLifeEffect(ManacostVariableValue.REGULAR).setText("You gain X life. Spend only white mana on X.")); Mode mode = new Mode(new GainLifeEffect(GetXValue.instance).setText("You gain X life. Spend only white mana on X."));
ability.addMode(mode); ability.addMode(mode);
this.addAbility(ability); this.addAbility(ability);

View file

@ -11,6 +11,7 @@ import mage.game.Game;
import mage.game.permanent.token.StormCrowToken; import mage.game.permanent.token.StormCrowToken;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import mage.util.CardUtil;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
@ -62,7 +63,7 @@ class AttemptedMurderEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
int xValue = source.getManaCostsToPay().getX(); int xValue = CardUtil.getSourceCostsTag(game, source, "X", 0);
if (player == null || xValue < 1) { if (player == null || xValue < 1) {
return false; return false;
} }

View file

@ -4,7 +4,7 @@ package mage.cards.a;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
@ -61,7 +61,7 @@ public final class AureliasFury extends CardImpl {
// Aurelia's Fury deals X damage divided as you choose among any number of target creatures and/or players. // Aurelia's Fury deals X damage divided as you choose among any number of target creatures and/or players.
// Tap each creature dealt damage this way. Players dealt damage this way can't cast noncreature spells this turn. // Tap each creature dealt damage this way. Players dealt damage this way can't cast noncreature spells this turn.
DynamicValue xValue = ManacostVariableValue.REGULAR; DynamicValue xValue = GetXValue.instance;
this.getSpellAbility().addEffect(new DamageMultiEffect(xValue)); this.getSpellAbility().addEffect(new DamageMultiEffect(xValue));
this.getSpellAbility().addEffect(new AureliasFuryEffect()); this.getSpellAbility().addEffect(new AureliasFuryEffect());
this.getSpellAbility().addTarget(new TargetAnyTargetAmount(xValue)); this.getSpellAbility().addTarget(new TargetAnyTargetAmount(xValue));

View file

@ -1,7 +1,6 @@
package mage.cards.a; package mage.cards.a;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.costs.mana.ManaCosts; import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
@ -14,6 +13,9 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.game.Game; import mage.game.Game;
import mage.target.common.TargetAnyTargetAmount; import mage.target.common.TargetAnyTargetAmount;
import mage.util.CardUtil;
import java.util.UUID;
/** /**
* *
@ -55,7 +57,7 @@ class AvacynsJudgmentManacostVariableValue implements DynamicValue {
if (manaCosts.getVariableCosts().isEmpty()) { if (manaCosts.getVariableCosts().isEmpty()) {
return 2; return 2;
} }
return sourceAbility.getManaCostsToPay().getX(); return CardUtil.getSourceCostsTag(game, sourceAbility, "X", 0);
} }
@Override @Override

View file

@ -1,7 +1,7 @@
package mage.cards.a; package mage.cards.a;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.DestroyTargetEffect; import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -30,7 +30,7 @@ public final class Avalanche extends CardImpl {
// Destroy X target snow lands. // Destroy X target snow lands.
this.getSpellAbility().addEffect(new DestroyTargetEffect("Destroy X target snow lands")); this.getSpellAbility().addEffect(new DestroyTargetEffect("Destroy X target snow lands"));
this.getSpellAbility().addTarget(new TargetPermanent(1, 1, filter, false)); this.getSpellAbility().addTarget(new TargetPermanent(1, 1, filter, false));
this.getSpellAbility().setTargetAdjuster(new TargetsCountAdjuster(ManacostVariableValue.REGULAR)); this.getSpellAbility().setTargetAdjuster(new TargetsCountAdjuster(GetXValue.instance));
} }

View file

@ -1,6 +1,6 @@
package mage.cards.a; package mage.cards.a;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.CreateTokenEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -18,7 +18,7 @@ public final class AwakenTheWoods extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{G}{G}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{G}{G}");
// Create X 1/1 green Forest Dryad land creature tokens. // Create X 1/1 green Forest Dryad land creature tokens.
this.getSpellAbility().addEffect(new CreateTokenEffect(new ForestDryadToken(), ManacostVariableValue.REGULAR)); this.getSpellAbility().addEffect(new CreateTokenEffect(new ForestDryadToken(), GetXValue.instance));
} }
private AwakenTheWoods(final AwakenTheWoods card) { private AwakenTheWoods(final AwakenTheWoods card) {

View file

@ -5,7 +5,7 @@ import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.common.counter.AddCountersAttachedEffect; import mage.abilities.effects.common.counter.AddCountersAttachedEffect;
import mage.constants.*; import mage.constants.*;
@ -38,7 +38,7 @@ public final class AwakenedAwareness extends CardImpl {
// When Awakened Awareness enters the battlefield, put X +1/+1 counters on enchanted permanent. // When Awakened Awareness enters the battlefield, put X +1/+1 counters on enchanted permanent.
this.addAbility(new EntersBattlefieldTriggeredAbility( this.addAbility(new EntersBattlefieldTriggeredAbility(
new AddCountersAttachedEffect(CounterType.P1P1.createInstance(), ManacostVariableValue.ETB, "enchanted permanent") new AddCountersAttachedEffect(CounterType.P1P1.createInstance(), GetXValue.instance, "enchanted permanent")
)); ));
// As long as enchanted permanent is a creature, it has base power and toughness 1/1. // As long as enchanted permanent is a creature, it has base power and toughness 1/1.

View file

@ -1,6 +1,6 @@
package mage.cards.b; package mage.cards.b;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect; import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -30,7 +30,7 @@ public final class BackInTown extends CardImpl {
this.getSpellAbility().addEffect(new ReturnFromGraveyardToBattlefieldTargetEffect() this.getSpellAbility().addEffect(new ReturnFromGraveyardToBattlefieldTargetEffect()
.setText("return X target outlaw creature cards from your graveyard to the battlefield")); .setText("return X target outlaw creature cards from your graveyard to the battlefield"));
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(filter)); this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(filter));
this.getSpellAbility().setTargetAdjuster(new TargetsCountAdjuster(ManacostVariableValue.REGULAR)); this.getSpellAbility().setTargetAdjuster(new TargetsCountAdjuster(GetXValue.instance));
} }
private BackInTown(final BackInTown card) { private BackInTown(final BackInTown card) {

View file

@ -3,7 +3,7 @@ package mage.cards.b;
import java.util.UUID; import java.util.UUID;
import mage.abilities.common.delayed.AtTheBeginOfNextUpkeepDelayedTriggeredAbility; import mage.abilities.common.delayed.AtTheBeginOfNextUpkeepDelayedTriggeredAbility;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect; import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect;
@ -25,7 +25,7 @@ public final class BalduvianRage extends CardImpl {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{X}{R}"); super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{X}{R}");
// Target attacking creature gets +X/+0 until end of turn. // Target attacking creature gets +X/+0 until end of turn.
this.getSpellAbility().addEffect(new BoostTargetEffect(ManacostVariableValue.REGULAR, StaticValue.get(0), Duration.EndOfTurn)); this.getSpellAbility().addEffect(new BoostTargetEffect(GetXValue.instance, StaticValue.get(0), Duration.EndOfTurn));
this.getSpellAbility().addTarget(new TargetCreaturePermanent(new FilterAttackingCreature())); this.getSpellAbility().addTarget(new TargetCreaturePermanent(new FilterAttackingCreature()));
// Draw a card at the beginning of the next turn's upkeep. // Draw a card at the beginning of the next turn's upkeep.

View file

@ -7,7 +7,7 @@ import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -30,7 +30,7 @@ public final class BallistaSquad extends CardImpl {
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
// {X}{W}, {T}: Ballista Squad deals X damage to target attacking or blocking creature. // {X}{W}, {T}: Ballista Squad deals X damage to target attacking or blocking creature.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(ManacostVariableValue.REGULAR), new ManaCostsImpl<>("{X}{W}")); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(GetXValue.instance), new ManaCostsImpl<>("{X}{W}"));
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
ability.addTarget(new TargetAttackingOrBlockingCreature()); ability.addTarget(new TargetAttackingOrBlockingCreature());
this.addAbility(ability); this.addAbility(ability);

View file

@ -1,11 +1,10 @@
package mage.cards.b; package mage.cards.b;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.Condition; import mage.abilities.condition.Condition;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.Card; import mage.cards.Card;
@ -21,6 +20,9 @@ import mage.game.permanent.Permanent;
import mage.game.stack.Spell; import mage.game.stack.Spell;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetAnyTarget; import mage.target.common.TargetAnyTarget;
import mage.util.CardUtil;
import java.util.UUID;
/** /**
* *
@ -90,7 +92,7 @@ class BaneFireEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(source.getFirstTarget()); Player targetPlayer = game.getPlayer(source.getFirstTarget());
Permanent targetCreature = game.getPermanent(source.getFirstTarget()); Permanent targetCreature = game.getPermanent(source.getFirstTarget());
int damage = source.getManaCostsToPay().getX(); int damage = CardUtil.getSourceCostsTag(game, source, "X", 0);
boolean preventable = damage < 5; boolean preventable = damage < 5;
if (targetPlayer != null) { if (targetPlayer != null) {
targetPlayer.damage(damage, source.getSourceId(), source, game, false, preventable); targetPlayer.damage(damage, source.getSourceId(), source, game, false, preventable);
@ -106,7 +108,7 @@ class BaneFireEffect extends OneShotEffect {
class BanefireCantCounterEffect extends ContinuousRuleModifyingEffectImpl { class BanefireCantCounterEffect extends ContinuousRuleModifyingEffectImpl {
private Condition condition = new testCondition(ManacostVariableValue.REGULAR, 5); private Condition condition = new testCondition(GetXValue.instance, 5);
public BanefireCantCounterEffect() { public BanefireCantCounterEffect() {
super(Duration.WhileOnStack, Outcome.Benefit); super(Duration.WhileOnStack, Outcome.Benefit);

View file

@ -8,7 +8,7 @@ import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.dynamicvalue.common.HalfValue; import mage.abilities.dynamicvalue.common.HalfValue;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.DamageControllerEffect; import mage.abilities.effects.common.DamageControllerEffect;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -31,9 +31,9 @@ public final class Banshee extends CardImpl {
this.toughness = new MageInt(1); this.toughness = new MageInt(1);
// {X}, {T}: Banshee deals half X damage, rounded down, to any target, and half X damage, rounded up, to you. // {X}, {T}: Banshee deals half X damage, rounded down, to any target, and half X damage, rounded up, to you.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(new HalfValue(ManacostVariableValue.REGULAR, false)).setText("Banshee deals half X damage, rounded down, to any target,"), new ManaCostsImpl<>("{X}")); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(new HalfValue(GetXValue.instance, false)).setText("Banshee deals half X damage, rounded down, to any target,"), new ManaCostsImpl<>("{X}"));
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
ability.addEffect(new DamageControllerEffect(new HalfValue(ManacostVariableValue.REGULAR, true)).setText(" and half X damage, rounded up, to you")); ability.addEffect(new DamageControllerEffect(new HalfValue(GetXValue.instance, true)).setText(" and half X damage, rounded up, to you"));
ability.addTarget(new TargetAnyTarget()); ability.addTarget(new TargetAnyTarget());
this.addAbility(ability); this.addAbility(ability);
} }

View file

@ -7,7 +7,7 @@ import mage.abilities.condition.common.MorbidCondition;
import mage.abilities.condition.common.YouControlPermanentCondition; import mage.abilities.condition.common.YouControlPermanentCondition;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.keyword.AmassEffect; import mage.abilities.effects.keyword.AmassEffect;
import mage.abilities.mana.BlackManaAbility; import mage.abilities.mana.BlackManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -48,7 +48,7 @@ public final class BaradDur extends CardImpl {
// {X}{X}{B}, {T}: Amass Orcs X. Activate only if a creature died this turn. // {X}{X}{B}, {T}: Amass Orcs X. Activate only if a creature died this turn.
Ability ability = new ActivateIfConditionActivatedAbility( Ability ability = new ActivateIfConditionActivatedAbility(
Zone.BATTLEFIELD, Zone.BATTLEFIELD,
new AmassEffect(ManacostVariableValue.REGULAR, SubType.ORC, false), new AmassEffect(GetXValue.instance, SubType.ORC, false),
new ManaCostsImpl<>("{X}{X}{B}"), new ManaCostsImpl<>("{X}{X}{B}"),
MorbidCondition.instance MorbidCondition.instance
); );

View file

@ -3,7 +3,7 @@ package mage.cards.b;
import java.util.UUID; import java.util.UUID;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.dynamicvalue.common.SignInversionDynamicValue; import mage.abilities.dynamicvalue.common.SignInversionDynamicValue;
import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.continuous.BoostTargetEffect; import mage.abilities.effects.common.continuous.BoostTargetEffect;
@ -20,7 +20,7 @@ import mage.target.common.TargetCreaturePermanent;
*/ */
public final class BattleAtTheBridge extends CardImpl { public final class BattleAtTheBridge extends CardImpl {
private static final DynamicValue xValue = new SignInversionDynamicValue(ManacostVariableValue.REGULAR); private static final DynamicValue xValue = new SignInversionDynamicValue(GetXValue.instance);
public BattleAtTheBridge(UUID ownerId, CardSetInfo setInfo) { public BattleAtTheBridge(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{B}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{B}");
@ -32,7 +32,7 @@ public final class BattleAtTheBridge extends CardImpl {
this.getSpellAbility().addEffect(new BoostTargetEffect(xValue, xValue, Duration.EndOfTurn)); this.getSpellAbility().addEffect(new BoostTargetEffect(xValue, xValue, Duration.EndOfTurn));
this.getSpellAbility().addTarget(new TargetCreaturePermanent()); this.getSpellAbility().addTarget(new TargetCreaturePermanent());
this.getSpellAbility().addEffect(new GainLifeEffect(ManacostVariableValue.REGULAR)); this.getSpellAbility().addEffect(new GainLifeEffect(GetXValue.instance));
} }
private BattleAtTheBridge(final BattleAtTheBridge card) { private BattleAtTheBridge(final BattleAtTheBridge card) {

View file

@ -10,6 +10,7 @@ import mage.constants.Outcome;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.game.Game; import mage.game.Game;
import mage.target.common.TargetCardWithDifferentNameInLibrary; import mage.target.common.TargetCardWithDifferentNameInLibrary;
import mage.util.CardUtil;
import java.util.UUID; import java.util.UUID;
@ -60,7 +61,7 @@ class BeginTheInvasionEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
int xValue = source.getManaCostsToPay().getX(); int xValue = CardUtil.getSourceCostsTag(game, source, "X", 0);
return new SearchLibraryPutInPlayEffect( return new SearchLibraryPutInPlayEffect(
new TargetCardWithDifferentNameInLibrary(0, xValue, filter), false new TargetCardWithDifferentNameInLibrary(0, xValue, filter), false
).apply(game, source); ).apply(game, source);

View file

@ -5,7 +5,7 @@ import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.MultipliedValue; import mage.abilities.dynamicvalue.MultipliedValue;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.continuous.BoostTargetEffect; import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -25,8 +25,8 @@ public final class BelbesArmor extends CardImpl {
// {X}, {tap}: Target creature gets -X/+X until end of turn. // {X}, {tap}: Target creature gets -X/+X until end of turn.
Ability ability = new SimpleActivatedAbility(new BoostTargetEffect( Ability ability = new SimpleActivatedAbility(new BoostTargetEffect(
new MultipliedValue(ManacostVariableValue.REGULAR, -1), new MultipliedValue(GetXValue.instance, -1),
ManacostVariableValue.REGULAR, Duration.EndOfTurn GetXValue.instance, Duration.EndOfTurn
).setText("Target creature gets -X/+X until end of turn"), new ManaCostsImpl<>("{X}")); ).setText("Target creature gets -X/+X until end of turn"), new ManaCostsImpl<>("{X}"));
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
ability.addTarget(new TargetCreaturePermanent()); ability.addTarget(new TargetCreaturePermanent());

View file

@ -3,7 +3,7 @@ package mage.cards.b;
import java.util.UUID; import java.util.UUID;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.continuous.SetBasePowerToughnessAllEffect; import mage.abilities.effects.common.continuous.SetBasePowerToughnessAllEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -22,7 +22,7 @@ public final class BiomassMutation extends CardImpl {
// Creatures you control have base power and toughness X/X until end of turn. // Creatures you control have base power and toughness X/X until end of turn.
DynamicValue variableMana = ManacostVariableValue.REGULAR; DynamicValue variableMana = GetXValue.instance;
this.getSpellAbility().addEffect(new SetBasePowerToughnessAllEffect(variableMana, variableMana, Duration.EndOfTurn, StaticFilters.FILTER_CONTROLLED_CREATURES)); this.getSpellAbility().addEffect(new SetBasePowerToughnessAllEffect(variableMana, variableMana, Duration.EndOfTurn, StaticFilters.FILTER_CONTROLLED_CREATURES));
} }

View file

@ -9,7 +9,7 @@ import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.IntPlusDynamicValue; import mage.abilities.dynamicvalue.IntPlusDynamicValue;
import mage.abilities.dynamicvalue.common.CountersSourceCount; import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.mana.DynamicManaAbility; import mage.abilities.mana.DynamicManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -38,7 +38,7 @@ public final class BlackManaBattery extends CardImpl {
// Add {B}, then add an additional {B} for each charge counter removed this way. // Add {B}, then add an additional {B} for each charge counter removed this way.
ability = new DynamicManaAbility( ability = new DynamicManaAbility(
Mana.BlackMana(1), Mana.BlackMana(1),
new IntPlusDynamicValue(1, RemovedCountersForCostValue.instance), new IntPlusDynamicValue(1, GetXValue.instance),
new TapSourceCost(), new TapSourceCost(),
"Add {B}, then add {B} for each charge counter removed this way", "Add {B}, then add {B} for each charge counter removed this way",
true, new IntPlusDynamicValue(1, new CountersSourceCount(CounterType.CHARGE))); true, new IntPlusDynamicValue(1, new CountersSourceCount(CounterType.CHARGE)));

View file

@ -1,10 +1,8 @@
package mage.cards.b; package mage.cards.b;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.dynamicvalue.common.SignInversionDynamicValue; import mage.abilities.dynamicvalue.common.SignInversionDynamicValue;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.BoostTargetEffect; import mage.abilities.effects.common.continuous.BoostTargetEffect;
@ -20,13 +18,16 @@ import mage.players.Player;
import mage.target.TargetCard; import mage.target.TargetCard;
import mage.target.common.TargetCardInYourGraveyard; import mage.target.common.TargetCardInYourGraveyard;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import mage.util.CardUtil;
import java.util.UUID;
/** /**
* @author TheElk801 * @author TheElk801
*/ */
public final class BlackSunsTwilight extends CardImpl { public final class BlackSunsTwilight extends CardImpl {
private static final DynamicValue xValue = new SignInversionDynamicValue(ManacostVariableValue.REGULAR); private static final DynamicValue xValue = new SignInversionDynamicValue(GetXValue.instance);
public BlackSunsTwilight(UUID ownerId, CardSetInfo setInfo) { public BlackSunsTwilight(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{B}"); super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{B}");
@ -69,7 +70,7 @@ class BlackSunsTwilightEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
int xValue = source.getManaCostsToPay().getX(); int xValue = CardUtil.getSourceCostsTag(game, source, "X", 0);
if (player == null || xValue < 5) { if (player == null || xValue < 5) {
return false; return false;
} }

View file

@ -2,7 +2,6 @@
package mage.cards.b; package mage.cards.b;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ShuffleSpellEffect; import mage.abilities.effects.common.ShuffleSpellEffect;
@ -13,6 +12,9 @@ import mage.constants.Outcome;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.util.CardUtil;
import java.util.UUID;
/** /**
* *
@ -51,7 +53,7 @@ class BlackSunsZenithEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
int amount = source.getManaCostsToPay().getX(); int amount = CardUtil.getSourceCostsTag(game, source, "X", 0);
for (Permanent permanent : game.getBattlefield().getAllActivePermanents()) { for (Permanent permanent : game.getBattlefield().getAllActivePermanents()) {
if (permanent != null && permanent.isCreature(game)) { if (permanent != null && permanent.isCreature(game)) {
permanent.addCounters(CounterType.M1M1.createInstance(amount), source.getControllerId(), source, game); permanent.addCounters(CounterType.M1M1.createInstance(amount), source.getControllerId(), source, game);

View file

@ -9,7 +9,7 @@ import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.MultipliedValue; import mage.abilities.dynamicvalue.MultipliedValue;
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BoostSourceEffect; import mage.abilities.effects.common.continuous.BoostSourceEffect;
@ -27,7 +27,7 @@ import mage.filter.StaticFilters;
*/ */
public final class BlademaneBaku extends CardImpl { public final class BlademaneBaku extends CardImpl {
private static final DynamicValue xValue = new MultipliedValue(RemovedCountersForCostValue.instance, 2); private static final DynamicValue xValue = new MultipliedValue(GetXValue.instance, 2);
public BlademaneBaku(UUID ownerId, CardSetInfo setInfo) { public BlademaneBaku(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{R}"); super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{R}");

View file

@ -7,7 +7,7 @@ import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DestroyAllEffect; import mage.abilities.effects.common.DestroyAllEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
@ -46,7 +46,7 @@ public final class BlastZone extends CardImpl {
// {X}{X}, {T}: Put X charge counters on Blast Zone. // {X}{X}, {T}: Put X charge counters on Blast Zone.
Ability ability = new SimpleActivatedAbility(new AddCountersSourceEffect( Ability ability = new SimpleActivatedAbility(new AddCountersSourceEffect(
CounterType.CHARGE.createInstance(), ManacostVariableValue.REGULAR, true CounterType.CHARGE.createInstance(), GetXValue.instance, true
), new ManaCostsImpl<>("{X}{X}")); ), new ManaCostsImpl<>("{X}{X}"));
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
this.addAbility(ability); this.addAbility(ability);

View file

@ -2,7 +2,7 @@
package mage.cards.b; package mage.cards.b;
import java.util.UUID; import java.util.UUID;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -20,7 +20,7 @@ public final class Blaze extends CardImpl {
// Blaze deals X damage to any target. // Blaze deals X damage to any target.
this.getSpellAbility().addEffect(new DamageTargetEffect(ManacostVariableValue.REGULAR)); this.getSpellAbility().addEffect(new DamageTargetEffect(GetXValue.instance));
this.getSpellAbility().addTarget(new TargetAnyTarget()); this.getSpellAbility().addTarget(new TargetAnyTarget());
} }

View file

@ -3,7 +3,7 @@ package mage.cards.b;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.condition.Condition; import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalOneShotEffect; import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.DestroyAllEffect; import mage.abilities.effects.common.DestroyAllEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -14,6 +14,7 @@ import mage.filter.common.FilterNonlandPermanent;
import mage.filter.predicate.Predicates; import mage.filter.predicate.Predicates;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.token.InklingToken; import mage.game.permanent.token.InklingToken;
import mage.util.CardUtil;
import java.util.UUID; import java.util.UUID;
@ -33,7 +34,7 @@ public final class BlotOutTheSky extends CardImpl {
// Create X tapped 2/1 white and black Inkling creature tokens with flying. If X is 6 or more, destroy all noncreature, nonland permanents. // Create X tapped 2/1 white and black Inkling creature tokens with flying. If X is 6 or more, destroy all noncreature, nonland permanents.
this.getSpellAbility().addEffect(new CreateTokenEffect( this.getSpellAbility().addEffect(new CreateTokenEffect(
new InklingToken(), ManacostVariableValue.REGULAR, true, false new InklingToken(), GetXValue.instance, true, false
)); ));
this.getSpellAbility().addEffect(new ConditionalOneShotEffect( this.getSpellAbility().addEffect(new ConditionalOneShotEffect(
new DestroyAllEffect(filter), BlotOutTheSkyCondition.instance, new DestroyAllEffect(filter), BlotOutTheSkyCondition.instance,
@ -56,6 +57,6 @@ enum BlotOutTheSkyCondition implements Condition {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
return source.getManaCostsToPay().getX() >= 6; return CardUtil.getSourceCostsTag(game, source, "X", 0) >= 6;
} }
} }

View file

@ -9,7 +9,7 @@ import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.IntPlusDynamicValue; import mage.abilities.dynamicvalue.IntPlusDynamicValue;
import mage.abilities.dynamicvalue.common.CountersSourceCount; import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.mana.DynamicManaAbility; import mage.abilities.mana.DynamicManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -37,7 +37,7 @@ public final class BlueManaBattery extends CardImpl {
// then add an additional {U} for each charge counter removed this way. // then add an additional {U} for each charge counter removed this way.
ability = new DynamicManaAbility( ability = new DynamicManaAbility(
Mana.BlueMana(1), Mana.BlueMana(1),
new IntPlusDynamicValue(1, RemovedCountersForCostValue.instance), new IntPlusDynamicValue(1, GetXValue.instance),
new TapSourceCost(), new TapSourceCost(),
"Add {U}, then add {U} for each charge counter removed this way", "Add {U}, then add {U} for each charge counter removed this way",
true, new IntPlusDynamicValue(1, new CountersSourceCount(CounterType.CHARGE))); true, new IntPlusDynamicValue(1, new CountersSourceCount(CounterType.CHARGE)));

View file

@ -13,6 +13,7 @@ import mage.constants.Duration;
import mage.game.Game; import mage.game.Game;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import mage.target.targetadjustment.XManaValueTargetAdjuster; import mage.target.targetadjustment.XManaValueTargetAdjuster;
import mage.util.CardUtil;
import java.util.UUID; import java.util.UUID;
@ -50,6 +51,6 @@ enum BlueSunsTwilightCondition implements Condition {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
return source.getManaCostsToPay().getX() >= 5; return CardUtil.getSourceCostsTag(game, source, "X", 0) >= 5;
} }
} }

View file

@ -3,7 +3,7 @@
package mage.cards.b; package mage.cards.b;
import java.util.UUID; import java.util.UUID;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.DrawCardTargetEffect; import mage.abilities.effects.common.DrawCardTargetEffect;
import mage.abilities.effects.common.ShuffleSpellEffect; import mage.abilities.effects.common.ShuffleSpellEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -21,7 +21,7 @@ public final class BlueSunsZenith extends CardImpl {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{X}{U}{U}{U}"); super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{X}{U}{U}{U}");
// Target player draws X cards. Shuffle Blue Sun's Zenith into its owner's library. // Target player draws X cards. Shuffle Blue Sun's Zenith into its owner's library.
this.getSpellAbility().addEffect(new DrawCardTargetEffect(ManacostVariableValue.REGULAR)); this.getSpellAbility().addEffect(new DrawCardTargetEffect(GetXValue.instance));
this.getSpellAbility().addEffect(ShuffleSpellEffect.getInstance()); this.getSpellAbility().addEffect(ShuffleSpellEffect.getInstance());
this.getSpellAbility().addTarget(new TargetPlayer()); this.getSpellAbility().addTarget(new TargetPlayer());
} }

View file

@ -4,7 +4,7 @@ package mage.cards.b;
import java.util.UUID; import java.util.UUID;
import mage.abilities.costs.common.PayLifeCost; import mage.abilities.costs.common.PayLifeCost;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.LoseLifeOpponentsEffect; import mage.abilities.effects.common.LoseLifeOpponentsEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -18,7 +18,7 @@ public final class BondOfAgony extends CardImpl {
public BondOfAgony(UUID ownerId, CardSetInfo setInfo) { public BondOfAgony(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{X}{B}"); super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{X}{B}");
DynamicValue xValue = ManacostVariableValue.REGULAR; DynamicValue xValue = GetXValue.instance;
// As an additional cost to cast Bond of Agony, pay X life. // As an additional cost to cast Bond of Agony, pay X life.
// magenoxx: here we don't use PayVariableLifeCost as {X} shouldn't actually be announced // magenoxx: here we don't use PayVariableLifeCost as {X} shouldn't actually be announced

View file

@ -12,6 +12,7 @@ import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetPlayerOrPlaneswalker; import mage.target.common.TargetPlayerOrPlaneswalker;
import mage.util.CardUtil;
import java.util.UUID; import java.util.UUID;
@ -55,7 +56,7 @@ class BonfireOfTheDamnedEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
int damage = source.getManaCostsToPay().getX(); int damage = CardUtil.getSourceCostsTag(game, source, "X", 0);
if (damage < 1) { if (damage < 1) {
return false; return false;
} }

View file

@ -2,7 +2,7 @@
package mage.cards.b; package mage.cards.b;
import java.util.UUID; import java.util.UUID;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.DamageEverythingEffect; import mage.abilities.effects.common.DamageEverythingEffect;
import mage.abilities.keyword.HorsemanshipAbility; import mage.abilities.keyword.HorsemanshipAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -27,7 +27,7 @@ public final class BorrowingTheEastWind extends CardImpl {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{X}{G}{G}"); super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{X}{G}{G}");
// Borrowing the East Wind deals X damage to each creature with horsemanship and each player. // Borrowing the East Wind deals X damage to each creature with horsemanship and each player.
this.getSpellAbility().addEffect(new DamageEverythingEffect(ManacostVariableValue.REGULAR, filter)); } this.getSpellAbility().addEffect(new DamageEverythingEffect(GetXValue.instance, filter)); }
private BorrowingTheEastWind(final BorrowingTheEastWind card) { private BorrowingTheEastWind(final BorrowingTheEastWind card) {
super(card); super(card);

View file

@ -12,7 +12,7 @@ import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.decorator.ConditionalOneShotEffect; import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.dynamicvalue.common.CountersSourceCount; import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
@ -44,7 +44,7 @@ public final class BottomlessVault extends CardImpl {
// {tap}, Remove any number of storage counters from Bottomless Vault: Add {B} for each storage counter removed this way. // {tap}, Remove any number of storage counters from Bottomless Vault: Add {B} for each storage counter removed this way.
Ability ability = new DynamicManaAbility( Ability ability = new DynamicManaAbility(
Mana.BlackMana(1), Mana.BlackMana(1),
RemovedCountersForCostValue.instance, GetXValue.instance,
new TapSourceCost(), new TapSourceCost(),
"Add {B} for each storage counter removed this way", "Add {B} for each storage counter removed this way",
true, new CountersSourceCount(CounterType.STORAGE)); true, new CountersSourceCount(CounterType.STORAGE));

View file

@ -5,7 +5,7 @@ import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.RemoveVariableCountersSourceCost; import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -112,7 +112,7 @@ class BrainInAJarScryEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
int x = RemovedCountersForCostValue.instance.calculate(game, source, this); int x = GetXValue.instance.calculate(game, source, this);
if (x > 0) { if (x > 0) {
return controller.scry(x, source, game); return controller.scry(x, source, game);
} }

View file

@ -2,7 +2,7 @@
package mage.cards.b; package mage.cards.b;
import java.util.UUID; import java.util.UUID;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.DrawCardTargetEffect; import mage.abilities.effects.common.DrawCardTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -21,7 +21,7 @@ public final class Braingeyser extends CardImpl {
// Target player draws X cards. // Target player draws X cards.
this.getSpellAbility().addEffect(new DrawCardTargetEffect(ManacostVariableValue.REGULAR)); this.getSpellAbility().addEffect(new DrawCardTargetEffect(GetXValue.instance));
this.getSpellAbility().addTarget(new TargetPlayer()); this.getSpellAbility().addTarget(new TargetPlayer());
} }

View file

@ -12,6 +12,7 @@ import mage.filter.StaticFilters;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetCardInHand; import mage.target.common.TargetCardInHand;
import mage.util.CardUtil;
import java.util.UUID; import java.util.UUID;
@ -62,7 +63,7 @@ class BreakthroughEffect extends OneShotEffect {
if (player == null) { if (player == null) {
return false; return false;
} }
int amountToKeep = source.getManaCostsToPay().getX(); int amountToKeep = CardUtil.getSourceCostsTag(game, source, "X", 0);
if (amountToKeep == 0) { if (amountToKeep == 0) {
player.discard(player.getHand(), false, source, game); player.discard(player.getHand(), false, source, game);
} else if (amountToKeep < player.getHand().size()) { } else if (amountToKeep < player.getHand().size()) {

View file

@ -3,7 +3,7 @@ package mage.cards.b;
import mage.ObjectColor; import mage.ObjectColor;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -27,7 +27,7 @@ public final class Brightflame extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{R}{R}{W}{W}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{R}{R}{W}{W}");
// Radiance - Brightflame deals X damage to target creature and each other creature that shares a color with it. You gain life equal to the damage dealt this way. // Radiance - Brightflame deals X damage to target creature and each other creature that shares a color with it. You gain life equal to the damage dealt this way.
this.getSpellAbility().addEffect(new BrightflameEffect(ManacostVariableValue.REGULAR)); this.getSpellAbility().addEffect(new BrightflameEffect(GetXValue.instance));
this.getSpellAbility().addTarget(new TargetCreaturePermanent()); this.getSpellAbility().addTarget(new TargetCreaturePermanent());
this.getSpellAbility().setAbilityWord(AbilityWord.RADIANCE); this.getSpellAbility().setAbilityWord(AbilityWord.RADIANCE);
} }

View file

@ -1,7 +1,7 @@
package mage.cards.b; package mage.cards.b;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ClashEffect; import mage.abilities.effects.common.ClashEffect;
import mage.abilities.effects.common.CounterUnlessPaysEffect; import mage.abilities.effects.common.CounterUnlessPaysEffect;
@ -25,7 +25,7 @@ public final class BrokenAmbitions extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{U}"); super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{U}");
// Counter target spell unless its controller pays {X}. Clash with an opponent. If you win, that spell's controller puts the top four cards of their library into their graveyard. // Counter target spell unless its controller pays {X}. Clash with an opponent. If you win, that spell's controller puts the top four cards of their library into their graveyard.
this.getSpellAbility().addEffect(new CounterUnlessPaysEffect(ManacostVariableValue.REGULAR)); this.getSpellAbility().addEffect(new CounterUnlessPaysEffect(GetXValue.instance));
this.getSpellAbility().addEffect(new BrokenAmbitionsEffect()); this.getSpellAbility().addEffect(new BrokenAmbitionsEffect());
this.getSpellAbility().addTarget(new TargetSpell()); this.getSpellAbility().addTarget(new TargetSpell());
} }

View file

@ -5,7 +5,7 @@ import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileUntilSourceLeavesEffect; import mage.abilities.effects.common.ExileUntilSourceLeavesEffect;
import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.common.GainLifeEffect;
@ -58,7 +58,7 @@ public final class BronzebeakForagers extends CardImpl {
new ManaCostsImpl<>("{X}{W}") new ManaCostsImpl<>("{X}{W}")
); );
dissolveAbility.setTargetAdjuster(BronzebeakForagerDissolveAdjuster.instance); dissolveAbility.setTargetAdjuster(BronzebeakForagerDissolveAdjuster.instance);
dissolveAbility.addEffect(new GainLifeEffect(ManacostVariableValue.REGULAR)); dissolveAbility.addEffect(new GainLifeEffect(GetXValue.instance));
this.addAbility(dissolveAbility); this.addAbility(dissolveAbility);
} }
@ -79,7 +79,7 @@ enum BronzebeakForagerDissolveAdjuster implements TargetAdjuster {
@Override @Override
public void adjustTargets(Ability ability, Game game) { public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear(); ability.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX(); int xValue = CardUtil.getSourceCostsTag(game, ability, "X", 0);
FilterCard filter = new FilterCard("card with mana value " + xValue); FilterCard filter = new FilterCard("card with mana value " + xValue);
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, xValue)); filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, xValue));
ability.addTarget(new TargetCardInExile(filter, CardUtil.getExileZoneId(game, ability))); ability.addTarget(new TargetCardInExile(filter, CardUtil.getExileZoneId(game, ability)));

View file

@ -3,7 +3,7 @@ package mage.cards.b;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.RavenousAbility; import mage.abilities.keyword.RavenousAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -37,7 +37,7 @@ public final class Broodlord extends CardImpl {
// Brood Telepathy -- When Broodlord enters the battlefield, distribute X +1/+1 counters among any number of other target creatures you control. // Brood Telepathy -- When Broodlord enters the battlefield, distribute X +1/+1 counters among any number of other target creatures you control.
Ability ability = new EntersBattlefieldTriggeredAbility(new BroodlordEffect()); Ability ability = new EntersBattlefieldTriggeredAbility(new BroodlordEffect());
ability.addTarget(new TargetPermanentAmount(ManacostVariableValue.ETB, StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE)); ability.addTarget(new TargetPermanentAmount(GetXValue.instance, StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE));
this.addAbility(ability.withFlavorWord("Brood Telepathy")); this.addAbility(ability.withFlavorWord("Brood Telepathy"));
} }

View file

@ -17,6 +17,7 @@ import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetAnyTarget; import mage.target.common.TargetAnyTarget;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
import java.util.UUID; import java.util.UUID;
@ -69,7 +70,7 @@ class BurnFromWithinEffect extends OneShotEffect {
return false; return false;
} }
int amount = source.getManaCostsToPay().getX(); int amount = CardUtil.getSourceCostsTag(game, source, "X", 0);
// Target is a creature // Target is a creature
Permanent creature = game.getPermanent(getTargetPointer().getFirst(game, source)); Permanent creature = game.getPermanent(getTargetPointer().getFirst(game, source));

View file

@ -5,7 +5,7 @@ import mage.abilities.Ability;
import mage.abilities.common.ActivateAsSorceryActivatedAbility; import mage.abilities.common.ActivateAsSorceryActivatedAbility;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.discard.DiscardCardYouChooseTargetEffect; import mage.abilities.effects.common.discard.DiscardCardYouChooseTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -31,7 +31,7 @@ public final class CabalInterrogator extends CardImpl {
// {X}{B}, {tap}: Target player reveals X cards from their hand and you choose one of them. That player discards that card. // {X}{B}, {tap}: Target player reveals X cards from their hand and you choose one of them. That player discards that card.
// Activate only as a sorcery. // Activate only as a sorcery.
Ability ability = new ActivateAsSorceryActivatedAbility( Ability ability = new ActivateAsSorceryActivatedAbility(
new DiscardCardYouChooseTargetEffect(ManacostVariableValue.REGULAR), new DiscardCardYouChooseTargetEffect(GetXValue.instance),
new ManaCostsImpl<>("{X}{B}")); new ManaCostsImpl<>("{X}{B}"));
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
ability.addTarget(new TargetPlayer()); ability.addTarget(new TargetPlayer());

View file

@ -8,7 +8,7 @@ import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.DiscardCardCost; import mage.abilities.costs.common.DiscardCardCost;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.common.continuous.BoostTargetEffect; import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -33,7 +33,7 @@ public final class CacklingWitch extends CardImpl {
this.toughness = new MageInt(1); this.toughness = new MageInt(1);
// {X}{B}, {tap}, Discard a card: Target creature gets +X/+0 until end of turn. // {X}{B}, {tap}, Discard a card: Target creature gets +X/+0 until end of turn.
ManacostVariableValue manaX = ManacostVariableValue.REGULAR; GetXValue manaX = GetXValue.instance;
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
new BoostTargetEffect(manaX, StaticValue.get(0), Duration.EndOfTurn), new BoostTargetEffect(manaX, StaticValue.get(0), Duration.EndOfTurn),
new ManaCostsImpl<>("{X}{B}")); new ManaCostsImpl<>("{X}{B}"));

View file

@ -7,7 +7,7 @@ import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.CountersSourceCount; import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.effects.mana.AddManaInAnyCombinationEffect; import mage.abilities.effects.mana.AddManaInAnyCombinationEffect;
import mage.abilities.mana.ColorlessManaAbility; import mage.abilities.mana.ColorlessManaAbility;
@ -36,7 +36,7 @@ public final class CalciformPools extends CardImpl {
this.addAbility(ability); this.addAbility(ability);
// {1}, Remove X storage counters from Calciform Pools: Add X mana in any combination of {W} and/or {U}. // {1}, Remove X storage counters from Calciform Pools: Add X mana in any combination of {W} and/or {U}.
ability = new SimpleManaAbility(Zone.BATTLEFIELD, ability = new SimpleManaAbility(Zone.BATTLEFIELD,
new AddManaInAnyCombinationEffect(RemovedCountersForCostValue.instance, new AddManaInAnyCombinationEffect(GetXValue.instance,
new CountersSourceCount(CounterType.STORAGE), ColoredManaSymbol.W, ColoredManaSymbol.U), new CountersSourceCount(CounterType.STORAGE), ColoredManaSymbol.W, ColoredManaSymbol.U),
new GenericManaCost(1)); new GenericManaCost(1));
ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE)); ability.addCost(new RemoveVariableCountersSourceCost(CounterType.STORAGE));

View file

@ -2,7 +2,7 @@ package mage.cards.c;
import mage.MageObjectReference; import mage.MageObjectReference;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.RedirectionEffect; import mage.abilities.effects.RedirectionEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -73,7 +73,7 @@ class CaptainsManeuverEffect extends RedirectionEffect {
@Override @Override
public void init(Ability source, Game game) { public void init(Ability source, Game game) {
super.init(source, game); super.init(source, game);
amountToRedirect = ManacostVariableValue.REGULAR.calculate(game, source, this); amountToRedirect = GetXValue.instance.calculate(game, source, this);
redirectToObject = new MageObjectReference(source.getTargets().get(1).getFirstTarget(), game); redirectToObject = new MageObjectReference(source.getTargets().get(1).getFirstTarget(), game);
} }

View file

@ -3,7 +3,7 @@ package mage.cards.c;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.DamageAllEffect; import mage.abilities.effects.common.DamageAllEffect;
@ -40,7 +40,7 @@ public final class CataclysmicProspecting extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{R}{R}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{R}{R}");
// Cataclysmic Prospecting deals X damage to each creature. For each mana from a Desert spent to cast this spell, create a tapped Treasure token. // Cataclysmic Prospecting deals X damage to each creature. For each mana from a Desert spent to cast this spell, create a tapped Treasure token.
this.getSpellAbility().addEffect(new DamageAllEffect(ManacostVariableValue.REGULAR, StaticFilters.FILTER_PERMANENT_CREATURE)); this.getSpellAbility().addEffect(new DamageAllEffect(GetXValue.instance, StaticFilters.FILTER_PERMANENT_CREATURE));
this.getSpellAbility().addEffect(new CreateTokenEffect(new TreasureToken(), CataclysmicProspectingValue.instance, true, false) this.getSpellAbility().addEffect(new CreateTokenEffect(new TreasureToken(), CataclysmicProspectingValue.instance, true, false)
.setText("For each mana from a Desert spent to cast this spell, create a tapped Treasure token.")); .setText("For each mana from a Desert spent to cast this spell, create a tapped Treasure token."));
this.getSpellAbility().addWatcher(new CataclysmicProspectingWatcher()); this.getSpellAbility().addWatcher(new CataclysmicProspectingWatcher());

View file

@ -11,7 +11,7 @@ import mage.abilities.costs.common.RemoveCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.ColorsOfManaSpentToCastCount; import mage.abilities.dynamicvalue.common.ColorsOfManaSpentToCastCount;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.ReturnSourceFromGraveyardToHandEffect; import mage.abilities.effects.common.ReturnSourceFromGraveyardToHandEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
@ -25,6 +25,7 @@ import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.target.common.TargetAnyTarget; import mage.target.common.TargetAnyTarget;
import mage.util.CardUtil;
import java.util.UUID; import java.util.UUID;
@ -45,7 +46,7 @@ public final class ChamberSentry extends CardImpl {
"with a +1/+1 counter on it for each color of mana spent to cast it")); "with a +1/+1 counter on it for each color of mana spent to cast it"));
// {X}, {T}, Remove X +1/+1 counters from Chamber Sentry: It deals X damage to any target. // {X}, {T}, Remove X +1/+1 counters from Chamber Sentry: It deals X damage to any target.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(ManacostVariableValue.REGULAR) Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(GetXValue.instance)
.setText("It deals X damage to any target"), .setText("It deals X damage to any target"),
new ManaCostsImpl<>("{X}")); new ManaCostsImpl<>("{X}"));
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
@ -128,6 +129,6 @@ class ChamberSentryRemoveVariableCountersSourceCost extends VariableCostImpl {
@Override @Override
public int announceXValue(Ability source, Game game) { public int announceXValue(Ability source, Game game) {
return source.getManaCostsToPay().getX(); return CardUtil.getSourceCostsTag(game, source, "X", 0);
} }
} }

View file

@ -3,7 +3,7 @@ package mage.cards.c;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility; import mage.abilities.LoyaltyAbility;
import mage.abilities.common.CantBeCounteredSourceAbility; import mage.abilities.common.CantBeCounteredSourceAbility;
import mage.abilities.dynamicvalue.common.GetXLoyaltyValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DamageAllEffect; import mage.abilities.effects.common.DamageAllEffect;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
@ -51,7 +51,7 @@ public final class ChandraAwakenedInferno extends CardImpl {
this.addAbility(new LoyaltyAbility(new DamageAllEffect(3, filter), -3)); this.addAbility(new LoyaltyAbility(new DamageAllEffect(3, filter), -3));
// -X: Chandra, Awakened Inferno deals X damage to target creature or planeswalker. If a permanent dealt damage this way would die this turn, exile it instead. // -X: Chandra, Awakened Inferno deals X damage to target creature or planeswalker. If a permanent dealt damage this way would die this turn, exile it instead.
Ability ability = new LoyaltyAbility(new DamageTargetEffect(GetXLoyaltyValue.instance)); Ability ability = new LoyaltyAbility(new DamageTargetEffect(GetXValue.instance));
ability.addEffect( ability.addEffect(
new ExileTargetIfDiesEffect() new ExileTargetIfDiesEffect()
.setText("If a permanent dealt damage this way would die this turn, exile it instead.") .setText("If a permanent dealt damage this way would die this turn, exile it instead.")

View file

@ -2,7 +2,7 @@ package mage.cards.c;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility; import mage.abilities.LoyaltyAbility;
import mage.abilities.dynamicvalue.common.GetXLoyaltyValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.DamageAllEffect; import mage.abilities.effects.common.DamageAllEffect;
@ -39,7 +39,7 @@ public final class ChandraFlamecaller extends CardImpl {
// -X: Chandra, Flamecaller deals X damage to each creature. // -X: Chandra, Flamecaller deals X damage to each creature.
this.addAbility(new LoyaltyAbility(new DamageAllEffect( this.addAbility(new LoyaltyAbility(new DamageAllEffect(
GetXLoyaltyValue.instance, StaticFilters.FILTER_PERMANENT_CREATURE GetXValue.instance, StaticFilters.FILTER_PERMANENT_CREATURE
))); )));
} }

View file

@ -5,7 +5,7 @@ import mage.MageObjectReference;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility; import mage.abilities.LoyaltyAbility;
import mage.abilities.common.SpellCastControllerTriggeredAbility; import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.dynamicvalue.common.GetXLoyaltyValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.AsThoughEffectImpl; import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CopyTargetStackObjectEffect; import mage.abilities.effects.common.CopyTargetStackObjectEffect;
@ -52,7 +52,7 @@ public class ChandraHopesBeacon extends CardImpl {
//X: Chandra, Hopes Beacon deals X damage to each of up to two targets. //X: Chandra, Hopes Beacon deals X damage to each of up to two targets.
LoyaltyAbility loyaltyAbility = new LoyaltyAbility(new DamageTargetEffect( LoyaltyAbility loyaltyAbility = new LoyaltyAbility(new DamageTargetEffect(
GetXLoyaltyValue.instance, true, "each of up to two targets" GetXValue.instance, true, "each of up to two targets"
)); ));
loyaltyAbility.addTarget(new TargetAnyTarget(0, 2)); loyaltyAbility.addTarget(new TargetAnyTarget(0, 2));
this.addAbility(loyaltyAbility); this.addAbility(loyaltyAbility);

View file

@ -1,7 +1,7 @@
package mage.cards.c; package mage.cards.c;
import mage.abilities.LoyaltyAbility; import mage.abilities.LoyaltyAbility;
import mage.abilities.dynamicvalue.common.GetXLoyaltyValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.DamageAllControlledTargetEffect; import mage.abilities.effects.common.DamageAllControlledTargetEffect;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -9,7 +9,6 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.SuperType; import mage.constants.SuperType;
import mage.filter.common.FilterCreaturePermanent;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import mage.target.common.TargetPlayerOrPlaneswalker; import mage.target.common.TargetPlayerOrPlaneswalker;
@ -33,7 +32,7 @@ public final class ChandraNalaar extends CardImpl {
this.addAbility(ability1); this.addAbility(ability1);
// -X: Chandra Nalaar deals X damage to target creature. // -X: Chandra Nalaar deals X damage to target creature.
LoyaltyAbility ability2 = new LoyaltyAbility(new DamageTargetEffect(GetXLoyaltyValue.instance)); LoyaltyAbility ability2 = new LoyaltyAbility(new DamageTargetEffect(GetXValue.instance));
ability2.addTarget(new TargetCreaturePermanent()); ability2.addTarget(new TargetCreaturePermanent());
this.addAbility(ability2); this.addAbility(ability2);

View file

@ -12,6 +12,7 @@ import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.util.CardUtil;
import java.util.UUID; import java.util.UUID;
@ -74,7 +75,7 @@ class ChimericCoilsEffect extends ContinuousEffectImpl {
break; break;
case PTChangingEffects_7: case PTChangingEffects_7:
if (sublayer == SubLayer.SetPT_7b) { if (sublayer == SubLayer.SetPT_7b) {
int xValue = source.getManaCostsToPay().getX(); int xValue = CardUtil.getSourceCostsTag(game, source, "X", 0);
permanent.getPower().setModifiedBaseValue(xValue); permanent.getPower().setModifiedBaseValue(xValue);
permanent.getToughness().setModifiedBaseValue(xValue); permanent.getToughness().setModifiedBaseValue(xValue);
} }

View file

@ -9,6 +9,7 @@ import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.util.CardUtil;
import java.util.UUID; import java.util.UUID;
@ -69,7 +70,7 @@ class ChimericStaffEffect extends ContinuousEffectImpl {
break; break;
case PTChangingEffects_7: case PTChangingEffects_7:
if (sublayer == SubLayer.SetPT_7b) { if (sublayer == SubLayer.SetPT_7b) {
int xValue = source.getManaCostsToPay().getX(); int xValue = CardUtil.getSourceCostsTag(game, source, "X", 0);
permanent.getPower().setModifiedBaseValue(xValue); permanent.getPower().setModifiedBaseValue(xValue);
permanent.getToughness().setModifiedBaseValue(xValue); permanent.getToughness().setModifiedBaseValue(xValue);
} }

View file

@ -8,7 +8,7 @@ import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -31,7 +31,7 @@ public final class CinderElemental extends CardImpl {
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
// {X}{R}, {tap}, Sacrifice Cinder Elemental: Cinder Elemental deals X damage to any target. // {X}{R}, {tap}, Sacrifice Cinder Elemental: Cinder Elemental deals X damage to any target.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(ManacostVariableValue.REGULAR, "it"), new ManaCostsImpl<>("{X}{R}")); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(GetXValue.instance, "it"), new ManaCostsImpl<>("{X}{R}"));
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
ability.addCost(new SacrificeSourceCost()); ability.addCost(new SacrificeSourceCost());
ability.addTarget(new TargetAnyTarget()); ability.addTarget(new TargetAnyTarget());

View file

@ -19,6 +19,7 @@ import mage.filter.predicate.mageobject.ManaValuePredicate;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetCardInLibrary;
import mage.util.CardUtil;
import java.util.UUID; import java.util.UUID;
@ -73,7 +74,7 @@ class CitanulFluteSearchEffect extends OneShotEffect {
FilterCard filter = new FilterCreatureCard("creature card with mana value X or less"); FilterCard filter = new FilterCreatureCard("creature card with mana value X or less");
//Set the mana cost one higher to 'emulate' a less than or equal to comparison. //Set the mana cost one higher to 'emulate' a less than or equal to comparison.
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, source.getManaCostsToPay().getX() + 1)); filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, CardUtil.getSourceCostsTag(game, source, "X", 0) + 1));
TargetCardInLibrary target = new TargetCardInLibrary(filter); TargetCardInLibrary target = new TargetCardInLibrary(filter);
player.searchLibrary(target, source, game); player.searchLibrary(target, source, game);

View file

@ -1,7 +1,7 @@
package mage.cards.c; package mage.cards.c;
import mage.abilities.Mode; import mage.abilities.Mode;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -35,14 +35,14 @@ public final class ClanDefiance extends CardImpl {
this.getSpellAbility().getModes().setMinModes(1); this.getSpellAbility().getModes().setMinModes(1);
this.getSpellAbility().getModes().setMaxModes(3); this.getSpellAbility().getModes().setMaxModes(3);
// Clan Defiance deals X damage to target creature with flying; // Clan Defiance deals X damage to target creature with flying;
this.getSpellAbility().addEffect(new DamageTargetEffect(ManacostVariableValue.REGULAR)); this.getSpellAbility().addEffect(new DamageTargetEffect(GetXValue.instance));
this.getSpellAbility().addTarget(new TargetCreaturePermanent(filterFlying).withChooseHint("deals X damage, with flying")); this.getSpellAbility().addTarget(new TargetCreaturePermanent(filterFlying).withChooseHint("deals X damage, with flying"));
// Clan Defiance deals X damage to target creature without flying; // Clan Defiance deals X damage to target creature without flying;
Mode mode1 = new Mode(new DamageTargetEffect(ManacostVariableValue.REGULAR)); Mode mode1 = new Mode(new DamageTargetEffect(GetXValue.instance));
mode1.addTarget(new TargetCreaturePermanent(filterWithoutFlying).withChooseHint("deals X damage, without flying")); mode1.addTarget(new TargetCreaturePermanent(filterWithoutFlying).withChooseHint("deals X damage, without flying"));
this.getSpellAbility().addMode(mode1); this.getSpellAbility().addMode(mode1);
// and/or Clan Defiance deals X damage to target player. // and/or Clan Defiance deals X damage to target player.
Mode mode2 = new Mode(new DamageTargetEffect(ManacostVariableValue.REGULAR)); Mode mode2 = new Mode(new DamageTargetEffect(GetXValue.instance));
mode2.addTarget(new TargetPlayerOrPlaneswalker().withChooseHint("deals X damage")); mode2.addTarget(new TargetPlayerOrPlaneswalker().withChooseHint("deals X damage"));
this.getSpellAbility().addMode(mode2); this.getSpellAbility().addMode(mode2);

View file

@ -2,7 +2,7 @@
package mage.cards.c; package mage.cards.c;
import java.util.UUID; import java.util.UUID;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.CounterUnlessPaysEffect; import mage.abilities.effects.common.CounterUnlessPaysEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -19,7 +19,7 @@ public final class ClashOfWills extends CardImpl {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{X}{U}"); super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{X}{U}");
// Counter target spell unless its controller pays {X}. // Counter target spell unless its controller pays {X}.
this.getSpellAbility().addEffect(new CounterUnlessPaysEffect(ManacostVariableValue.REGULAR)); this.getSpellAbility().addEffect(new CounterUnlessPaysEffect(GetXValue.instance));
this.getSpellAbility().addTarget(new TargetSpell()); this.getSpellAbility().addTarget(new TargetSpell());
} }

View file

@ -21,6 +21,7 @@ import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.util.CardUtil;
import mage.watchers.common.AttackedOrBlockedThisCombatWatcher; import mage.watchers.common.AttackedOrBlockedThisCombatWatcher;
import java.util.UUID; import java.util.UUID;
@ -97,7 +98,7 @@ class ClockworkAvianEffect extends OneShotEffect {
return false; return false;
} }
int maxCounters = Integer.min( int maxCounters = Integer.min(
4 - permanent.getCounters(game).getCount(CounterType.P1P0), source.getManaCostsToPay().getX() 4 - permanent.getCounters(game).getCount(CounterType.P1P0), CardUtil.getSourceCostsTag(game, source, "X", 0)
); );
if (maxCounters < 1) { if (maxCounters < 1) {
return false; return false;

View file

@ -21,6 +21,7 @@ import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.util.CardUtil;
import mage.watchers.common.AttackedOrBlockedThisCombatWatcher; import mage.watchers.common.AttackedOrBlockedThisCombatWatcher;
import java.util.UUID; import java.util.UUID;
@ -94,7 +95,7 @@ class ClockworkBeastEffect extends OneShotEffect {
return false; return false;
} }
int maxCounters = Integer.min( int maxCounters = Integer.min(
7 - permanent.getCounters(game).getCount(CounterType.P1P0), source.getManaCostsToPay().getX() 7 - permanent.getCounters(game).getCount(CounterType.P1P0), CardUtil.getSourceCostsTag(game, source, "X", 0)
); );
if (maxCounters < 1) { if (maxCounters < 1) {
return false; return false;

View file

@ -23,6 +23,7 @@ import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.util.CardUtil;
import mage.watchers.common.AttackedOrBlockedThisCombatWatcher; import mage.watchers.common.AttackedOrBlockedThisCombatWatcher;
import java.util.UUID; import java.util.UUID;
@ -102,7 +103,7 @@ class ClockworkSteedEffect extends OneShotEffect {
return false; return false;
} }
int maxCounters = Integer.min( int maxCounters = Integer.min(
4 - permanent.getCounters(game).getCount(CounterType.P1P0), source.getManaCostsToPay().getX() 4 - permanent.getCounters(game).getCount(CounterType.P1P0), CardUtil.getSourceCostsTag(game, source, "X", 0)
); );
if (maxCounters < 1) { if (maxCounters < 1) {
return false; return false;

View file

@ -23,6 +23,7 @@ import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.util.CardUtil;
import mage.watchers.common.AttackedOrBlockedThisCombatWatcher; import mage.watchers.common.AttackedOrBlockedThisCombatWatcher;
import java.util.UUID; import java.util.UUID;
@ -106,7 +107,7 @@ class ClockworkSwarmEffect extends OneShotEffect {
return false; return false;
} }
int maxCounters = Integer.min( int maxCounters = Integer.min(
4 - permanent.getCounters(game).getCount(CounterType.P1P0), source.getManaCostsToPay().getX() 4 - permanent.getCounters(game).getCount(CounterType.P1P0), CardUtil.getSourceCostsTag(game, source, "X", 0)
); );
if (maxCounters < 1) { if (maxCounters < 1) {
return false; return false;

View file

@ -3,7 +3,7 @@ package mage.cards.c;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.CrewAbility; import mage.abilities.keyword.CrewAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -72,7 +72,7 @@ class ClownCarEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
int xValue = ManacostVariableValue.ETB.calculate(game, source, this); int xValue = GetXValue.instance.calculate(game, source, this);
if (player == null || xValue < 1) { if (player == null || xValue < 1) {
return false; return false;
} }

View file

@ -14,6 +14,7 @@ import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetAnyTarget; import mage.target.common.TargetAnyTarget;
import mage.target.targetadjustment.TargetsCountAdjuster; import mage.target.targetadjustment.TargetsCountAdjuster;
import mage.util.CardUtil;
import java.util.UUID; import java.util.UUID;
@ -58,7 +59,7 @@ class CometStormEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
int damage = source.getManaCostsToPay().getX(); int damage = CardUtil.getSourceCostsTag(game, source, "X", 0);
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
for (UUID uuid : this.getTargetPointer().getTargets(game, source)) { for (UUID uuid : this.getTargetPointer().getTargets(game, source)) {

View file

@ -10,6 +10,7 @@ import mage.constants.Outcome;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetPlayer; import mage.target.TargetPlayer;
import mage.util.CardUtil;
import mage.watchers.common.CommanderPlaysCountWatcher; import mage.watchers.common.CommanderPlaysCountWatcher;
import java.util.UUID; import java.util.UUID;
@ -94,7 +95,7 @@ class CommandersInsightEffect extends OneShotEffect {
if (player == null || watcher == null) { if (player == null || watcher == null) {
return false; return false;
} }
int toDraw = watcher.getPlayerCount(player.getId()) + source.getManaCostsToPay().getX(); int toDraw = watcher.getPlayerCount(player.getId()) + CardUtil.getSourceCostsTag(game, source, "X", 0);
return player.drawCards(toDraw, source, game) > 0; return player.drawCards(toDraw, source, game) > 0;
} }
} }

View file

@ -60,7 +60,7 @@ class CommuneWithLavaEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
Card sourceCard = game.getCard(source.getSourceId()); Card sourceCard = game.getCard(source.getSourceId());
if (controller != null && sourceCard != null) { if (controller != null && sourceCard != null) {
int amount = source.getManaCostsToPay().getX(); int amount = CardUtil.getSourceCostsTag(game, source, "X", 0);
Set<Card> cards = controller.getLibrary().getTopCards(game, amount); Set<Card> cards = controller.getLibrary().getTopCards(game, amount);
controller.moveCardsToExile(cards, source, game, true, CardUtil.getCardExileZoneId(game, source), sourceCard.getIdName()); controller.moveCardsToExile(cards, source, game, true, CardUtil.getCardExileZoneId(game, source), sourceCard.getIdName());

View file

@ -2,7 +2,7 @@
package mage.cards.c; package mage.cards.c;
import java.util.UUID; import java.util.UUID;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.CounterUnlessPaysEffect; import mage.abilities.effects.common.CounterUnlessPaysEffect;
import mage.abilities.effects.keyword.ScryEffect; import mage.abilities.effects.keyword.ScryEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -21,7 +21,7 @@ public final class Condescend extends CardImpl {
// Counter target spell unless its controller pays {X}. // Counter target spell unless its controller pays {X}.
this.getSpellAbility().addEffect(new CounterUnlessPaysEffect(ManacostVariableValue.REGULAR)); this.getSpellAbility().addEffect(new CounterUnlessPaysEffect(GetXValue.instance));
this.getSpellAbility().addTarget(new TargetSpell()); this.getSpellAbility().addTarget(new TargetSpell());
// Scry 2. // Scry 2.
this.getSpellAbility().addEffect(new ScryEffect(2)); this.getSpellAbility().addEffect(new ScryEffect(2));

View file

@ -1,21 +1,19 @@
package mage.cards.c; package mage.cards.c;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.DiscardXTargetCost; import mage.abilities.costs.common.DiscardXTargetCost;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DamageMultiEffect; import mage.abilities.effects.common.DamageMultiEffect;
import mage.abilities.keyword.FlashbackAbility; import mage.abilities.keyword.FlashbackAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.filter.StaticFilters; import mage.filter.StaticFilters;
import mage.game.Game;
import mage.target.common.TargetAnyTargetAmount; import mage.target.common.TargetAnyTargetAmount;
import java.util.UUID;
/** /**
* *
* @author LevelX2 * @author LevelX2
@ -26,9 +24,8 @@ public final class Conflagrate extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{X}{R}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{X}{R}");
// Conflagrate deals X damage divided as you choose among any number of targets. // Conflagrate deals X damage divided as you choose among any number of targets.
DynamicValue xValue = new ConflagrateVariableValue(); this.getSpellAbility().addEffect(new DamageMultiEffect(GetXValue.instance));
this.getSpellAbility().addEffect(new DamageMultiEffect(xValue)); this.getSpellAbility().addTarget(new TargetAnyTargetAmount(GetXValue.instance));
this.getSpellAbility().addTarget(new TargetAnyTargetAmount(xValue));
// Flashback-{R}{R}, Discard X cards. // Flashback-{R}{R}, Discard X cards.
Ability ability = new FlashbackAbility(this, new ManaCostsImpl<>("{R}{R}")); Ability ability = new FlashbackAbility(this, new ManaCostsImpl<>("{R}{R}"));
@ -46,32 +43,3 @@ public final class Conflagrate extends CardImpl {
return new Conflagrate(this); return new Conflagrate(this);
} }
} }
class ConflagrateVariableValue implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
int xValue = sourceAbility.getManaCostsToPay().getX();
for (Cost cost : sourceAbility.getCosts()) {
if (cost instanceof DiscardXTargetCost) {
xValue = ((DiscardXTargetCost) cost).getAmount();
}
}
return xValue;
}
@Override
public ConflagrateVariableValue copy() {
return new ConflagrateVariableValue();
}
@Override
public String toString() {
return "X";
}
@Override
public String getMessage() {
return "";
}
}

View file

@ -16,6 +16,7 @@ import mage.game.permanent.Permanent;
import mage.target.common.TargetCardInYourGraveyard; import mage.target.common.TargetCardInYourGraveyard;
import mage.target.common.TargetPlaneswalkerPermanent; import mage.target.common.TargetPlaneswalkerPermanent;
import mage.target.targetadjustment.TargetAdjuster; import mage.target.targetadjustment.TargetAdjuster;
import mage.util.CardUtil;
import java.util.UUID; import java.util.UUID;
@ -65,7 +66,7 @@ enum ConfrontThePastAdjuster implements TargetAdjuster {
public void adjustTargets(Ability ability, Game game) { public void adjustTargets(Ability ability, Game game) {
if (ability.getEffects().size() == 1 if (ability.getEffects().size() == 1
&& ability.getEffects().get(0) instanceof ReturnFromGraveyardToBattlefieldTargetEffect) { && ability.getEffects().get(0) instanceof ReturnFromGraveyardToBattlefieldTargetEffect) {
int xValue = ability.getManaCostsToPay().getX(); int xValue = CardUtil.getSourceCostsTag(game, ability, "X", 0);
ability.getTargets().clear(); ability.getTargets().clear();
FilterPermanentCard filter = new FilterPermanentCard("planeswalker card with mana value X or less"); FilterPermanentCard filter = new FilterPermanentCard("planeswalker card with mana value X or less");
filter.add(CardType.PLANESWALKER.getPredicate()); filter.add(CardType.PLANESWALKER.getPredicate());
@ -93,7 +94,7 @@ class ConfrontThePastLoyaltyEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
int xValue = source.getManaCostsToPay().getX(); int xValue = CardUtil.getSourceCostsTag(game, source, "X", 0);
Permanent target = game.getPermanent(source.getFirstTarget()); Permanent target = game.getPermanent(source.getFirstTarget());
target.removeCounters(CounterType.LOYALTY.createInstance(xValue * 2), source, game); target.removeCounters(CounterType.LOYALTY.createInstance(xValue * 2), source, game);
return true; return true;

View file

@ -4,7 +4,7 @@ package mage.cards.c;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.VariableCost; import mage.abilities.costs.VariableCost;
import mage.abilities.costs.mana.VariableManaCost; import mage.abilities.costs.mana.VariableManaCost;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.InfoEffect; import mage.abilities.effects.common.InfoEffect;
@ -38,8 +38,8 @@ public final class ConsumeSpirit extends CardImpl {
// Consume Spirit deals X damage to any target and you gain X life. // Consume Spirit deals X damage to any target and you gain X life.
this.getSpellAbility().addTarget(new TargetAnyTarget()); this.getSpellAbility().addTarget(new TargetAnyTarget());
this.getSpellAbility().addEffect(new DamageTargetEffect(ManacostVariableValue.REGULAR)); this.getSpellAbility().addEffect(new DamageTargetEffect(GetXValue.instance));
this.getSpellAbility().addEffect(new GainLifeEffect(ManacostVariableValue.REGULAR).concatBy("and")); this.getSpellAbility().addEffect(new GainLifeEffect(GetXValue.instance).concatBy("and"));
VariableCost variableCost = this.getSpellAbility().getManaCostsToPay().getVariableCosts().get(0); VariableCost variableCost = this.getSpellAbility().getManaCostsToPay().getVariableCosts().get(0);
if (variableCost instanceof VariableManaCost) { if (variableCost instanceof VariableManaCost) {
((VariableManaCost) variableCost).setFilter(filterBlack); ((VariableManaCost) variableCost).setFilter(filterBlack);

View file

@ -1,7 +1,7 @@
package mage.cards.c; package mage.cards.c;
import mage.abilities.dynamicvalue.common.HalfValue; import mage.abilities.dynamicvalue.common.HalfValue;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.counter.AddCountersPlayersEffect; import mage.abilities.effects.common.counter.AddCountersPlayersEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -21,9 +21,9 @@ public final class ContaminatedDrink extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{U}{B}"); super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{U}{B}");
// Draw X cards, then you get half X rad counters, rounded up. // Draw X cards, then you get half X rad counters, rounded up.
this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(ManacostVariableValue.REGULAR)); this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(GetXValue.instance));
this.getSpellAbility().addEffect(new AddCountersPlayersEffect( this.getSpellAbility().addEffect(new AddCountersPlayersEffect(
CounterType.RAD.createInstance(), new HalfValue(ManacostVariableValue.REGULAR, true), TargetController.YOU CounterType.RAD.createInstance(), new HalfValue(GetXValue.instance, true), TargetController.YOU
).setText(", then you get half X rad counters, rounded up")); ).setText(", then you get half X rad counters, rounded up"));
} }

View file

@ -2,7 +2,7 @@
package mage.cards.c; package mage.cards.c;
import java.util.UUID; import java.util.UUID;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.DamageAllEffect; import mage.abilities.effects.common.DamageAllEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -27,7 +27,7 @@ public final class CorrosiveGale extends CardImpl {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{X}{G/P}"); super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{X}{G/P}");
this.getSpellAbility().addEffect(new DamageAllEffect(ManacostVariableValue.REGULAR, filter)); this.getSpellAbility().addEffect(new DamageAllEffect(GetXValue.instance, filter));
} }
private CorrosiveGale(final CorrosiveGale card) { private CorrosiveGale(final CorrosiveGale card) {

View file

@ -2,7 +2,7 @@ package mage.cards.c;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.MultipliedValue; import mage.abilities.dynamicvalue.MultipliedValue;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -17,7 +17,7 @@ import java.util.UUID;
*/ */
public final class CrackleWithPower extends CardImpl { public final class CrackleWithPower extends CardImpl {
private static final DynamicValue value = new MultipliedValue(ManacostVariableValue.REGULAR, 5); private static final DynamicValue value = new MultipliedValue(GetXValue.instance, 5);
public CrackleWithPower(UUID ownerId, CardSetInfo setInfo) { public CrackleWithPower(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{X}{X}{R}{R}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{X}{X}{R}{R}");

View file

@ -3,7 +3,7 @@ package mage.cards.c;
import mage.abilities.condition.common.FerociousCondition; import mage.abilities.condition.common.FerociousCondition;
import mage.abilities.decorator.ConditionalOneShotEffect; import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.dynamicvalue.IntPlusDynamicValue; import mage.abilities.dynamicvalue.IntPlusDynamicValue;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.hint.common.FerociousHint; import mage.abilities.hint.common.FerociousHint;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -24,8 +24,8 @@ public final class CratersClaws extends CardImpl {
// Crater's Claws deals X damage to any target. // Crater's Claws deals X damage to any target.
// <i>Ferocious</i> &mdash; Crater's Claws deals X plus 2 damage to that creature or player instead if you control a creature with power 4 or greater. // <i>Ferocious</i> &mdash; Crater's Claws deals X plus 2 damage to that creature or player instead if you control a creature with power 4 or greater.
this.getSpellAbility().addEffect(new ConditionalOneShotEffect( this.getSpellAbility().addEffect(new ConditionalOneShotEffect(
new DamageTargetEffect(new IntPlusDynamicValue(2, ManacostVariableValue.REGULAR)), new DamageTargetEffect(new IntPlusDynamicValue(2, GetXValue.instance)),
new DamageTargetEffect(ManacostVariableValue.REGULAR), new DamageTargetEffect(GetXValue.instance),
FerociousCondition.instance, FerociousCondition.instance,
"{this} deals X damage to any target." "{this} deals X damage to any target."
+ "<br><i>Ferocious</i> &mdash; {this} deals X plus 2 damage instead if you control a creature with power 4 or greater")); + "<br><i>Ferocious</i> &mdash; {this} deals X plus 2 damage instead if you control a creature with power 4 or greater"));

View file

@ -1,7 +1,6 @@
package mage.cards.c; package mage.cards.c;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect; import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect;
@ -15,6 +14,9 @@ import mage.filter.predicate.Predicates;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.target.common.TargetCardInOpponentsGraveyard; import mage.target.common.TargetCardInOpponentsGraveyard;
import mage.util.CardUtil;
import java.util.UUID;
public final class CrimePunishment extends SplitCard { public final class CrimePunishment extends SplitCard {
@ -69,7 +71,7 @@ class PunishmentEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
for (Permanent permanent : game.getBattlefield().getActivePermanents(source.getControllerId(), game)) { for (Permanent permanent : game.getBattlefield().getActivePermanents(source.getControllerId(), game)) {
if (permanent != null if (permanent != null
&& permanent.getManaValue() == source.getManaCostsToPay().getX() && permanent.getManaValue() == CardUtil.getSourceCostsTag(game, source, "X", 0)
&& (permanent.isArtifact(game) && (permanent.isArtifact(game)
|| permanent.isCreature(game) || permanent.isCreature(game)
|| permanent.isEnchantment(game))) { || permanent.isEnchantment(game))) {

View file

@ -9,7 +9,7 @@ import mage.abilities.costs.VariableCost;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.costs.mana.VariableManaCost; import mage.abilities.costs.mana.VariableManaCost;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
@ -43,7 +43,7 @@ public final class CrimsonHellkite extends CardImpl {
// Flying // Flying
this.addAbility(FlyingAbility.getInstance()); this.addAbility(FlyingAbility.getInstance());
// {X}, {tap}: Crimson Hellkite deals X damage to target creature. Spend only red mana on X. // {X}, {tap}: Crimson Hellkite deals X damage to target creature. Spend only red mana on X.
Effect effect = new DamageTargetEffect(ManacostVariableValue.REGULAR); Effect effect = new DamageTargetEffect(GetXValue.instance);
effect.setText("{this} deals X damage to target creature. Spend only red mana on X"); effect.setText("{this} deals X damage to target creature. Spend only red mana on X");
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl<>("{X}")); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl<>("{X}"));
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());

View file

@ -11,7 +11,7 @@ import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.common.CountersSourceCount; import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.mana.ColorlessManaAbility; import mage.abilities.mana.ColorlessManaAbility;
import mage.abilities.mana.ConditionalAnyColorManaAbility; import mage.abilities.mana.ConditionalAnyColorManaAbility;
@ -44,7 +44,7 @@ public final class CrucibleOfTheSpiritDragon extends CardImpl {
// {T}, Remove X storage counters from Crucible of the Spirit Dragon: Add X mana in any combination of colors. Spend this mana only to cast Dragon spells or activate abilities of Dragons. // {T}, Remove X storage counters from Crucible of the Spirit Dragon: Add X mana in any combination of colors. Spend this mana only to cast Dragon spells or activate abilities of Dragons.
ability = new ConditionalAnyColorManaAbility( ability = new ConditionalAnyColorManaAbility(
new TapSourceCost(), new TapSourceCost(),
RemovedCountersForCostValue.instance, GetXValue.instance,
new CountersSourceCount(CounterType.STORAGE), new CountersSourceCount(CounterType.STORAGE),
new CrucibleOfTheSpiritDragonManaBuilder(), new CrucibleOfTheSpiritDragonManaBuilder(),
false false

View file

@ -8,7 +8,7 @@ import mage.abilities.costs.common.RemoveVariableCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ColoredManaCost; import mage.abilities.costs.mana.ColoredManaCost;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.RemovedCountersForCostValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -45,7 +45,7 @@ public final class CruelSadist extends CardImpl {
// {2}{B}, {T}, Remove X +1/+1 counters from Cruel Sadist: Cruel Sadist deals X damage to target creature. // {2}{B}, {T}, Remove X +1/+1 counters from Cruel Sadist: Cruel Sadist deals X damage to target creature.
ability = new SimpleActivatedAbility( ability = new SimpleActivatedAbility(
new DamageTargetEffect(RemovedCountersForCostValue.instance, "it"), new ManaCostsImpl<>("{2}{B}") new DamageTargetEffect(GetXValue.instance, "it"), new ManaCostsImpl<>("{2}{B}")
); );
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
ability.addCost(new RemoveVariableCountersSourceCost(CounterType.P1P1)); ability.addCost(new RemoveVariableCountersSourceCost(CounterType.P1P1));

View file

@ -8,7 +8,7 @@ import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.VariableCost; import mage.abilities.costs.VariableCost;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.costs.mana.VariableManaCost; import mage.abilities.costs.mana.VariableManaCost;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DamageEverythingEffect; import mage.abilities.effects.common.DamageEverythingEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -38,7 +38,7 @@ public final class CryptRats extends CardImpl {
this.toughness = new MageInt(1); this.toughness = new MageInt(1);
// {X}: Crypt Rats deals X damage to each creature and each player. Spend only black mana on X. // {X}: Crypt Rats deals X damage to each creature and each player. Spend only black mana on X.
Effect effect = new DamageEverythingEffect(ManacostVariableValue.REGULAR); Effect effect = new DamageEverythingEffect(GetXValue.instance);
effect.setText("{this} deals X damage to each creature and each player. Spend only black mana on X"); effect.setText("{this} deals X damage to each creature and each player. Spend only black mana on X");
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect,new ManaCostsImpl<>("{X}")); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect,new ManaCostsImpl<>("{X}"));
VariableCost variableCost = ability.getManaCostsToPay().getVariableCosts().get(0); VariableCost variableCost = ability.getManaCostsToPay().getVariableCosts().get(0);

View file

@ -18,6 +18,7 @@ import mage.filter.predicate.mageobject.ColorPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.token.TreasureToken; import mage.game.permanent.token.TreasureToken;
import mage.players.Player; import mage.players.Player;
import mage.util.CardUtil;
import java.util.UUID; import java.util.UUID;
@ -75,7 +76,7 @@ class CulminationOfStudiesEffect extends OneShotEffect {
if (player == null) { if (player == null) {
return false; return false;
} }
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, source.getManaCostsToPay().getX())); Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, CardUtil.getSourceCostsTag(game, source, "X", 0)));
player.moveCards(cards, Zone.EXILED, source, game); player.moveCards(cards, Zone.EXILED, source, game);
cards.removeIf(uuid -> game.getState().getZone(uuid) != Zone.EXILED); cards.removeIf(uuid -> game.getState().getZone(uuid) != Zone.EXILED);
int landCards = cards.count(StaticFilters.FILTER_CARD_LAND, game); int landCards = cards.count(StaticFilters.FILTER_CARD_LAND, game);

View file

@ -1,6 +1,6 @@
package mage.cards.c; package mage.cards.c;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect; import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.abilities.keyword.CasualtyAbility; import mage.abilities.keyword.CasualtyAbility;
@ -22,8 +22,8 @@ public final class CutOfTheProfits extends CardImpl {
this.addAbility(new CasualtyAbility(3)); this.addAbility(new CasualtyAbility(3));
// You draw X cards and you lose X life. // You draw X cards and you lose X life.
this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(ManacostVariableValue.REGULAR, "you")); this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(GetXValue.instance, "you"));
this.getSpellAbility().addEffect(new LoseLifeSourceControllerEffect(ManacostVariableValue.REGULAR).concatBy("and")); this.getSpellAbility().addEffect(new LoseLifeSourceControllerEffect(GetXValue.instance).concatBy("and"));
} }
private CutOfTheProfits(final CutOfTheProfits card) { private CutOfTheProfits(final CutOfTheProfits card) {

View file

@ -1,7 +1,7 @@
package mage.cards.c; package mage.cards.c;
import java.util.UUID; import java.util.UUID;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.LoseLifeOpponentsEffect; import mage.abilities.effects.common.LoseLifeOpponentsEffect;
import mage.abilities.keyword.AftermathAbility; import mage.abilities.keyword.AftermathAbility;
@ -28,7 +28,7 @@ public final class CutRibbons extends SplitCard {
// Ribbons // Ribbons
// Each opponent loses X life. // Each opponent loses X life.
getRightHalfCard().addAbility(new AftermathAbility().setRuleAtTheTop(true)); getRightHalfCard().addAbility(new AftermathAbility().setRuleAtTheTop(true));
getRightHalfCard().getSpellAbility().addEffect(new LoseLifeOpponentsEffect(ManacostVariableValue.REGULAR)); getRightHalfCard().getSpellAbility().addEffect(new LoseLifeOpponentsEffect(GetXValue.instance));
} }

View file

@ -1,7 +1,6 @@
package mage.cards.d; package mage.cards.d;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -11,6 +10,9 @@ import mage.constants.Outcome;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetPlayer; import mage.target.TargetPlayer;
import mage.util.CardUtil;
import java.util.UUID;
/** /**
* *
@ -52,8 +54,8 @@ class DamnablePactEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source)); Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (targetPlayer != null) { if (targetPlayer != null) {
targetPlayer.drawCards(source.getManaCostsToPay().getX(), source, game); targetPlayer.drawCards(CardUtil.getSourceCostsTag(game, source, "X", 0), source, game);
targetPlayer.loseLife(source.getManaCostsToPay().getX(), game, source, false); targetPlayer.loseLife(CardUtil.getSourceCostsTag(game, source, "X", 0), game, source, false);
return true; return true;
} }
return false; return false;

View file

@ -19,6 +19,7 @@ import mage.target.Target;
import mage.target.common.TargetCardInYourGraveyard; import mage.target.common.TargetCardInYourGraveyard;
import mage.target.targetadjustment.TargetAdjuster; import mage.target.targetadjustment.TargetAdjuster;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
import java.util.Collection; import java.util.Collection;
import java.util.Objects; import java.util.Objects;
@ -53,7 +54,7 @@ enum DanceOfTheManseAdjuster implements TargetAdjuster {
@Override @Override
public void adjustTargets(Ability ability, Game game) { public void adjustTargets(Ability ability, Game game) {
int xValue = ability.getManaCostsToPay().getX(); int xValue = CardUtil.getSourceCostsTag(game, ability, "X", 0);
FilterCard filter = new FilterCard("artifact and/or non-Aura enchantment cards " + FilterCard filter = new FilterCard("artifact and/or non-Aura enchantment cards " +
"each with mana value " + xValue + " or less from your graveyard"); "each with mana value " + xValue + " or less from your graveyard");
filter.add(Predicates.or( filter.add(Predicates.or(
@ -102,7 +103,7 @@ class DanceOfTheManseEffect extends OneShotEffect {
.filter(Objects::nonNull) .filter(Objects::nonNull)
.collect(Collectors.toSet())); .collect(Collectors.toSet()));
player.moveCards(cards, Zone.BATTLEFIELD, source, game); player.moveCards(cards, Zone.BATTLEFIELD, source, game);
if (source.getManaCostsToPay().getX() < 6) { if (CardUtil.getSourceCostsTag(game, source, "X", 0) < 6) {
return true; return true;
} }
cards.stream() cards.stream()

View file

@ -3,7 +3,7 @@ package mage.cards.d;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateTokenTargetEffect; import mage.abilities.effects.common.CreateTokenTargetEffect;
import mage.abilities.effects.common.continuous.BoostTargetEffect; import mage.abilities.effects.common.continuous.BoostTargetEffect;
@ -31,7 +31,7 @@ public final class DarkSalvation extends CardImpl {
// Target player creates X 2/2 black Zombie creature tokens, then up to one target creature gets -1/-1 until end of turn for each Zombie that player controls. // Target player creates X 2/2 black Zombie creature tokens, then up to one target creature gets -1/-1 until end of turn for each Zombie that player controls.
this.getSpellAbility().addTarget(new TargetPlayer()); this.getSpellAbility().addTarget(new TargetPlayer());
this.getSpellAbility().addEffect(new CreateTokenTargetEffect(new ZombieToken(), ManacostVariableValue.REGULAR)); this.getSpellAbility().addEffect(new CreateTokenTargetEffect(new ZombieToken(), GetXValue.instance));
this.getSpellAbility().addTarget(new TargetCreaturePermanent(0, 1)); this.getSpellAbility().addTarget(new TargetCreaturePermanent(0, 1));
Effect effect = new BoostTargetEffect( Effect effect = new BoostTargetEffect(

Some files were not shown because too many files have changed in this diff Show more