diff options
author | Nao Pross <naopross@thearcway.org> | 2018-11-20 14:10:09 +0100 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2018-11-20 14:10:09 +0100 |
commit | 502c5ba36398f17b96297ac07fb66291e59b57ff (patch) | |
tree | a47f99a927f405b58c3db7e1365cb394a3099d31 /src | |
parent | Move util.Palette to graphics.Palette, fix canvas resize (diff) | |
download | Subconscious-java-502c5ba36398f17b96297ac07fb66291e59b57ff.tar.gz Subconscious-java-502c5ba36398f17b96297ac07fb66291e59b57ff.zip |
Implement unbreakable weapons
Diffstat (limited to 'src')
-rw-r--r-- | src/subconscious/Weapon.java | 18 |
1 files 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; } |