-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdventurer.java
269 lines (229 loc) · 6.61 KB
/
Adventurer.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
import java.util.*;
public abstract class Adventurer{
private String name;
private int HP,maxHP;
boolean isStunned, isBurning, isPoisoned, isPoisoned2, isWeakened, isStrengthened;
boolean yangHasBuff, rageMode, hasDGStrengthed, hasElvenDebuff, hasCheeseMark, hasSecondPhase, deathCounted;
int shieldStrength, burnDuration, poisonDuration;
ArrayList<Adventurer> enemies = new ArrayList<Adventurer>();
ArrayList<Adventurer> allies = new ArrayList<Adventurer>();
//Abstract methods are meant to be implemented in child classes.
/*
all adventurers must have a custom special
consumable resource (mana/rage/money/witts etc)
*/
//give it a short name (fewer than 13 characters)
public abstract String getSpecialName();
//accessor methods
public abstract int getSpecial();
public abstract int getSpecialMax();
public abstract void setSpecial(int n);
//concrete method written using abstract methods.
//refill special resource by amount, but only up to at most getSpecialMax()
public int restoreSpecial(int n){
if( n > getSpecialMax() - getSpecial()){
n = getSpecialMax() - getSpecial();
}
setSpecial(getSpecial()+n);
return n;
}
/*
all adventurers must have a way to attack enemies and
support their allys
*/
//hurt or hinder the target adventurer
public abstract String attack(Adventurer other);
/*This is an example of an improvement that you can make to allow
* for more flexible targetting.
*/
//heal or buff the party
//public abstract String support(ArrayList<Adventurer> others);
//heal or buff the target adventurer
public abstract String support(Adventurer other);
//heal or buff self
public abstract String support();
//hurt or hinder the target adventurer, consume some special resource
public abstract String specialAttack(Adventurer other);
/*
standard methods
*/
public String attack(ArrayList<Adventurer> enemies) {
return this + " does not have an AoE attack.";
}
public String specialAttack(ArrayList<Adventurer> enemies) {
return this + " does not have an AoE special attack.";
}
public String specialAttack(ArrayList<Adventurer> enemies, ArrayList<Adventurer> allies) {
return this + " does not have an AoE special attack which damages allies.";
}
public boolean isAoe(String move) {
return false;
}
public void setStunned(boolean stunned) {
this.isStunned = stunned;
}
public boolean isStunned() {
return isStunned;
}
public void setBurning(boolean burning) {
this.isBurning = burning;
}
public boolean isBurning() {
return isBurning;
}
public void setPoisoned(boolean poisoned) {
this.isPoisoned = poisoned;
}
public void setPoisoned2(boolean poisoned) {
this.isPoisoned2 = poisoned;
}
public boolean isPoisoned() {
return isPoisoned;
}
public boolean isPoisoned2() {
return isPoisoned2;
}
public void setWeakened(boolean weakened) {
this.isWeakened = weakened;
}
public boolean isWeakened() {
return isWeakened;
}
public void setStrengthened(boolean Strengthened) {
this.isStrengthened = Strengthened;
}
public void setHasDGStrengthed(boolean strengthend) {
this.hasDGStrengthed = strengthend;
}
public int getShieldStrength() {
return shieldStrength;
}
public boolean isDead() {
return HP <= 0;
}
public String applyDamage(int amount, Adventurer other){
String result = "";
if (this.shieldStrength > 0) {
int shielded = Math.min(amount, this.shieldStrength);
this.shieldStrength -= shielded;
amount -= shielded;
result = result + "\n" + getName() + "'s shield absorbed " + shielded + " damage.";
}
if (this.isStrengthened) {
amount = amount *2;
result = result + "\n" + getName() + " has received the Blessing of the Sun, dealing 2x the damage!";
setStrengthened(false);
}
if (other.hasElvenDebuff) {
if ((int)(Math.random() * 100) + 1 > 30) {
amount = 0;
result = result + "\n" + other.getName() + " has muddied judgement and misses, dealing no damage.";
}
hasElvenDebuff = false;
}
if (this.hasDGStrengthed) {
amount = (int)(amount * 1.5);
result = result + "\n" + getName() + " is bolstered by encouragement and alchohol, increasing their damage 1.5x!";
setHasDGStrengthed(false);
}
if (amount > 0) {
this.HP -= amount;
}
if (HP <= 0) {
HP = 0;
}
return result;
}
public void applyDamage(int amount){
if (amount > 0) {
this.HP -= amount;
}
if (HP <= 0) {
HP = 0;
}
}
public String applyStatusEffects() {
String result = "";
if (!isDead()) {
if (isBurning()) {
applyDamage(1);
burnDuration++;
result += "\n" + getName() + " takes 1 damage from burning.";
if (burnDuration + 1 == 2) {
result += "\n" + getName() + "\'s burning has lifted.";
isBurning = false;
}
}
if (isPoisoned()) {
applyDamage(1);
result += "\n" + getName() + " takes 1 damage from poison.";
if (poisonDuration + 1 == 2) {
result += "\n" + getName() + "\'s poisoning has lifted.";
isPoisoned = false;
}
poisonDuration++;
}
if (isPoisoned2()) {
applyDamage(1);
result += "\n" + getName() + " takes 1 damage from poison.";
}
}
return result;
}
public String applyStatusEffects(int dmg, Adventurer other) {
String result = "";
if (isWeakened()) {
result = result + "\n" + getName() + " is weakened, taking 2x damage.";
dmg = dmg * 2;
setWeakened(false);
}
if (yangHasBuff) {
if ((int)(Math.random() * 100) + 1 <= 30) {
dmg = 0;
}
result = result + "\nYang has dodged the attack!";
yangHasBuff = false;
}
if (rageMode) {
dmg = (int)(dmg*0.7);
}
result = result + applyDamage(dmg, other);
return result;
}
//You did it wrong if this happens.
public Adventurer(){
this("Lester-the-noArg-constructor-string");
}
public Adventurer(String name){
this(name, 10);
}
public Adventurer(String name, int hp){
this.name = name;
this.HP = hp;
this.maxHP = hp;
}
//toString method
public String toString(){
return this.getName();
}
//Get Methods
public String getName(){
return name;
}
public int getHP(){
return HP;
}
public int getmaxHP(){
return maxHP;
}
public void setmaxHP(int newMax){
maxHP = newMax;
}
//Set Methods
public void setHP(int health){
this.HP = health;
}
public void setName(String s){
this.name = s;
}
}