fix: clamp stats between 0 and max value

This commit is contained in:
punchready 2021-06-03 03:05:59 +02:00
parent b80b96a3a0
commit 7cd99495ba

View File

@ -33,11 +33,11 @@ public class Stat {
} }
public void increaseValue(int value) { public void increaseValue(int value) {
this.value += value; this.value = Math.min(this.max, this.value + value);
} }
public void decreaseValue(int value) { public void decreaseValue(int value) {
this.value -= value; this.value = Math.max(0, this.value - value);
} }
public int getMax() { public int getMax() {