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 |
|
25 |
1.1 |
|
29 |
1.1 |
|
37 |
1.1 |
|
45 |
1.1 |
|
49 |
1.1 2.2 |
|
50 |
1.1 |
|
54 |
1.1 2.2 3.3 |
|
58 |
1.1 2.2 |
|
60 |
1.1 |