Player.java

1
package g0803.bindingofshiba.model.game.elements;
2
3
import g0803.bindingofshiba.math.Vec2D;
4
5
public class Player extends MoveableElement {
6
7
    private int numberOfKeys;
8
    private int hp;
9
    private final int maxHp;
10
    private int damage;
11
12
    public Player(Vec2D position, int numberOfKeys, int hp, int damage) {
13
        super(position);
14
        this.numberOfKeys = numberOfKeys;
15
        this.hp = hp;
16
        this.maxHp = hp;
17
        this.damage = damage;
18
    }
19
20
    public int getHp() {
21 1 1. getHp : replaced int return with 0 for g0803/bindingofshiba/model/game/elements/Player::getHp → KILLED
        return hp;
22
    }
23
24
    public int getMaxHp() {
25 1 1. getMaxHp : replaced int return with 0 for g0803/bindingofshiba/model/game/elements/Player::getMaxHp → NO_COVERAGE
        return maxHp;
26
    }
27
28
    public int getNumberOfKeys() {
29 1 1. getNumberOfKeys : replaced int return with 0 for g0803/bindingofshiba/model/game/elements/Player::getNumberOfKeys → KILLED
        return numberOfKeys;
30
    }
31
32
    public void setHp(int hp) {
33
        this.hp = hp;
34
    }
35
36
    public float getDamage() {
37 1 1. getDamage : replaced float return with 0.0f for g0803/bindingofshiba/model/game/elements/Player::getDamage → NO_COVERAGE
        return damage;
38
    }
39
40
    public void setDamage(int damage) {
41
        this.damage = damage;
42
    }
43
44
    public void pickKey() {
45 1 1. pickKey : Replaced integer addition with subtraction → KILLED
        this.numberOfKeys++;
46
    }
47
48
    public void dropKey() {
49 2 1. dropKey : changed conditional boundary → KILLED
2. dropKey : negated conditional → KILLED
        if (this.numberOfKeys <= 0) throw new IllegalStateException("There are no keys to remove");
50 1 1. dropKey : Replaced integer subtraction with addition → KILLED
        this.numberOfKeys--;
51
    }
52
53
    public boolean isAlive() {
54 3 1. isAlive : changed conditional boundary → KILLED
2. isAlive : negated conditional → KILLED
3. isAlive : replaced boolean return with true for g0803/bindingofshiba/model/game/elements/Player::isAlive → KILLED
        return this.hp > 0;
55
    }
56
57
    public void decreaseHpByAmount(int amount) throws IllegalArgumentException {
58 2 1. decreaseHpByAmount : changed conditional boundary → SURVIVED
2. decreaseHpByAmount : negated conditional → KILLED
        if (amount < 0) throw new IllegalArgumentException("Amount cannot be negative");
59
60 1 1. decreaseHpByAmount : Replaced integer subtraction with addition → KILLED
        this.hp = Math.max(this.hp - amount, 0);
61
    }
62
}

Mutations

21

1.1
Location : getHp
Killed by : g0803.bindingofshiba.model.game.elements.PlayerTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.model.game.elements.PlayerTest]/[method:decreaseHp()]
replaced int return with 0 for g0803/bindingofshiba/model/game/elements/Player::getHp → KILLED

25

1.1
Location : getMaxHp
Killed by : none
replaced int return with 0 for g0803/bindingofshiba/model/game/elements/Player::getMaxHp → NO_COVERAGE

29

1.1
Location : getNumberOfKeys
Killed by : g0803.bindingofshiba.model.game.elements.PlayerTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.model.game.elements.PlayerTest]/[method:pickKey()]
replaced int return with 0 for g0803/bindingofshiba/model/game/elements/Player::getNumberOfKeys → KILLED

37

1.1
Location : getDamage
Killed by : none
replaced float return with 0.0f for g0803/bindingofshiba/model/game/elements/Player::getDamage → NO_COVERAGE

45

1.1
Location : pickKey
Killed by : g0803.bindingofshiba.model.game.elements.PlayerTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.model.game.elements.PlayerTest]/[method:pickKey()]
Replaced integer addition with subtraction → KILLED

49

1.1
Location : dropKey
Killed by : g0803.bindingofshiba.model.game.elements.PlayerTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.model.game.elements.PlayerTest]/[method:dropKey()]
changed conditional boundary → KILLED

2.2
Location : dropKey
Killed by : g0803.bindingofshiba.model.game.elements.PlayerTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.model.game.elements.PlayerTest]/[method:dropKey()]
negated conditional → KILLED

50

1.1
Location : dropKey
Killed by : g0803.bindingofshiba.model.game.elements.PlayerTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.model.game.elements.PlayerTest]/[method:dropKey()]
Replaced integer subtraction with addition → KILLED

54

1.1
Location : isAlive
Killed by : g0803.bindingofshiba.model.game.elements.PlayerTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.model.game.elements.PlayerTest]/[method:decreaseHpByAmountLargerThanHealth()]
changed conditional boundary → KILLED

2.2
Location : isAlive
Killed by : g0803.bindingofshiba.model.game.elements.PlayerTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.model.game.elements.PlayerTest]/[method:decreaseHpByAmountLargerThanHealth()]
negated conditional → KILLED

3.3
Location : isAlive
Killed by : g0803.bindingofshiba.model.game.elements.PlayerTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.model.game.elements.PlayerTest]/[method:decreaseHpByAmountLargerThanHealth()]
replaced boolean return with true for g0803/bindingofshiba/model/game/elements/Player::isAlive → KILLED

58

1.1
Location : decreaseHpByAmount
Killed by : none
changed conditional boundary → SURVIVED

2.2
Location : decreaseHpByAmount
Killed by : g0803.bindingofshiba.model.game.elements.PlayerTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.model.game.elements.PlayerTest]/[method:decreaseHpByNegativeNumber()]
negated conditional → KILLED

60

1.1
Location : decreaseHpByAmount
Killed by : g0803.bindingofshiba.model.game.elements.PlayerTest.[engine:junit-jupiter]/[class:g0803.bindingofshiba.model.game.elements.PlayerTest]/[method:decreaseHpByAmountLargerThanHealth()]
Replaced integer subtraction with addition → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.0