From b61378e423c5534d33755f55d5a2019a0546ac01 Mon Sep 17 00:00:00 2001 From: Leen Dereu Date: Fri, 23 Mar 2018 13:19:20 +0100 Subject: [PATCH] methodes ivm hit points --- OGP1718-Worms/src/worms/model/Worm.java | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/OGP1718-Worms/src/worms/model/Worm.java b/OGP1718-Worms/src/worms/model/Worm.java index bd1de04..a50109a 100644 --- a/OGP1718-Worms/src/worms/model/Worm.java +++ b/OGP1718-Worms/src/worms/model/Worm.java @@ -6,6 +6,8 @@ import worms.util.IllegalNameException; import static java.lang.Math.*; +import java.util.Random; + /** * A class with the specifications of the worm * @@ -122,6 +124,9 @@ public class Worm { if (validName != -1) throw new IllegalNameException(validName, name); this.name = name; + + long startHitPoints = 1000 + (new Random().nextLong() * (2000 - 1000)); + setHitPoints(startHitPoints); } //=================================================================================== @@ -754,6 +759,26 @@ public class Worm { } + //=================================================================================== + // endregion + + // region hitPoints + //=================================================================================== + + @Basic @Raw + public long gethitPoints() { + return this.hitPoints; + } + + @Raw + private void setHitPoints(long hitPoints) { + if (hitPoints <= 0) + //TODO worm sterft + weghalen van gamewereld + this.hitPoints = hitPoints; + } + + private long hitPoints; + //=================================================================================== // endregion }