diff options
Diffstat (limited to '')
-rw-r--r-- | src/main/java/Weapon.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/main/java/Weapon.java b/src/main/java/Weapon.java new file mode 100644 index 0000000..824ad6f --- /dev/null +++ b/src/main/java/Weapon.java @@ -0,0 +1,52 @@ +public class Weapon { + private final int RANGE; + private final int DAMAGE; + private final int WARMUP; + private final int BURSTCOUNT; + + private int coolDown; + + public Weapon(int damage, int range, int burstcount, int warmup) { + this.coolDown = 0; + this.DAMAGE = damage; + this.RANGE = range; + this.BURSTCOUNT = burstcount; + this.WARMUP = warmup; + } + + public int getDamage() { + return this.DAMAGE; + } + + public int getBurst() { + return this.BURSTCOUNT; + } + + public int getRange() { + return this.RANGE; + } + + public boolean canShoot() { + if (coolDown <= 0) { + return true; + } else { + return false; + } + } + + public boolean shoot(Actor actor, double probability) { + if (coolDown <= 0) { + actor.damage((int)((this.DAMAGE*probability)*(double)this.BURSTCOUNT)); + this.coolDown = this.WARMUP; + return true; + } else { + return false; + } + } + + public void tick() { + if (coolDown > 0) { + coolDown--; + } + } +} |