-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBurglar.java
More file actions
51 lines (45 loc) · 1.33 KB
/
Burglar.java
File metadata and controls
51 lines (45 loc) · 1.33 KB
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
public class Burglar extends Player{
private int ap; // Agilitat del personatge
private static final int baseAp = 1;
Burglar(String playerName, String characterName){
super(playerName, characterName);
this.ap = 1;
}
Burglar(String playerName, String characterName, int level, int hp, int xp, int ap){
super(playerName, characterName, level, hp, xp);
this.ap = ap;
}
public int getAp(){
return ap;
}
public void setAp(int ap){
this.ap = ap;
}
public void gainXP(int value){
setXp(getXp()+value);
if(getLevel()*getXp()>getLevel()*1000){
setLevel(getLevel()+1);
setAp(getAp()+1);
setHp(getHp()+8);
}
}
public boolean disableTrap(int trapDifficulty){
if(getLevel()*getAp()>trapDifficulty){
System.out.println("Trap disabled");
return true;
}
else{
System.out.println("Trap activated");
setHp(getHp()-10);
return false;
}
}
public String toString(){
String s = new StringBuilder()
.append(super.toString())
.append("Character type: Burglar" + "\n")
.append("Agility Power: " + getAp())
.toString();
return s;
}
}