-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOpenAIEmployee.java
82 lines (71 loc) · 2.4 KB
/
OpenAIEmployee.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
public class OpenAIEmployee extends Adventurer{
int paycheck, paycheckMax;
/*the other constructors ultimately call the constructor
*with all parameters.*/
public OpenAIEmployee(String name, int hp){
super(name,hp);
paycheckMax =100;
paycheck = 20;
}
/*The next 8 methods are all required because they are abstract:*/
public String getSpecialName(){
return "Paycheck";
}
public int getSpecial(){
return paycheck;
}
public void setSpecial(int n){
if (n < 0){
paycheck = 0;
}
else if (n > paycheckMax){
paycheck = paycheckMax;
}
else{
paycheck = n;
}
}
public int getSpecialMax(){
return paycheckMax;
}
// Stone Throw: deal 15-20 damage to opponent, restores 10 paycheck
public String attack(Adventurer other){
int damage = (int)(Math.random()*6) + 15;
other.applyDamage(damage);
restoreSpecial(10);
return this + " throws a stone at " + other + " and dealt " + damage +
" points of damage. While attacking, their boss pays them 10 paycheck.";
}
//- **Ultimate**: *Baseball Bat Bash (Requires 40 paycheck)*: Deals 0-50 damage
public String specialAttack(Adventurer other){
if (getSpecial() >= 40){
setSpecial(getSpecial() - 40);
int damage = (int)(Math.random() * 50);
other.applyDamage(damage);
if (damage > 20){
return this + " saves up all their paychecks to buy a baseball bat and bashes " +
other + " on the head, dealing " + damage + " damage.";
}
else{
return this + " saves up all their paychecks to buy a baseball bat and tries to bash " +
other + " on the head, but slightly misses, dealing " + damage + " damage";
}
}
else{
return "Not enough paychecks to buy a baseball bat. Instead, " + attack(other);
}
}
//**Support (Ally)**: *Tax evasion*: Restores 10-15 specialResource to ally
public String support(Adventurer other){
int amount = (int)(Math.random()*6) + 10;
other.restoreSpecial(amount);
return this + " magically fabricates paychecks and gives them to " + other +
" to evade the IRS, restoring " + amount + " paychecks to " + other;
}
//- **Support (Self)**: *So Lucky!*: Restores 10-15 paycheck
public String support(){
int amount = (int)(Math.random()*6) + 10;
restoreSpecial(amount);
return this + " picks up a few pennies, restoring " + amount + " paychecks";
}
}