-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpiceEnthusiast.java
93 lines (81 loc) · 2.96 KB
/
SpiceEnthusiast.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import java.util.*;
public class SpiceEnthusiast extends Adventurer {
int sprays, spraysMax;
/*the other constructors ultimately call the constructor
*with all parameters.*/
public SpiceEnthusiast(String name, int hp){
super(name,hp);
spraysMax = 20;
sprays = spraysMax/2;
}
public SpiceEnthusiast(String name){
this(name,21);
}
public SpiceEnthusiast(){
this("Seifer");
}
/*The next 8 methods are all required because they are abstract:*/
public String getSpecialName(){
return "sprays";
}
public int getSpecial(){
return sprays;
}
public void setSpecial(int n){
sprays = n;
}
public int getSpecialMax(){
return spraysMax;
}
/*Deal 3-5 damage to opponent, restores 2 sprays*/
public String attack(Adventurer other){
int damage = (int) (Math.random() * 3) + 3;
other.applyDamage(damage);
restoreSpecial(2);
return this + " throws spices at " + other + " and dealt " + damage
+ " points of damage. " + other + " tears up. ";
}
/*Deal 5-13 damage to opponent, reduces sprays by 6.
*Only used as abstract method.*/
public String specialAttack(Adventurer other){
if (getSpecial() >= 6) {
setSpecial(getSpecial() - 6);
int damage = (int) ((Math.random() * 6) + (Math.random() * 6)) + 5;
other.applyDamage(damage);
return this + " used their gigantic pepper spray on " + other + ". Spiciness attacks "
+ other + ", dealing " + damage + " points of damage. ";
} else {
return "Not enough sprays to use the gigantic pepper spray. Instead " + attack(other);
}
}
/*Deal 5-7 damage to each opponent, only if sprays is high enough.
*Reduces sprays by 6.*/
public String specialAttack(ArrayList<Adventurer> others){
String text = "";
if (getSpecial() >= 6) {
setSpecial(getSpecial() - 6);
for (Adventurer other : others) {
int damage = (int) (Math.random() * 3) + 5;
other.applyDamage(damage);
text += this + " used their gigantic pepper spray on " + other + ". Spiciness attacks "
+ other + ", dealing " + damage + " points of damage. ";
}
return text;
} else {
int randomEnemy = (int) (Math.random() * others.size());
return "Not enough sprays to use the gigantic pepper spray. Instead " + attack(others.get(randomEnemy));
}
}
/*Restores 4 special and 1 hp to self.*/
public String support(){
int hp = 1;
setHP(getHP() + hp);
return this + " drinks a bowl of hot flaming soup to reinvigorate " + restoreSpecial(4) + " "
+ getSpecialName() + " and " + hp + " HP. ";
}
/*Restores 6 special to other*/
public String support(Adventurer other){
return this + " gives a pack of spicy sticks to " + other + " and restores "
+ other.restoreSpecial(6) + " " + other.getSpecialName() + ". ";
}
}