Skip to content

Commit

Permalink
Allow tuv to be set to 0. (#11896)
Browse files Browse the repository at this point in the history
This change allows tuv to be set to 0 and be used for calculations. Also a check was add for the proper values.
  • Loading branch information
WCSumpton authored Aug 29, 2023
1 parent 0b98d7b commit 7281b74
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2516,7 +2516,12 @@ private Tuple<Integer, String> parseStackingLimit(final String type, final Strin
return Tuple.of(max, s[1].intern());
}

private void setTuv(final String s) {
private void setTuv(final String s) throws GameParseException {
final int value = getInt(s);
if (value < -1) {
throw new GameParseException(
"tuv must be 0 positive (or -1, default, to calculate) " + thisErrorMsg());
}
tuv = getInt(s);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private static IntegerMap<UnitType> getCostsForTuvForAllPlayersMergedAndAveraged
// Add any units that have XML TUV even if they aren't purchasable
for (final UnitType unitType : data.getUnitTypeList()) {
final UnitAttachment ua = unitType.getUnitAttachment();
if (ua.getTuv() > 0) {
if (ua.getTuv() > -1) {
costs.put(unitType, ua.getTuv());
}
}
Expand All @@ -131,7 +131,7 @@ private static IntegerMap<UnitType> getCostsForTuvForAllPlayersMergedAndAveraged
private static int getTotalTuv(
final UnitType unitType, final IntegerMap<UnitType> costs, final Set<UnitType> alreadyAdded) {
final UnitAttachment ua = unitType.getUnitAttachment();
if (ua.getTuv() > 0) {
if (ua.getTuv() > -1) {
return ua.getTuv();
}
int tuv = costs.getInt(unitType);
Expand Down

0 comments on commit 7281b74

Please sign in to comment.