-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoss.java
74 lines (62 loc) · 1.7 KB
/
Boss.java
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
public class Boss extends Adventurer{
private int rage, rageMax;
public Boss(String name, int hp){
super(name, hp);
rageMax = 20;
rage = rageMax/2;
}
public Boss(String name){
this(name, 120);
}
public Boss(){
this("Dragon");
}
public String getSpecialName(){
return "rage";
}
//accessor methods
public int getSpecial(){
return rage;
}
public int getSpecialMax(){
return rageMax;
}
public void setSpecial(int n){
rage = n;
}
public int restoreSpecial(int n){
if(n > getSpecialMax() - getSpecial()){
n = getSpecialMax() - getSpecial();
}
setSpecial(getSpecial() - n);
return n;
}
public String attack(Adventurer other){
int damage = 20;
other.applyDamage(damage);
return this + " shoots fire from his mouth and burns " + other + " for " + damage + " HP.";
}
public String support(){
int healAmount = 10;
setHP(getHP() + healAmount);
return this + " heals itself for " + healAmount + " HP.";
}
public String specialAttack(Adventurer other) {
int maxDamage = 20;
int healthLost = Math.min(maxDamage, getHP());
other.applyDamage(healthLost);
setHP(getHP() - healthLost);
return this + " sacrifices " + healthLost + " HP to deal " + healthLost + " burn damage to " + other + ".";
}
public String support(Adventurer other){
if (rage >= 5){
int healAmount = 15;
other.setHP(other.getHP() + healAmount);
setSpecial(rage - 5);
return this + " feels bad for the adventuer and chooses to heal " + other + " for " + healAmount + " HP." + "The boss also loses 5 rage";
}
else {
return this + " the boss did not have enough rage";
}
}
}