Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize accessing X values #12059

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 1 addition & 7 deletions Mage.Common/src/main/java/mage/view/CardView.java
Original file line number Diff line number Diff line change
Expand Up @@ -745,13 +745,7 @@ private void generateCardIconsForAny(MageObject object, Ability ability, Game ga
&& showAbility != null
&& (showZone.match(Zone.BATTLEFIELD) || showZone.match(Zone.STACK))) {
int costX;
if (showCard instanceof Permanent) {
// permanent on battlefield (can show x icon multiple turns, so use end_game source)
JayDi85 marked this conversation as resolved.
Show resolved Hide resolved
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);
}
costX = ManacostVariableValue.instance.calculate(game, showAbility, null);
this.cardIcons.add(CardIconImpl.variableCost(costX));
}

Expand Down
5 changes: 3 additions & 2 deletions Mage.Sets/src/mage/cards/a/AbandonHope.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import mage.game.Game;
import mage.target.common.TargetCardInHand;
import mage.target.common.TargetOpponent;
import mage.util.CardUtil;

import java.util.UUID;

Expand All @@ -34,7 +35,7 @@ Zone.ALL, new InfoEffect("As an additional cost to cast this spell, discard X ca
this.addAbility(ability);

// 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, ManacostVariableValue.instance));
this.getSpellAbility().addTarget(new TargetOpponent());
this.getSpellAbility().setCostAdjuster(AbandonHopeAdjuster.instance);
}
Expand All @@ -54,7 +55,7 @@ enum AbandonHopeAdjuster implements CostAdjuster {

@Override
public void adjustCosts(Ability ability, Game game) {
int xValue = ability.getManaCostsToPay().getX();
int xValue = CardUtil.getSourceCostsTag(game, ability, "X", 0);
if (xValue > 0) {
ability.addCost(new DiscardTargetCost(new TargetCardInHand(xValue, xValue, StaticFilters.FILTER_CARD_CARDS)));
}
Expand Down
2 changes: 1 addition & 1 deletion Mage.Sets/src/mage/cards/a/AbuelosAwakening.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public AbuelosAwakeningEffect copy() {

@Override
public boolean apply(Game game, Ability source) {
int counterAmount = ManacostVariableValue.REGULAR.calculate(game, source, this);
int counterAmount = ManacostVariableValue.instance.calculate(game, source, this);
for (UUID targetId : getTargetPointer().getTargets(game, source)) {
AbuelosAwakeningContinuousEffect continuousEffect = new AbuelosAwakeningContinuousEffect();
continuousEffect.setTargetPointer(new FixedTarget(targetId, game));
Expand Down
6 changes: 4 additions & 2 deletions Mage.Sets/src/mage/cards/a/AetherTide.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package mage.cards.a;

import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.CostAdjuster;
Expand All @@ -17,6 +16,9 @@
import mage.target.common.TargetCardInHand;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetadjustment.XTargetsAdjuster;
import mage.util.CardUtil;

import java.util.UUID;

/**
*
Expand Down Expand Up @@ -57,7 +59,7 @@ enum AetherTideCostAdjuster implements CostAdjuster {

@Override
public void adjustCosts(Ability ability, Game game) {
int xValue = ability.getManaCostsToPay().getX();
int xValue = CardUtil.getSourceCostsTag(game, ability, "X", 0);
if (xValue > 0) {
ability.addCost(new DiscardTargetCost(new TargetCardInHand(xValue, xValue, StaticFilters.FILTER_CARD_CREATURES)));
}
Expand Down
3 changes: 2 additions & 1 deletion Mage.Sets/src/mage/cards/a/AgadeemsAwakening.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import mage.game.Game;
import mage.target.common.TargetCardInYourGraveyard;
import mage.target.targetadjustment.TargetAdjuster;
import mage.util.CardUtil;

import java.util.Set;
import java.util.UUID;
Expand Down Expand Up @@ -74,7 +75,7 @@ enum AgadeemsAwakeningAdjuster implements TargetAdjuster {
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
ability.addTarget(new AgadeemsAwakeningTarget(ability.getManaCostsToPay().getX()));
ability.addTarget(new AgadeemsAwakeningTarget(CardUtil.getSourceCostsTag(game, ability, "X", 0)));
}
}

Expand Down
4 changes: 2 additions & 2 deletions Mage.Sets/src/mage/cards/a/AlabasterPotion.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public AlabasterPotion(UUID ownerId, CardSetInfo setInfo) {
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.
this.getSpellAbility().addEffect(new GainLifeTargetEffect(ManacostVariableValue.REGULAR));
this.getSpellAbility().addEffect(new GainLifeTargetEffect(ManacostVariableValue.instance));
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, ManacostVariableValue.instance));
mode.addTarget(new TargetAnyTarget());
this.getSpellAbility().addMode(mode);
}
Expand Down
11 changes: 8 additions & 3 deletions Mage.Sets/src/mage/cards/a/AladdinsLamp.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@

package mage.cards.a;

import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.costs.mana.VariableManaCost;
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.Duration;
import mage.constants.Outcome;
Expand All @@ -18,6 +20,9 @@
import mage.game.events.GameEvent;
import mage.players.Player;
import mage.target.TargetCard;
import mage.util.CardUtil;

import java.util.UUID;

/**
*
Expand Down Expand Up @@ -73,7 +78,7 @@ public boolean replaceEvent(GameEvent event, Ability source, Game game) {
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);
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to stay at the top of library"));
if (controller.choose(outcome, cards, target, source, game)) {
Expand Down
4 changes: 2 additions & 2 deletions Mage.Sets/src/mage/cards/a/AlquistProftMasterSleuth.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ public AlquistProftMasterSleuth(UUID ownerId, CardSetInfo setInfo) {

// {X}{W}{U}{U}, {T}, Sacrifice a Clue: You draw X cards and gain X life.
Ability ability = new SimpleActivatedAbility(
new DrawCardSourceControllerEffect(ManacostVariableValue.REGULAR, "you"), new ManaCostsImpl<>("{X}{W}{U}{U}")
new DrawCardSourceControllerEffect(ManacostVariableValue.instance, "you"), new ManaCostsImpl<>("{X}{W}{U}{U}")
);
ability.addCost(new TapSourceCost());
ability.addCost(new SacrificeTargetCost(StaticFilters.FILTER_CONTROLLED_CLUE));
ability.addEffect(new GainLifeEffect(ManacostVariableValue.REGULAR).setText("and gain X life"));
ability.addEffect(new GainLifeEffect(ManacostVariableValue.instance).setText("and gain X life"));
this.addAbility(ability);
}

Expand Down
10 changes: 6 additions & 4 deletions Mage.Sets/src/mage/cards/a/AnimistsAwakening.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@

package mage.cards.a;

import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.condition.common.SpellMasteryCondition;
Expand All @@ -16,6 +13,11 @@
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;

import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;

/**
*
Expand Down Expand Up @@ -61,7 +63,7 @@ public boolean apply(Game game, Ability source) {
return false;
}
Cards cards = new CardsImpl();
int xValue = source.getManaCostsToPay().getX();
int xValue = CardUtil.getSourceCostsTag(game, source, "X", 0);
cards.addAllCards(controller.getLibrary().getTopCards(game, xValue));
if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getIdName(), cards, game);
Expand Down
2 changes: 1 addition & 1 deletion Mage.Sets/src/mage/cards/a/AnotherRound.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public boolean apply(Game game, Ability source) {
return false;
}

int xValue = ManacostVariableValue.REGULAR.calculate(game, source, this);
int xValue = ManacostVariableValue.instance.calculate(game, source, this);
TargetControlledCreaturePermanent target =
new TargetControlledCreaturePermanent(
0, Integer.MAX_VALUE,
Expand Down
6 changes: 4 additions & 2 deletions Mage.Sets/src/mage/cards/a/Anthroplasm.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

package mage.cards.a;

import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility;
Expand All @@ -19,6 +18,9 @@
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.util.CardUtil;

import java.util.UUID;

/**
*
Expand Down Expand Up @@ -75,7 +77,7 @@ public boolean apply(Game game, Ability source) {
//Remove all +1/+1 counters
permanent.removeCounters(permanent.getCounters(game).get(CounterType.P1P1.getName()), source, game);
//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 false;
Expand Down
4 changes: 2 additions & 2 deletions Mage.Sets/src/mage/cards/a/ArashiTheSkyAsunder.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public ArashiTheSkyAsunder(UUID ownerId, CardSetInfo setInfo) {
this.toughness = new MageInt(5);

// {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(ManacostVariableValue.instance), new ManaCostsImpl<>("{X}{G}"));
ability.addCost(new TapSourceCost());
ability.addTarget(new TargetPermanent(filter));
this.addAbility(ability);

// 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(ManacostVariableValue.instance, filter)));
}

private ArashiTheSkyAsunder(final ArashiTheSkyAsunder card) {
Expand Down
2 changes: 1 addition & 1 deletion Mage.Sets/src/mage/cards/a/ArborealAlliance.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public ArborealAllianceEffect copy() {
@Override
public boolean apply(Game game, Ability source) {
return new CreateTokenEffect(
new SylvanOfferingTreefolkToken(ManacostVariableValue.ETB.calculate(game, source, this))
new SylvanOfferingTreefolkToken(ManacostVariableValue.instance.calculate(game, source, this))
).apply(game, source);
}
}
3 changes: 2 additions & 1 deletion Mage.Sets/src/mage/cards/a/AscendFromAvernus.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import mage.filter.predicate.Predicates;
import mage.game.Game;
import mage.players.Player;
import mage.util.CardUtil;

import java.util.UUID;

Expand Down Expand Up @@ -73,7 +74,7 @@ public boolean apply(Game game, Ability source) {
return false;
}
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);
}
}
2 changes: 1 addition & 1 deletion Mage.Sets/src/mage/cards/a/AssaultOnOsgiliath.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public AssaultOnOsgiliath(UUID ownerId, CardSetInfo setInfo) {
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.
this.getSpellAbility().addEffect(new AmassEffect(ManacostVariableValue.REGULAR, SubType.ORC));
this.getSpellAbility().addEffect(new AmassEffect(ManacostVariableValue.instance, SubType.ORC));
this.getSpellAbility().addEffect(new GainAbilityControlledEffect(
DoubleStrikeAbility.getInstance(), Duration.EndOfTurn, filter
).setText(", then Goblins and Orcs you control gain double strike"));
Expand Down
4 changes: 2 additions & 2 deletions Mage.Sets/src/mage/cards/a/AtalyaSamiteMaster.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public AtalyaSamiteMaster(UUID ownerId, CardSetInfo setInfo) {
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.
PreventDamageToTargetEffect effect = new PreventDamageToTargetEffect(Duration.EndOfTurn, false, true, ManacostVariableValue.REGULAR);
PreventDamageToTargetEffect effect = new PreventDamageToTargetEffect(Duration.EndOfTurn, false, true, ManacostVariableValue.instance);
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.addCost(new TapSourceCost());
Expand All @@ -54,7 +54,7 @@ public AtalyaSamiteMaster(UUID ownerId, CardSetInfo setInfo) {
ability.addTarget(new TargetCreaturePermanent());

// 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(ManacostVariableValue.instance).setText("You gain X life. Spend only white mana on X."));
ability.addMode(mode);

this.addAbility(ability);
Expand Down
3 changes: 2 additions & 1 deletion Mage.Sets/src/mage/cards/a/AttemptedMurder.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import mage.game.permanent.token.StormCrowToken;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
import mage.util.CardUtil;

import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -62,7 +63,7 @@ public AttemptedMurderEffect copy() {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
int xValue = source.getManaCostsToPay().getX();
int xValue = CardUtil.getSourceCostsTag(game, source, "X", 0);
if (player == null || xValue < 1) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion Mage.Sets/src/mage/cards/a/AureliasFury.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public AureliasFury(UUID ownerId, CardSetInfo setInfo) {

// 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.
DynamicValue xValue = ManacostVariableValue.REGULAR;
DynamicValue xValue = ManacostVariableValue.instance;
this.getSpellAbility().addEffect(new DamageMultiEffect(xValue));
this.getSpellAbility().addEffect(new AureliasFuryEffect());
this.getSpellAbility().addTarget(new TargetAnyTargetAmount(xValue));
Expand Down
6 changes: 4 additions & 2 deletions Mage.Sets/src/mage/cards/a/AvacynsJudgment.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

package mage.cards.a;

import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.costs.mana.ManaCostsImpl;
Expand All @@ -14,6 +13,9 @@
import mage.constants.CardType;
import mage.game.Game;
import mage.target.common.TargetAnyTargetAmount;
import mage.util.CardUtil;

import java.util.UUID;

/**
*
Expand Down Expand Up @@ -55,7 +57,7 @@ public int calculate(Game game, Ability sourceAbility, Effect effect) {
if (manaCosts.getVariableCosts().isEmpty()) {
return 2;
}
return sourceAbility.getManaCostsToPay().getX();
return CardUtil.getSourceCostsTag(game, sourceAbility, "X", 0);
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion Mage.Sets/src/mage/cards/a/Avalanche.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import mage.game.Game;
import mage.target.TargetPermanent;
import mage.target.targetadjustment.TargetAdjuster;
import mage.util.CardUtil;

import java.util.UUID;

Expand Down Expand Up @@ -49,7 +50,7 @@ enum AvalancheAdjuster implements TargetAdjuster {
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
int xValue = ability.getManaCostsToPay().getX();
int xValue = CardUtil.getSourceCostsTag(game, ability, "X", 0);
ability.addTarget(new TargetPermanent(xValue, xValue, filter, false));
}
}
2 changes: 1 addition & 1 deletion Mage.Sets/src/mage/cards/a/AwakenTheWoods.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public AwakenTheWoods(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{G}{G}");

// 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(), ManacostVariableValue.instance));
}

private AwakenTheWoods(final AwakenTheWoods card) {
Expand Down
2 changes: 1 addition & 1 deletion Mage.Sets/src/mage/cards/a/AwakenedAwareness.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public AwakenedAwareness(UUID ownerId, CardSetInfo setInfo) {

// When Awakened Awareness enters the battlefield, put X +1/+1 counters on enchanted permanent.
this.addAbility(new EntersBattlefieldTriggeredAbility(
new AddCountersAttachedEffect(CounterType.P1P1.createInstance(), ManacostVariableValue.ETB, "enchanted permanent")
new AddCountersAttachedEffect(CounterType.P1P1.createInstance(), ManacostVariableValue.instance, "enchanted permanent")
));

// As long as enchanted permanent is a creature, it has base power and toughness 1/1.
Expand Down
2 changes: 1 addition & 1 deletion Mage.Sets/src/mage/cards/b/BalduvianRage.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public BalduvianRage(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{X}{R}");

// 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(ManacostVariableValue.instance, StaticValue.get(0), Duration.EndOfTurn));
this.getSpellAbility().addTarget(new TargetCreaturePermanent(new FilterAttackingCreature()));

// Draw a card at the beginning of the next turn's upkeep.
Expand Down
Loading
Loading