-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHungryVampire.java
78 lines (67 loc) · 2.22 KB
/
HungryVampire.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
75
76
77
78
public class HungryVampire extends Adventurer{
int lifeblood, lifebloodMax;
/*the other constructors ultimately call the constructor
*with all parameters.*/
public HungryVampire(String name, int hp){
super(name,hp);
lifebloodMax = 15;
lifeblood = lifebloodMax/2;
}
public HungryVampire(String name){
this(name,30);
}
public HungryVampire(){
this("Morpheus");
}
public String getSpecialName(){
return "lifeblood";
}
public int getSpecial(){
return lifeblood;
}
public void setSpecial(int n){
lifeblood = n;
}
public int getSpecialMax(){
return lifebloodMax;
}
/*Deal 2-4 damage to opponent, restores 2 lifeblood*/
public String attack(Adventurer other){
int damage = (int)(Math.random()*3)+2;
other.applyDamage(damage);
restoreSpecial(2);
return this + " attacked "+ other + " and dealt "+ damage +
" points of damage. They then take a sip from their jug of lifeblood. ";
}
/*Deal 8 damage to opponent, only if lifeblood is high enough.
*Reduces lifeblood by 5; increases hp by 2 if not at max HP.
*/
public String specialAttack(Adventurer other){
String sptext = "";
if(getSpecial() >= 5){
setSpecial(getSpecial()-5);
if (getHP() + 2 <= getmaxHP()) {
setHP(getHP()+2);
} else {
sptext += "Already at maximum HP. ";
}
int damage = 8;
other.applyDamage(damage);
sptext += this + " used their vampire moves to suck blood out of "+other+", dealing "+ damage +" points of damage. ";
return sptext;
}else{
return "Not enough lifeblood to use this ultimate attack. Instead "+attack(other);
}
}
/*Restores 3 HP to other, loses 2 HP*/
public String support(Adventurer other){
other.setHP(other.getHP()+3);
setHP(getHP()-2);
return this + " gives condensed lifebloood smoothie to "+other+" and restores 3 HP to them at the cost of 2 HP. ";
}
/*Restores 6 special to self.*/
public String support(){
return this+" takes a juicy bite of a nearby wolf to restore "+restoreSpecial(6)+ " "
+ getSpecialName() + ". ";
}
}