-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPokemon[Conflict].java
executable file
·443 lines (379 loc) · 14.7 KB
/
Pokemon[Conflict].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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
import javax.swing.*;
/**
* @author John Wuller
* @version 2.0
*/
public class Pokemon{
//Note - Max stats is actually the default stats, not the maximum!
/** the minimum level randomly assigned to a Pokemon */
public static int minLv = 85;
/** the maximum level randomly assigned to a Pokemon */
public static int maxLv = 100;
String Name;
long Health;
long MaxHealth;
long Attack;
long Defense;
long SpAttack;
long SpDefense;
long Speed;
int SpCond;
int SpCondTurnNum;
long MaxAttack;
long MaxDefense;
long MaxSpAttack;
long MaxSpDefense;
long MaxSpeed;
double Accuracy, Evasion;
boolean Recharge;
type TypeOne;
type TypeTwo;
int Level;
attack[] AttackList = new attack[4];
int[] statLvChange = {
0,
0,
0,
0,
0,
0,
0,
0
};
//number 5 is for struggle
int[] pp = {0, 0, 0, 0, 1};
Battle_4_1 game;
Generic g = game.g;
/**
* @author John Wuller
* @version 2.0
*
* The constructor when given any values
*/
public Pokemon(Battle_4_1 game, String name, int level, long attack, long defense, long spAttack, long spDefense, long speed, long health, attack attack1,
attack attack2, attack attack3, attack attack4, type type1, type type2) {
this.game = game;
this.AttackList[0] = attack1;
this.AttackList[1] = attack2;
this.AttackList[2] = attack3;
this.AttackList[3] = attack4;
for (int i = 0; i < 4; i++) {
this.pp[i] = AttackList[i].maxPP;
AttackList[i].pp = AttackList[i].maxPP;
for (int j = 0; j < i; j++) {
if (this.AttackList[i].equals(this.AttackList[j])) {
this.AttackList[i] = Battle_4_1.noAttack;
}
}
this.Name = name;
this.Health = health;
this.MaxHealth = health;
this.MaxAttack = attack;
this.MaxDefense = defense;
this.MaxSpAttack = spAttack;
this.MaxSpDefense = spDefense;
this.MaxSpeed = speed;
this.SpCond = 0;
this.SpCondTurnNum = 0;
this.Speed = MaxSpeed;
this.Attack = MaxAttack;
this.Defense = MaxDefense;
this.SpAttack = MaxSpAttack;
this.SpDefense = MaxSpDefense;
this.Recharge = false;
this.Level = level;
this.Accuracy = 1;
this.Evasion = 1;
this.TypeOne = type1;
this.TypeTwo = type2;
if (TypeTwo.equals(TypeOne)) {
this.TypeTwo = Battle_4_1.none;
}
}
}
/**
* @author John Wuller
* @version 2.0
*
* The constructor which gets everything randomly
*/
public Pokemon(Battle_4_1 game, String name) {
this.Name = name;
this.Level = (int) g.randomNumber(minLv, maxLv);
int minStatLv = (int) Level * 2;
int maxStatLv = (int) Level * 4;
this.AttackList[0] = game.getRandomAttack();
this.AttackList[1] = game.getRandomAttack();
this.AttackList[2] = game.getRandomAttack();
this.AttackList[3] = game.getRandomAttack();
for (int i = 0; i < 4; i++) {
this.pp[i] = AttackList[i].maxPP;
AttackList[i].pp = AttackList[i].maxPP;
for (int j = 0; j < i; j++) {
if (this.AttackList[i].equals(this.AttackList[j])) {
type none = Battle_4_1.none;
this.AttackList[i] = new attack(this.game, "none", "none", none, "none", 0, 0, 0, 0);
}
}
this.Health = g.randomNumber(minStatLv, maxStatLv);
this.MaxHealth = this.Health;
this.MaxAttack = g.randomNumber(minStatLv, maxStatLv);
this.MaxDefense = g.randomNumber(minStatLv, maxStatLv);
this.MaxSpAttack = g.randomNumber(minStatLv, maxStatLv);
this.MaxSpDefense = g.randomNumber(minStatLv, maxStatLv);
this.MaxSpeed = g.randomNumber(minStatLv, maxStatLv);
this.SpCond = 0;
this.SpCondTurnNum = 0;
this.Speed = MaxSpeed;
this.Attack = MaxAttack;
this.Defense = MaxDefense;
this.SpAttack = MaxSpAttack;
this.SpDefense = MaxSpDefense;
this.Recharge = false;
this.Accuracy = 1;
this.Evasion = 1;
this.TypeOne = Battle_4_1.types[(int) g.randomNumber(0, 17)];
this.TypeTwo = Battle_4_1.types[(int) g.randomNumber(0, 18)];
for (i = 0; i < 4; i++) {
if (this.AttackList[i].effect.equals("sand")) {
if (g.randomNumber(1, 2) == 1) {
this.TypeTwo = Battle_4_1.Rock;
} else {
this.TypeTwo = Battle_4_1.Steel;
}
} else if (this.AttackList[i].effect.equals("hail")) {
this.TypeTwo = Battle_4_1.Ice;
}
}
if (TypeTwo.equals(TypeOne)) {
this.TypeTwo = Battle_4_1.none;
}
}
}
/**
* @author John Wuller
* @version 3.2
*
* @param stat the stat to be changed
* @param howMuch How many levels the stat should be changed
*
* This changes a stat of the Pokemon by a given number of levels
*/
public void statChange(String stat, int howMuch) {
switch (stat) {
case "attack":
if (howMuch == 1) {
g.p(this.Name + "'s attack rose!");
} else if (howMuch == -1) {
g.p(this.Name + "'s attack fell!");
} else if (howMuch == 2) {
g.p(this.Name + "'s attack sharply rose!");
} else if (howMuch == -2) {
g.p(this.Name + "'s attack harshly fell!");
} else if (howMuch > 2) {
g.p(this.Name + "'s attack rose drastically!");
} else {
g.p(this.Name + "'s attack severely fell!");
}
this.statLvChange[1] += howMuch;
if (this.statLvChange[1] > 6) {
g.p(this.Name + "'s attack can't go any higher!");
this.statLvChange[1] = 6;
} else if (this.statLvChange[1] < -6) {
g.p(this.Name + "'s attack can't go any lower!");
this.statLvChange[1] = -6;
}
if (this.statLvChange[1] < 0) {
this.Attack = this.MaxAttack * 2 / (Math.abs(this.statLvChange[1]) + 2);
} else {
this.Attack = this.MaxAttack * (this.statLvChange[1] + 2) / 2;
}
break;
case "defense":
if (howMuch == 1) {
g.p(this.Name + "'s defense rose!");
} else if (howMuch == -1) {
g.p(this.Name + "'s defense fell!");
} else if (howMuch == 2) {
g.p(this.Name + "'s defense sharply rose!");
} else if (howMuch == -2) {
g.p(this.Name + "'s defense harshly fell!");
} else if (howMuch > 2) {
g.p(this.Name + "'s defense rose drastically!");
} else {
g.p(this.Name + "'s defense severely fell!");
}
this.statLvChange[2] += howMuch;
if (this.statLvChange[2] > 6) {
g.p(this.Name + "'s defense can't go any higher!");
this.statLvChange[2] = 6;
} else if (this.statLvChange[2] < -6) {
g.p(this.Name + "'s defense can't go any lower!");
this.statLvChange[2] = -6;
}
if (this.statLvChange[2] < 0) {
this.Defense = this.MaxDefense * 2 / (Math.abs(this.statLvChange[2]) + 2);
} else {
this.Defense = this.MaxDefense * (this.statLvChange[2] + 2) / 2;
}
break;
case "spattack":
if (howMuch == 1) {
g.p(this.Name + "'s special attack rose!");
} else if (howMuch == -1) {
g.p(this.Name + "'s special attack fell!");
} else if (howMuch == 2) {
g.p(this.Name + "'s special attack sharply rose!");
} else if (howMuch == -2) {
g.p(this.Name + "'s special attack harshly fell!");
} else if (howMuch > 2) {
g.p(this.Name + "'s special attack rose drastically!");
} else {
g.p(this.Name + "'s special attack severely fell!");
}
this.statLvChange[3] += howMuch;
if (this.statLvChange[3] > 6) {
g.p(this.Name + "'s special attack can't go any higher!");
this.statLvChange[3] = 6;
} else if (this.statLvChange[3] < -6) {
g.p(this.Name + "'s special attack can't go any lower!");
this.statLvChange[3] = -6;
}
if (this.statLvChange[3] < 0) {
this.SpAttack = this.MaxSpAttack * 2 / (Math.abs(this.statLvChange[3]) + 2);
} else {
this.SpAttack = this.MaxSpAttack * (this.statLvChange[3] + 2) / 2;
}
break;
case "spdefense":
if (howMuch == 1) {
g.p(this.Name + "'s special defense rose!");
} else if (howMuch == -1) {
g.p(this.Name + "'s special defense fell!");
} else if (howMuch == 2) {
g.p(this.Name + "'s special defense sharply rose!");
} else if (howMuch == -2) {
g.p(this.Name + "'s special defense harshly fell!");
} else if (howMuch > 2) {
g.p(this.Name + "'s special defense rose drastically!");
} else {
g.p(this.Name + "'s special defense severely fell!");
}
this.statLvChange[4] += howMuch;
if (this.statLvChange[4] > 6) {
g.p(this.Name + "'s special defense can't go any higher!");
this.statLvChange[4] = 6;
} else if (this.statLvChange[4] < -6) {
g.p(this.Name + "'s special defense can't go any lower!");
this.statLvChange[4] = -6;
}
if (this.statLvChange[4] < 0) {
this.SpDefense = this.MaxSpDefense * 2 / (Math.abs(this.statLvChange[4]) + 2);
} else {
this.SpDefense = this.MaxSpDefense * (this.statLvChange[4] + 2) / 2;
}
break;
case "speed":
if (howMuch == 1) {
g.p(this.Name + "'s speed rose!");
} else if (howMuch == -1) {
g.p(this.Name + "'s speed fell!");
} else if (howMuch == 2) {
g.p(this.Name + "'s speed sharply rose!");
} else if (howMuch == -2) {
g.p(this.Name + "'s speed harshly fell!");
} else if (howMuch > 2) {
g.p(this.Name + "'s speed rose drastically!");
} else {
g.p(this.Name + "'s speed severely fell!");
}
this.statLvChange[5] += howMuch;
if (this.statLvChange[5] > 6) {
g.p(this.Name + "'s speed can't go any higher!");
this.statLvChange[5] = 6;
} else if (this.statLvChange[5] < -6) {
g.p(this.Name + "'s speed can't go any lower!");
this.statLvChange[5] = -6;
}
if (this.statLvChange[5] < 0) {
this.Speed = this.MaxSpeed * 2 / (Math.abs(this.statLvChange[5]) + 2);
} else {
this.Speed = this.MaxSpeed * (this.statLvChange[5] + 2) / 2;
}
break;
case "accuracy":
//g.p("Accuracy and Evasion support coming soon!");
if (howMuch == 1) {
g.p(this.Name + "'s accuracy rose!");
} else if (howMuch == -1) {
g.p(this.Name + "'s accuracy fell!");
} else if (howMuch > 0) {
g.p(this.Name + "'s accuracy sharply rose!");
} else {
g.p(this.Name + "'s accuracy harshly fell!");
}
this.statLvChange[6] += howMuch;
if (this.statLvChange[6] > 6) {
g.p(this.Name + "'s accuracy can't go any higher!");
this.statLvChange[6] = 6;
} else if (this.statLvChange[6] < -6) {
g.p(this.Name + "'s accuracy can't go any lower!");
this.statLvChange[6] = -6;
}
if (this.statLvChange[6] < 0) {
this.Accuracy = 3.0 / (3.0 - this.statLvChange[6]);
} else {
this.Accuracy = (this.statLvChange[6] + 3.0) / 3.0;
}
break;
case "evasion":
//g.p("Accuracy and Evasion support coming soon!");
if (howMuch == 1) {
g.p(this.Name + "'s evasion rose!");
} else if (howMuch == -1) {
g.p(this.Name + "'s evasion fell!");
} else if (howMuch > 0) {
g.p(this.Name + "'s evasion sharply rose!");
} else {
g.p(this.Name + "'s evasion harshly fell!");
}
this.statLvChange[7] += howMuch;
if (this.statLvChange[7] > 6) {
g.p(this.Name + "'s evasion can't go any higher!");
this.statLvChange[7] = 6;
} else if (this.statLvChange[7] < -6) {
g.p(this.Name + "'s evasion can't go any lower!");
this.statLvChange[7] = -6;
}
if (this.statLvChange[7] < 0) {
this.Evasion = 3.0 / (3.0 - this.statLvChange[7]);
} else {
this.Evasion = (this.statLvChange[7] + 3.0) / 3.0;
}
break;
default:
System.err.println("ERROR - " + stat + " is an invalid stat type");
break;
}
}
@Override
public String toString() {
return
Name + " (lv. " + Level + ")'s stats:"+
"\n\nAttack: " + Attack +
"\nDefense: " + Defense +
"\nSpecial Attack: " + SpAttack +
"\nSpecial Defense: " + SpDefense +
"\nSpeed: " + Speed +
"\nHealth: " + Health + " of " + MaxHealth +
"\nAccuracy: " + Math.floor(Accuracy * 10.0)/10.0 +
"\nEvasiness: " + Math.floor(Evasion * 10.0)/10.0 + "\n" +
"\nType 1: " + TypeOne +
"\nType 2: " + TypeTwo
+ "\n\n" +
AttackList[0] + "\n\n" +
AttackList[1] + "\n\n" +
AttackList[2] + "\n\n" +
AttackList[3];
}
}