When copying costs, make sure to recache the TapCost state.

This commit is contained in:
Chris H
2018-03-24 00:03:57 -04:00
parent 7d39889cef
commit 8e15326b0f

View File

@@ -51,12 +51,23 @@ public class Cost implements Serializable {
private final List<CostPart> costParts = Lists.newArrayList();
private boolean isMandatory = false;
// Primarily used for Summoning Sickness awareness
private boolean tapCost = false;
public final boolean hasTapCost() {
return this.tapCost;
}
private void cacheTapCost() {
tapCost = false;
for (CostPart p : getCostParts()) {
if (p instanceof CostTap || p instanceof CostUntap) {
tapCost = true;
return;
}
}
}
public final boolean hasNoManaCost() {
return this.getCostMana() == null;
}
@@ -508,6 +519,7 @@ public class Cost implements Serializable {
for (CostPart cp : this.costParts) {
toRet.costParts.add(cp.copy());
}
toRet.cacheTapCost();
return toRet;
}
@@ -518,12 +530,14 @@ public class Cost implements Serializable {
if (!(cp instanceof CostPartMana))
toRet.costParts.add(cp.copy());
}
toRet.cacheTapCost();
return toRet;
}
public final Cost copyWithDefinedMana(String manaCost) {
Cost toRet = copyWithNoMana();
toRet.costParts.add(new CostPartMana(new ManaCost(new ManaCostParser(manaCost)), null));
toRet.cacheTapCost();
return toRet;
}