Followup cleanup to manaCosts access in AbilityImpl (#11060)

(a relic of the rejected proposal to lazily instantiate manaCosts was left in #9625 and is removed here, allowing the fields to be made final)
This commit is contained in:
xenohedron 2023-08-28 22:42:34 -04:00 committed by GitHub
parent a7b06483ab
commit 8c0f2b9bf8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -56,8 +56,8 @@ public abstract class AbilityImpl implements Ability {
protected AbilityType abilityType;
protected UUID controllerId;
protected UUID sourceId;
private ManaCosts<ManaCost> manaCosts;
private ManaCosts<ManaCost> manaCostsToPay;
private final ManaCosts<ManaCost> manaCosts;
private final ManaCosts<ManaCost> manaCostsToPay;
private Costs<Cost> costs;
protected Modes modes; // access to it by GetModes only (it can be overridden by some abilities)
protected Zone zone;
@ -83,7 +83,7 @@ public abstract class AbilityImpl implements Ability {
protected String appendToRule = null;
protected int sourcePermanentTransformCount = 0;
public AbilityImpl(AbilityType abilityType, Zone zone) {
protected AbilityImpl(AbilityType abilityType, Zone zone) {
this.id = UUID.randomUUID();
this.originalId = id;
this.abilityType = abilityType;
@ -879,9 +879,6 @@ public abstract class AbilityImpl implements Ability {
if (manaCost == null) {
return;
}
if (manaCostsToPay == null) {
manaCostsToPay = new ManaCostsImpl<>();
}
if (manaCost instanceof ManaCosts) {
manaCostsToPay.addAll((ManaCosts) manaCost);
} else {
@ -894,14 +891,6 @@ public abstract class AbilityImpl implements Ability {
if (manaCost == null) {
return;
}
if (manaCosts == null) {
manaCosts = new ManaCostsImpl<>();
}
if (manaCostsToPay == null) {
manaCostsToPay = new ManaCostsImpl<>();
}
manaCosts.add(manaCost);
manaCostsToPay.add(manaCost);
}