aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/Weapon.java
blob: 824ad6fbff2bd4e8aaadf1d26368b813b8a43829 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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--;
        }
    }
}