diff --git a/src/tamagotchi-service/src/main/java/com/sap/tamagotchi/model/Device.java b/src/tamagotchi-service/src/main/java/com/sap/tamagotchi/model/Device.java index 0d42d6a..748003a 100644 --- a/src/tamagotchi-service/src/main/java/com/sap/tamagotchi/model/Device.java +++ b/src/tamagotchi-service/src/main/java/com/sap/tamagotchi/model/Device.java @@ -22,6 +22,8 @@ public class Device { private final Color color; @JsonProperty("born") private final Instant born = Instant.now(); + @JsonProperty("healthScore") + private int healthScore = 100; private final Queue messages = new ConcurrentLinkedQueue<>(); public Device(String owner, Color color) { @@ -49,6 +51,21 @@ public class Device { return born; } + @JsonProperty("healthScore") + public int getHealthScore() { + return healthScore; + } + + @JsonProperty("isAlive") + public boolean isAlive() { + return healthScore > 1; + } + + @JsonIgnore + public void changeHealthScore(int delta) { + this.healthScore += delta; + } + @JsonIgnore public boolean hasMessages() { return !messages.isEmpty();