mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +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 List<ManaCostShard> shards;
|
||||||
private final int genericCost;
|
private final int genericCost;
|
||||||
private boolean hasNoCost = true; // lands cost
|
private final boolean hasNoCost; // lands cost
|
||||||
private String stringValue; // precalculated for toString;
|
private String stringValue; // precalculated for toString;
|
||||||
|
|
||||||
private Float compareWeight = null;
|
private Float compareWeight = null;
|
||||||
@@ -93,14 +93,14 @@ public final class ManaCost implements Comparable<ManaCost>, Iterable<ManaCostSh
|
|||||||
public ManaCost(final IParserManaCost parser) {
|
public ManaCost(final IParserManaCost parser) {
|
||||||
final List<ManaCostShard> shardsTemp = Lists.newArrayList();
|
final List<ManaCostShard> shardsTemp = Lists.newArrayList();
|
||||||
while (parser.hasNext()) {
|
while (parser.hasNext()) {
|
||||||
this.hasNoCost = false;
|
|
||||||
final ManaCostShard shard = parser.next();
|
final ManaCostShard shard = parser.next();
|
||||||
if (shard != null && shard != ManaCostShard.GENERIC) {
|
if (shard != null && shard != ManaCostShard.GENERIC) {
|
||||||
shardsTemp.add(shard);
|
shardsTemp.add(shard);
|
||||||
} // null is OK - that was generic mana
|
} // null is OK - that was generic mana
|
||||||
}
|
}
|
||||||
this.genericCost = parser.getTotalGenericCost(); // collect generic mana
|
int generic = parser.getTotalGenericCost(); // collect generic mana here
|
||||||
// here
|
this.hasNoCost = generic == -1;
|
||||||
|
this.genericCost = generic == -1 ? 0 : generic;
|
||||||
sealClass(shardsTemp);
|
sealClass(shardsTemp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package forge.card.mana;
|
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
|
@Override
|
||||||
public final boolean hasNext() {
|
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
|
@Override
|
||||||
public final ManaCostShard next() {
|
public final ManaCostShard next() {
|
||||||
final String unparsed = this.cost[this.nextToken++];
|
final String unparsed = this.cost[this.nextToken++];
|
||||||
if (StringUtils.isNumeric(unparsed)) {
|
// consider negation sign
|
||||||
this.genericCost += Integer.parseInt(unparsed);
|
Integer i = Ints.tryParse(unparsed);
|
||||||
|
if (i != null) {
|
||||||
|
this.genericCost += i;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -97,7 +97,10 @@ public class ManaCostBeingPaid {
|
|||||||
@Override
|
@Override
|
||||||
public int getTotalGenericCost() {
|
public int getTotalGenericCost() {
|
||||||
ShardCount c = unpaidShards.get(ManaCostShard.GENERIC);
|
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