mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Fix logic for Henzie (#6402)
This commit is contained in:
@@ -42,7 +42,7 @@ public final class ManaCost implements Comparable<ManaCost>, Iterable<ManaCostSh
|
||||
|
||||
private List<ManaCostShard> shards;
|
||||
private final int genericCost;
|
||||
private boolean hasNoCost = true; // lands cost
|
||||
private final boolean hasNoCost; // lands cost
|
||||
private String stringValue; // precalculated for toString;
|
||||
|
||||
private Float compareWeight = null;
|
||||
@@ -93,14 +93,14 @@ public final class ManaCost implements Comparable<ManaCost>, Iterable<ManaCostSh
|
||||
public ManaCost(final IParserManaCost parser) {
|
||||
final List<ManaCostShard> shardsTemp = Lists.newArrayList();
|
||||
while (parser.hasNext()) {
|
||||
this.hasNoCost = false;
|
||||
final ManaCostShard shard = parser.next();
|
||||
if (shard != null && shard != ManaCostShard.GENERIC) {
|
||||
shardsTemp.add(shard);
|
||||
} // null is OK - that was generic mana
|
||||
}
|
||||
this.genericCost = parser.getTotalGenericCost(); // collect generic mana
|
||||
// here
|
||||
int generic = parser.getTotalGenericCost(); // collect generic mana here
|
||||
this.hasNoCost = generic == -1;
|
||||
this.genericCost = generic == -1 ? 0 : generic;
|
||||
sealClass(shardsTemp);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package forge.card.mana;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import com.google.common.primitives.Ints;
|
||||
|
||||
|
||||
/**
|
||||
@@ -54,7 +54,7 @@ public class ManaCostParser implements IParserManaCost {
|
||||
*/
|
||||
@Override
|
||||
public final boolean hasNext() {
|
||||
return this.nextToken < this.cost.length && !this.cost[this.nextToken].equals("-1");
|
||||
return this.nextToken < this.cost.length;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -65,8 +65,10 @@ public class ManaCostParser implements IParserManaCost {
|
||||
@Override
|
||||
public final ManaCostShard next() {
|
||||
final String unparsed = this.cost[this.nextToken++];
|
||||
if (StringUtils.isNumeric(unparsed)) {
|
||||
this.genericCost += Integer.parseInt(unparsed);
|
||||
// consider negation sign
|
||||
Integer i = Ints.tryParse(unparsed);
|
||||
if (i != null) {
|
||||
this.genericCost += i;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,10 @@ public class ManaCostBeingPaid {
|
||||
@Override
|
||||
public int getTotalGenericCost() {
|
||||
ShardCount c = unpaidShards.get(ManaCostShard.GENERIC);
|
||||
return c == null ? 0 : c.totalCount;
|
||||
if (c == null) {
|
||||
return unpaidShards.isEmpty() ? -1 : 0;
|
||||
}
|
||||
return c.totalCount;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user