summaryrefslogtreecommitdiffstats
path: root/src/Weapon.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/Weapon.java')
-rw-r--r--src/Weapon.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/Weapon.java b/src/Weapon.java
new file mode 100644
index 0000000..36c2ab7
--- /dev/null
+++ b/src/Weapon.java
@@ -0,0 +1,50 @@
+public class Weapon {
+ private boolean broken;
+ private int damage;
+ private int durability;
+ private int range;
+ private String name;
+
+ 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;
+ }
+
+ public int getDamage() {
+ return this.damage;
+ }
+
+ public boolean damage(Actor attacker, Actor attacked, Map map) {
+ if (this.broken) {
+ return false;
+ }
+
+ this.durability--;
+ if (this.durability <= 0) {
+ this.broken = true;
+ }
+
+ if (map.getTile(attacked.getX(), attacked.getY()).isSelected()) {
+ attacked.damage(this.damage);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public int getRange() {
+ return this.range;
+ }
+
+ public int getDurability() {
+ return this.durability;
+ }
+}