From 502c5ba36398f17b96297ac07fb66291e59b57ff Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Tue, 20 Nov 2018 14:10:09 +0100 Subject: Implement unbreakable weapons --- src/subconscious/Weapon.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/subconscious/Weapon.java b/src/subconscious/Weapon.java index 8533b9f..3295cb8 100644 --- a/src/subconscious/Weapon.java +++ b/src/subconscious/Weapon.java @@ -1,20 +1,24 @@ package subconscious; -// TODO: there are object such as "puch" that need infinite durability public class Weapon { - // TODO: if possible make final - private int damage; - private int durability; - private int range; + + private final boolean unbreakable; + private final int damage; + private final int range; + private String name; + private int durability; // TODO: add bonus / power-ups structure // public class PowerUps {} + // TODO: As a temporary workaround negative durability on the constructor + // makes the weapon unbreakable public Weapon(String name, int damage, int range, int durability) { this.name = name; this.damage = damage; this.range = range; + this.unbreakable = (durability < 0); this.durability = durability; } @@ -24,8 +28,10 @@ public class Weapon { public int getRange() { return this.range; } public int getDurability() { return this.durability; } - public boolean isBroken() { + if (this.unbreakable) + return false; + return this.durability <= 0; } -- cgit v1.2.1