Merge branch 'rangefix' into nut_arulir_mountain

This commit is contained in:
Gonk
2019-11-14 22:34:37 +01:00
3 changed files with 14 additions and 3 deletions

View File

@@ -79,9 +79,11 @@
"category":"food",
"description":"Even fly larvae have died eating this.",
"useEffect":{
"increaseCurrentHP":{
"min":-10,
"max":-15
"min":-15,
"max":-10
},
"conditionsSource":[
{

View File

@@ -47,10 +47,18 @@ public final class ResourceParserUtils {
public static ConstRange parseConstRange(JSONObject o) throws JSONException {
if (o == null) return null;
return new ConstRange(
ConstRange ret = new ConstRange(
o.getInt(JsonFieldNames.Range.max),
o.optInt(JsonFieldNames.Range.min)
);
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
if (ret.current > ret.max) {
L.log("WARNING: Detected range where max value is lower than current value");
}
}
return ret;
}
public static final ConstRange always = one;

View File

@@ -25,6 +25,7 @@ public final class ConstRange {
}
public String toMinMaxAbsString() {
if (isMax()) return Integer.toString(Math.abs(max));
else if (current < 0) return Math.abs(max) + "-" + Math.abs(current);
else return Math.abs(current) + "-" + Math.abs(max);
}
public boolean isMax() { return max == current; }