mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
Remove superfluous addManaCost method (#11288)
* no need to specify mana cost, just add cost * handle all mana costs through addcost method only * eliminate another constructor * more constructor cleanup
This commit is contained in:
parent
4e2a5bd5a9
commit
d7afa37893
53 changed files with 153 additions and 338 deletions
|
|
@ -155,14 +155,6 @@ public interface Ability extends Controllable, Serializable {
|
|||
*/
|
||||
ManaCosts<ManaCost> getManaCostsToPay();
|
||||
|
||||
/**
|
||||
* Adds a {@link ManaCost} to this ability that must be paid before this
|
||||
* ability is activated.
|
||||
*
|
||||
* @param cost The {@link ManaCost} to add.
|
||||
*/
|
||||
void addManaCost(ManaCost cost);
|
||||
|
||||
void addManaCostsToPay(ManaCost manaCost);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public abstract class AbilityImpl implements Ability {
|
|||
protected UUID sourceId;
|
||||
private final ManaCosts<ManaCost> manaCosts;
|
||||
private final ManaCosts<ManaCost> manaCostsToPay;
|
||||
private Costs<Cost> costs;
|
||||
private final Costs<Cost> costs;
|
||||
protected Modes modes; // access to it by GetModes only (it can be overridden by some abilities)
|
||||
protected Zone zone;
|
||||
protected String name;
|
||||
|
|
@ -855,7 +855,6 @@ public abstract class AbilityImpl implements Ability {
|
|||
if (cost == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cost instanceof Costs) {
|
||||
// as list of costs
|
||||
Costs<Cost> list = (Costs<Cost>) cost;
|
||||
|
|
@ -865,11 +864,9 @@ public abstract class AbilityImpl implements Ability {
|
|||
} else {
|
||||
// as single cost
|
||||
if (cost instanceof ManaCost) {
|
||||
addManaCost((ManaCost) cost);
|
||||
manaCosts.add((ManaCost) cost);
|
||||
manaCostsToPay.add((ManaCost) cost);
|
||||
} else {
|
||||
if (costs == null) {
|
||||
costs = new CostsImpl<>();
|
||||
}
|
||||
costs.add(cost);
|
||||
}
|
||||
}
|
||||
|
|
@ -887,15 +884,6 @@ public abstract class AbilityImpl implements Ability {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addManaCost(ManaCost manaCost) {
|
||||
if (manaCost == null) {
|
||||
return;
|
||||
}
|
||||
manaCosts.add(manaCost);
|
||||
manaCostsToPay.add(manaCost);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEffect(Effect effect) {
|
||||
if (effect != null) {
|
||||
|
|
@ -1141,10 +1129,10 @@ public abstract class AbilityImpl implements Ability {
|
|||
if (object == null) { // e.g. sacrificed token
|
||||
logger.warn("Could get no object: " + this);
|
||||
}
|
||||
return new StringBuilder(" activates: ")
|
||||
.append(object != null ? this.formatRule(getModes().getText(), object.getLogName()) : getModes().getText())
|
||||
.append(" from ")
|
||||
.append(getMessageText(game)).toString();
|
||||
return " activates: " +
|
||||
(object != null ? this.formatRule(getModes().getText(), object.getLogName()) : getModes().getText()) +
|
||||
" from " +
|
||||
getMessageText(game);
|
||||
}
|
||||
|
||||
protected String getMessageText(Game game) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import mage.ApprovingObject;
|
|||
import mage.MageObject;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.mana.ManaOptions;
|
||||
import mage.cards.Card;
|
||||
|
|
@ -57,17 +56,6 @@ public abstract class ActivatedAbilityImpl extends AbilityImpl implements Activa
|
|||
condition = ability.condition;
|
||||
}
|
||||
|
||||
protected ActivatedAbilityImpl(Zone zone, Effect effect) {
|
||||
super(AbilityType.ACTIVATED, zone);
|
||||
this.addEffect(effect);
|
||||
}
|
||||
|
||||
protected ActivatedAbilityImpl(Zone zone, Effect effect, ManaCosts cost) {
|
||||
super(AbilityType.ACTIVATED, zone);
|
||||
this.addEffect(effect);
|
||||
this.addManaCost(cost);
|
||||
}
|
||||
|
||||
protected ActivatedAbilityImpl(Zone zone, Effect effect, Cost cost) {
|
||||
super(AbilityType.ACTIVATED, zone);
|
||||
this.addEffect(effect);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public class SpellAbility extends ActivatedAbilityImpl {
|
|||
this.cardName = cardName;
|
||||
this.spellAbilityType = spellAbilityType;
|
||||
this.spellAbilityCastMode = spellAbilityCastMode;
|
||||
this.addManaCost(cost);
|
||||
this.addCost(cost);
|
||||
this.setIdentifier(MageIdentifier.Default);
|
||||
setSpellName();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
package mage.abilities.abilityword;
|
||||
|
||||
import mage.abilities.ActivatedAbilityImpl;
|
||||
|
|
@ -18,11 +16,8 @@ import mage.target.common.TargetCardInHand;
|
|||
|
||||
public class GrandeurAbility extends ActivatedAbilityImpl {
|
||||
|
||||
protected final String cardName;
|
||||
|
||||
public GrandeurAbility(Effect effect, String cardName) {
|
||||
super(Zone.BATTLEFIELD, effect);
|
||||
this.cardName = cardName;
|
||||
super(Zone.BATTLEFIELD, effect, null);
|
||||
|
||||
FilterCard filter = new FilterCard("another card named " + cardName);
|
||||
filter.add(new NamePredicate(cardName));
|
||||
|
|
@ -33,7 +28,6 @@ public class GrandeurAbility extends ActivatedAbilityImpl {
|
|||
|
||||
protected GrandeurAbility(final GrandeurAbility ability) {
|
||||
super(ability);
|
||||
this.cardName = ability.cardName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -23,8 +23,7 @@ public class FetchLandActivatedAbility extends ActivatedAbilityImpl {
|
|||
}
|
||||
|
||||
public FetchLandActivatedAbility(boolean withDamage, SubType subType1, SubType subType2) {
|
||||
super(Zone.BATTLEFIELD, null);
|
||||
addCost(new TapSourceCost());
|
||||
super(Zone.BATTLEFIELD, null, new TapSourceCost());
|
||||
if (withDamage) {
|
||||
addCost(new PayLifeCost(1));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import java.util.UUID;
|
|||
public class PassAbility extends ActivatedAbilityImpl {
|
||||
|
||||
public PassAbility() {
|
||||
super(Zone.ALL, new PassEffect());
|
||||
super(Zone.ALL, new PassEffect(), null);
|
||||
this.usesStack = false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package mage.abilities.common;
|
|||
import mage.constants.Zone;
|
||||
import mage.abilities.ActivatedAbilityImpl;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.abilities.effects.Effect;
|
||||
|
||||
/**
|
||||
|
|
@ -12,16 +11,8 @@ import mage.abilities.effects.Effect;
|
|||
*/
|
||||
public class SimpleActivatedAbility extends ActivatedAbilityImpl {
|
||||
|
||||
public SimpleActivatedAbility(Effect effect, ManaCosts cost) {
|
||||
super(Zone.BATTLEFIELD, effect, cost);
|
||||
}
|
||||
|
||||
public SimpleActivatedAbility(Effect effect, Cost cost) {
|
||||
super(Zone.BATTLEFIELD, effect, cost);
|
||||
}
|
||||
|
||||
public SimpleActivatedAbility(Zone zone, Effect effect, ManaCosts cost) {
|
||||
super(zone, effect, cost);
|
||||
this(Zone.BATTLEFIELD, effect, cost);
|
||||
}
|
||||
|
||||
public SimpleActivatedAbility(Zone zone, Effect effect, Cost cost) {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class SpellTransformedAbility extends SpellAbility {
|
|||
this.manaCost = manaCost;
|
||||
this.clearManaCosts();
|
||||
this.clearManaCostsToPay();
|
||||
this.addManaCost(new ManaCostsImpl<>(manaCost));
|
||||
this.addCost(new ManaCostsImpl<>(manaCost));
|
||||
this.addSubAbility(new TransformAbility());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
|
||||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpecialAction;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.Costs;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.AbilityType;
|
||||
|
|
@ -28,14 +26,7 @@ public class TurnFaceUpAbility extends SpecialAction {
|
|||
public TurnFaceUpAbility(Costs<Cost> costs, boolean megamorph) {
|
||||
super(Zone.BATTLEFIELD);
|
||||
this.addEffect(new TurnFaceUpEffect(megamorph));
|
||||
for (Cost cost : costs) {
|
||||
if (cost instanceof ManaCost) {
|
||||
this.addManaCost((ManaCost) cost);
|
||||
} else {
|
||||
this.addCost(cost);
|
||||
}
|
||||
}
|
||||
|
||||
this.addCost(costs);
|
||||
this.usesStack = false;
|
||||
this.abilityType = AbilityType.SPECIAL_ACTION;
|
||||
this.setRuleVisible(false); // will be made visible only to controller in CardView
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package mage.abilities.decorator;
|
|||
import mage.abilities.ActivatedAbilityImpl;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.Effects;
|
||||
import mage.constants.EffectType;
|
||||
|
|
@ -29,15 +28,8 @@ public class ConditionalActivatedAbility extends ActivatedAbilityImpl {
|
|||
this.condition = condition;
|
||||
}
|
||||
|
||||
public ConditionalActivatedAbility(Zone zone, Effect effect, ManaCosts cost, Condition condition, String rule) {
|
||||
super(zone, effect, cost);
|
||||
this.condition = condition;
|
||||
this.ruleText = rule;
|
||||
}
|
||||
|
||||
public ConditionalActivatedAbility(Zone zone, Effect effect, Cost cost, Condition condition, String rule) {
|
||||
super(zone, effect, cost);
|
||||
this.condition = condition;
|
||||
this(zone, effect, cost, condition);
|
||||
this.ruleText = rule;
|
||||
}
|
||||
|
||||
|
|
@ -70,10 +62,7 @@ public class ConditionalActivatedAbility extends ActivatedAbilityImpl {
|
|||
sb.append("as a sorcery and only ");
|
||||
}
|
||||
String conditionText = condition.toString();
|
||||
if (conditionText.startsWith("during")
|
||||
|| conditionText.startsWith("before")
|
||||
|| conditionText.startsWith("if")) {
|
||||
} else {
|
||||
if (!conditionText.startsWith("during") && !conditionText.startsWith("before") && !conditionText.startsWith("if")) {
|
||||
sb.append("if ");
|
||||
}
|
||||
sb.append(conditionText);
|
||||
|
|
|
|||
|
|
@ -31,10 +31,10 @@ public class AwakenAbility extends SpellAbility {
|
|||
|
||||
private static final Logger logger = Logger.getLogger(AwakenAbility.class);
|
||||
|
||||
private static String filterMessage = "a land you control to awake";
|
||||
private static final String filterMessage = "a land you control to awake";
|
||||
|
||||
private String rule;
|
||||
private int awakenValue;
|
||||
private final String rule;
|
||||
private final int awakenValue;
|
||||
|
||||
public AwakenAbility(Card card, int awakenValue, String awakenCosts) {
|
||||
super(card.getSpellAbility());
|
||||
|
|
@ -45,7 +45,7 @@ public class AwakenAbility extends SpellAbility {
|
|||
|
||||
this.clearManaCosts();
|
||||
this.clearManaCostsToPay();
|
||||
this.addManaCost(new ManaCostsImpl<>(awakenCosts));
|
||||
this.addCost(new ManaCostsImpl<>(awakenCosts));
|
||||
|
||||
this.addTarget(new TargetControlledPermanent(new FilterControlledLandPermanent(filterMessage)));
|
||||
this.addEffect(new AwakenEffect());
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class EmergeAbility extends SpellAbility {
|
|||
|
||||
this.clearManaCosts();
|
||||
this.clearManaCostsToPay();
|
||||
this.addManaCost(emergeCost.copy());
|
||||
this.addCost(emergeCost.copy());
|
||||
|
||||
this.setRuleAtTheTop(true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class EscapeAbility extends SpellAbility {
|
|||
this.clearManaCostsToPay();
|
||||
|
||||
String text = "Escape—" + manaCost;
|
||||
this.addManaCost(new ManaCostsImpl<>(manaCost));
|
||||
this.addCost(new ManaCostsImpl<>(manaCost));
|
||||
for (Cost cost : additionalCosts) {
|
||||
text += ", " + CardUtil.getTextWithFirstCharUpperCase(cost.getText());
|
||||
this.addCost(cost.copy().setText("")); // hide additional cost text from rules
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class SpectacleAbility extends SpellAbility {
|
|||
|
||||
this.clearManaCosts();
|
||||
this.clearManaCostsToPay();
|
||||
this.addManaCost(spectacleCosts.copy());
|
||||
this.addCost(spectacleCosts.copy());
|
||||
|
||||
this.setRuleAtTheTop(true);
|
||||
this.rule = "Spectacle " + spectacleCosts.getText()
|
||||
|
|
@ -58,7 +58,7 @@ public class SpectacleAbility extends SpellAbility {
|
|||
@SuppressWarnings("unchecked")
|
||||
public boolean activate(Game game, boolean noMana) {
|
||||
if (super.activate(game, noMana)) {
|
||||
List<Integer> spectacleActivations = (ArrayList) game.getState().getValue(SPECTACLE_ACTIVATION_VALUE_KEY + getSourceId());
|
||||
List<Integer> spectacleActivations = (List<Integer>) game.getState().getValue(SPECTACLE_ACTIVATION_VALUE_KEY + getSourceId());
|
||||
if (spectacleActivations == null) {
|
||||
spectacleActivations = new ArrayList<>(); // zoneChangeCounter
|
||||
game.getState().setValue(SPECTACLE_ACTIVATION_VALUE_KEY + getSourceId(), spectacleActivations);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class SurgeAbility extends SpellAbility {
|
|||
|
||||
public static final String SURGE_ACTIVATION_VALUE_KEY = "surgeActivation";
|
||||
|
||||
private String rule;
|
||||
private final String rule;
|
||||
|
||||
public SurgeAbility(Card card, String surgeCosts) {
|
||||
super(card.getSpellAbility());
|
||||
|
|
@ -32,7 +32,7 @@ public class SurgeAbility extends SpellAbility {
|
|||
|
||||
this.clearManaCosts();
|
||||
this.clearManaCostsToPay();
|
||||
this.addManaCost(new ManaCostsImpl<>(surgeCosts));
|
||||
this.addCost(new ManaCostsImpl<>(surgeCosts));
|
||||
|
||||
this.setRuleAtTheTop(true);
|
||||
this.rule = "Surge " + surgeCosts
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ public class SuspendAbility extends SpecialAction {
|
|||
if (suspend == Integer.MAX_VALUE) {
|
||||
VariableManaCost xCosts = new VariableManaCost(VariableCostType.ALTERNATIVE);
|
||||
xCosts.setMinX(1);
|
||||
this.addManaCost(xCosts);
|
||||
this.addCost(xCosts);
|
||||
cost = new ManaCostsImpl<>("{X}" + cost.getText());
|
||||
}
|
||||
StringBuilder sb = new StringBuilder("Suspend ");
|
||||
|
|
|
|||
|
|
@ -393,11 +393,6 @@ public class StackAbility extends StackObjectImpl implements Ability {
|
|||
return ability.getManaCostsToPay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addManaCost(ManaCost manaCost) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addManaCostsToPay(ManaCost manaCost) {
|
||||
// Do nothing
|
||||
|
|
|
|||
|
|
@ -1113,9 +1113,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
.computeIfAbsent(sourceId, k -> new HashMap<>())
|
||||
.put(identifier, costs != null ? costs.copy() : null);
|
||||
|
||||
if (identifier == null) {
|
||||
boolean a = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1236,7 +1233,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
} else {
|
||||
spellAbility.clearManaCosts();
|
||||
spellAbility.clearManaCostsToPay();
|
||||
spellAbility.addManaCost(alternateCosts.copy());
|
||||
spellAbility.addCost(alternateCosts.copy());
|
||||
}
|
||||
spellAbility.clearCosts();
|
||||
spellAbility.addCost(costs);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue