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:
xenohedron 2023-10-09 15:25:19 -04:00 committed by GitHub
parent 4e2a5bd5a9
commit d7afa37893
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
53 changed files with 153 additions and 338 deletions

View file

@ -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) {