summaryrefslogtreecommitdiffstats
path: root/src/Weapon.java
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2018-11-19 09:12:42 +0100
committerNao Pross <naopross@thearcway.org>2018-11-19 09:12:42 +0100
commit9dca8d0f3610e2cd1079f9705f1da31ff19aba93 (patch)
treef3e421cf2e8e676bbeec2fb111cd5930b4cb3031 /src/Weapon.java
parentUpdate makefile (diff)
downloadSubconscious-java-9dca8d0f3610e2cd1079f9705f1da31ff19aba93.tar.gz
Subconscious-java-9dca8d0f3610e2cd1079f9705f1da31ff19aba93.zip
Add Actor.SkillSet, remove useless members in various strucutres
Diffstat (limited to 'src/Weapon.java')
-rw-r--r--src/Weapon.java34
1 files changed, 12 insertions, 22 deletions
diff --git a/src/Weapon.java b/src/Weapon.java
index de6eb26..f20e0ca 100644
--- a/src/Weapon.java
+++ b/src/Weapon.java
@@ -1,54 +1,44 @@
// TODO: there are object such as "puch" that need infinite durability
public class Weapon {
- private boolean broken;
// TODO: if possible make final
private int damage;
private int durability;
private int range;
private String name;
+
// TODO: add bonus / power-ups structure
+ // public class PowerUps {}
public Weapon(String name, int damage, int range, int durability) {
this.name = name;
this.damage = damage;
this.range = range;
this.durability = durability;
-
- this.broken = false;
}
- public String getName() {
- return this.name;
- }
+ /* accessors */
+ public String getName() { return this.name; }
+ public int getDamage() { return this.damage; }
+ public int getRange() { return this.range; }
+ public int getDurability() { return this.durability; }
- public int getDamage() {
- return this.damage;
+
+ public boolean isBroken() {
+ return this.durability <= 0;
}
public boolean damage(Actor attacker, Actor attacked, Map map) {
- if (this.broken) {
+ if (isBroken()) {
return false;
}
- // TODO: bugfix durability-- iff damage has been done
- this.durability--;
- if (this.durability <= 0) {
- this.broken = true;
- }
-
if (map.getTile(attacked.getX(), attacked.getY()).isSelected()) {
attacked.damage(this.damage);
+ this.durability--;
return true;
} else {
return false;
}
}
- public int getRange() {
- return this.range;
- }
-
- public int getDurability() {
- return this.durability;
- }
}