-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButcher.java
74 lines (65 loc) · 2.09 KB
/
Butcher.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 Butcher extends Adventurer{
int meatScraps, meatScrapsMax;
/*the other constructors ultimately call the constructor
*with all parameters.*/
public Butcher(String name, int hp){
super(name,hp);
meatScrapsMax = 12;
meatScraps = meatScrapsMax/2;
}
public Butcher(String name){
this(name, 25);
}
public Butcher(){
this("Butcher");
}
/*The next 8 methods are all required because they are abstract:*/
public String getSpecialName(){
return "meatScraps";
}
public int getSpecial(){
return meatScraps;
}
public void setSpecial(int n){
meatScraps = n;
}
public int getSpecialMax(){
return meatScrapsMax;
}
/*Deal 4-6 damage to opponent*/
public String attack(Adventurer other){
int damage = (int)(Math.random()*3)+4;
other.applyDamage(damage);
restoreSpecial(2);
return this + " sliced "+ other + " with a butcher knife and dealt " + damage + " points of damage. Replenished 2 meat scraps.";
}
/*Deal 9-12 damage to opponent if meatScraps is high enough (8).
*Reduces meatScraps by 6. Does 3 damage to self.
*/
public String specialAttack(Adventurer other){
if(getSpecial() >= 8){
setSpecial(getSpecial()-6);
int damage = (int)(Math.random()*4)+9;
other.applyDamage(damage);
this.applyDamage(3);
return this + " attacked with their meat cleaver, dealing " + damage + " points of damage to " + other + ", but took 3 points of recoil damage.";
}else{
return "Not enough meatScraps to use the meat cleaver. Instead, "+attack(other);
}
}
/*heals team +3 hp*/
public String support(Adventurer other) {
setSpecial(getSpecial()-2);
int hp = 3;
other.setHP(other.getHP() + hp);
return this + " used 2 meat scraps and served a meat feast to " + other + ", restoring " + hp + " HP.";
}
/*restores 4 hp and 2 meat scraps*/
public String support(){
int hp = 4;
setHP(getHP() + hp);
int scraps = 2;
setSpecial(getSpecial() + 2);
return this + " dined on a steak, restoring " + hp + " HP and " + scraps + " " + getSpecialName() + ".";
}
}