From 7cd99495ba74bb7e172b8e107e311d880ce5f35a Mon Sep 17 00:00:00 2001 From: punchready Date: Thu, 3 Jun 2021 03:05:59 +0200 Subject: [PATCH] fix: clamp stats between 0 and max value --- .../uulm/teamname/marvelous/gamelibrary/entities/Stat.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/entities/Stat.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/entities/Stat.java index 0ca5fc5..2726dc3 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/entities/Stat.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/entities/Stat.java @@ -33,11 +33,11 @@ public class Stat { } public void increaseValue(int value) { - this.value += value; + this.value = Math.min(this.max, this.value + value); } public void decreaseValue(int value) { - this.value -= value; + this.value = Math.max(0, this.value - value); } public int getMax() {