-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRB.java
102 lines (91 loc) · 2.84 KB
/
RB.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
94
95
96
97
98
99
100
101
102
public class RB extends Adventurer{
int speed, maxSpeed;
String preferredLanguage;
boolean attackIncrease;
/*the other constructors ultimately call the constructor
*with all parameters.*/
public RB(String name, int hp, String language){
super(name,hp);
speed = 0;
maxSpeed = 60;
preferredLanguage = language;
attackIncrease = false;
}
public RB(String name, int hp){
this(name,hp,"c++");
}
public RB(String name){
this(name,80);
}
public RB(){
this("Cook (RB)");
}
/*The next 8 methods are all required because they are abstract:*/
public String getSpecialName(){
return "Speed";
}
public int getSpecial(){
return speed;
}
public void setSpecial(int n){
speed = n;
}
public int getSpecialMax(){
return maxSpeed;
}
/*Deal 5-10 damage to opponent, restores 10 speed*/
public String attack(Adventurer other){
int damage = (int)(Math.random()*6)+5;
other.applyDamage(damage);
restoreSpecial(10);
if (attackIncrease){
other.applyDamage(damage * 0.20);
return this + " rushed "+ other + " and dealt "+ (int)(damage * 1.2) +
" points of damage. They then get more warmed up and gain speed.";
}
else{
return this + " rushed "+ other + " and dealt "+ damage +
" points of damage. They then get more warmed up and gain speed.";
}
}
/*Deal 15 damage to opponent, only if speed is high enough.
*Reduces speed by 25.
*/
public String specialAttack(Adventurer other){
if(getSpecial() >= 25){
setSpecial(getSpecial()-25);
int damage = 15;
setHP(getHP()+15);
other.applyDamage(damage);
if (attackIncrease){
other.applyDamage(damage*0.2);
return this + "used their speed to truck through the enemy." +
" This hurt "+other+" dealing "+ (int)(damage * 1.2) +" points of damage." +"Also " +
"get a health increase of 5. However, self lost 25 speed.";
}
else{
return this + "used their speed to truck through the enemy." +
" This hurt "+other+" dealing "+ damage +" points of damage." +"Also " +
"get a health increase of 5. However, self lost 25 speed.";
}
}else{
return "Not enough speed to truck. Instead "+attack(other);
}
}
/*cannot support other*/
public String support(Adventurer other){
return "Nothing happens here. Instead "
+ support();
}
/*Gain damage increase based off of health.*/
public String support(){
if(getSpecial() >= 25){
attackIncrease = true;
setSpecial(getSpecial() - 25);
return this+" drinks gatorade to increase attack power.";
}
else{
return this + " does nothing.";
}
}
}