mirror of
https://github.com/magefree/mage.git
synced 2025-12-28 14:32:06 -08:00
refactor: removed direct counter names usage in some places
This commit is contained in:
parent
70fa98f492
commit
8f4cc84266
51 changed files with 72 additions and 67 deletions
|
|
@ -57,7 +57,7 @@ public class PayVariableLoyaltyCost extends VariableCostImpl {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int maxValue = permanent.getCounters(game).getCount(CounterType.LOYALTY.getName());
|
||||
int maxValue = permanent.getCounters(game).getCount(CounterType.LOYALTY);
|
||||
|
||||
// apply cost modification
|
||||
if (source instanceof LoyaltyAbility) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import mage.abilities.costs.Cost;
|
|||
import mage.abilities.costs.VariableCostImpl;
|
||||
import mage.abilities.costs.VariableCostType;
|
||||
import mage.counters.Counter;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
|
|
@ -14,26 +15,26 @@ import mage.game.permanent.Permanent;
|
|||
public class RemoveVariableCountersSourceCost extends VariableCostImpl {
|
||||
|
||||
protected int minimalCountersToPay = 0;
|
||||
private final String counterName;
|
||||
private final CounterType counterType;
|
||||
|
||||
public RemoveVariableCountersSourceCost(Counter counter) {
|
||||
this(counter, 0);
|
||||
public RemoveVariableCountersSourceCost(CounterType counterType) {
|
||||
this(counterType, 0);
|
||||
}
|
||||
|
||||
public RemoveVariableCountersSourceCost(Counter counter, String text) {
|
||||
this(counter, 0, text);
|
||||
public RemoveVariableCountersSourceCost(CounterType counterType, String text) {
|
||||
this(counterType, 0, text);
|
||||
}
|
||||
|
||||
public RemoveVariableCountersSourceCost(Counter counter, int minimalCountersToPay) {
|
||||
this(counter, minimalCountersToPay, "");
|
||||
public RemoveVariableCountersSourceCost(CounterType counterType, int minimalCountersToPay) {
|
||||
this(counterType, minimalCountersToPay, "");
|
||||
}
|
||||
|
||||
public RemoveVariableCountersSourceCost(Counter counter, int minimalCountersToPay, String text) {
|
||||
super(VariableCostType.NORMAL, counter.getName() + " counters to remove");
|
||||
public RemoveVariableCountersSourceCost(CounterType counterType, int minimalCountersToPay, String text) {
|
||||
super(VariableCostType.NORMAL, counterType.getName() + " counters to remove");
|
||||
this.minimalCountersToPay = minimalCountersToPay;
|
||||
this.counterName = counter.getName();
|
||||
this.counterType = counterType;
|
||||
if (text == null || text.isEmpty()) {
|
||||
this.text = "Remove X " + counterName + " counters from {this}";
|
||||
this.text = "Remove X " + counterType.getName() + " counters from {this}";
|
||||
} else {
|
||||
this.text = text;
|
||||
}
|
||||
|
|
@ -42,7 +43,7 @@ public class RemoveVariableCountersSourceCost extends VariableCostImpl {
|
|||
public RemoveVariableCountersSourceCost(final RemoveVariableCountersSourceCost cost) {
|
||||
super(cost);
|
||||
this.minimalCountersToPay = cost.minimalCountersToPay;
|
||||
this.counterName = cost.counterName;
|
||||
this.counterType = cost.counterType;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -52,7 +53,7 @@ public class RemoveVariableCountersSourceCost extends VariableCostImpl {
|
|||
|
||||
@Override
|
||||
public Cost getFixedCostsFromAnnouncedValue(int xValue) {
|
||||
return new RemoveCountersSourceCost(new Counter(counterName, xValue));
|
||||
return new RemoveCountersSourceCost(new Counter(this.counterType.getName(), xValue));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -63,6 +64,6 @@ public class RemoveVariableCountersSourceCost extends VariableCostImpl {
|
|||
@Override
|
||||
public int getMaxValue(Ability source, Game game) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
return permanent != null ? permanent.getCounters(game).getCount(counterName) : 0;
|
||||
return permanent != null ? permanent.getCounters(game).getCount(this.counterType) : 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue