-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPokemon.java
454 lines (433 loc) · 11.6 KB
/
Pokemon.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
444
445
446
447
448
449
450
451
452
453
454
/*Pokemon.java
*Namashi Sivaram and Will Jarvis-Cross
*creates a pokemon object to be used in the pokemon tron heroes game
*each pokemon has its own moves(editable),type, and stats. Pokemon also have
*iv values which influence thier final stat to give the same type of pokemon
*individuality
*/
import java.awt.image.*;
import java.awt.*;
import java.util.LinkedList;
public class Pokemon {
String name,type1,type2,ability,evolvefrom;
private int atk,def,spatk,spdef,spd,expv,evolve;
private int hp,exp,lvl,hpmax;
final int catchrate;
final int index;
private Moves[] moves=new Moves[4];
private int[] iv=new int[6];
final Image frontsprite;
final Image backsprite;
Image minisprite;
//stat modifiers
int atkmod=6;
int defmod=6;
int spatkmod=6;
int spdefmod=6;
int spdmod=6;
int evamod=6;
int accmod=6;
//status flags
private boolean flinch=false;
private boolean recharge=false;
private boolean seeded=false;
private boolean bind=false;
private int bidedmg=0;
private int bindturns=0;
private int clampturns=0;
private boolean poison=false;
private int poiturns=0;
private boolean sleep=false;
private int sleepturns=0;
private boolean para=false;
private int paraturns=0;
private boolean burn=false;
private int burnturns=0;
private boolean confuse=false;
private boolean freeze=false;
private int confuseturns=0;
private int earnedexp=0;
private boolean conversion=false;
LinkedList<Pokemon> battledagainst=new LinkedList<Pokemon>();
double[] statstages={2.0/8.0,2.0/7.0,2.0/6.0,2.0/5.0,2.0/4.0,2.0/3.0,2.0/2.0,3/2.0,4.0/2.0,5.0/2.0,6.0/2.0,7.0/2.0,8.0/2.0};
double[] acceva={3.0/9.0,3.0/8.0,3.0/7.0,3.0/6.0,3.0/5.0,3.0/4.0,3.0/3.0,4.0/3.0,5.0/3.0,6.0/3.0,7.0/3.0,8.0/3.0,9.0/3.0};
public Pokemon(String[] stats,int lvl,Moves[] moves,int[] ivs, Image fsprt,Image bsprt,Image msprt) {
index=Integer.parseInt(stats[1])-1;
minisprite=msprt;
name=stats[2];
hp=Integer.parseInt(stats[3]);
atk=Integer.parseInt(stats[4]);
def=Integer.parseInt(stats[5]);
spatk=Integer.parseInt(stats[6]);
spdef=Integer.parseInt(stats[7]);
spd=Integer.parseInt(stats[8]);
type1=stats[10].toUpperCase();
type2=stats[11].toUpperCase();
System.out.println(type2);
ability=stats[13];
expv=Integer.parseInt(stats[19]);
catchrate=Integer.parseInt(stats[25]);
exp=Integer.parseInt(stats[26]);
if(!stats[27].equals("")&&!stats[27].equals("N")){
if (stats[27].split(" ")[0].equals("Lv.")){
evolve=Integer.parseInt(stats[27].split(" ")[1]);
}
}
evolvefrom=stats[34];
this.lvl=lvl;
this.moves=moves;
frontsprite=fsprt;
backsprite=bsprt;
iv=ivs;
hp=(int)(((2*hp+iv[0]+(42.0/4.0))*lvl)/100)+10+lvl;
System.out.println(hp);
atk=(int)(((2*atk+iv[1]+(42.0/4.0))*lvl)/100)+5;
System.out.println(atk);
def=(int)(((2*def+iv[2]+(42.0/4.0))*lvl)/100)+5;
System.out.println(def);
spatk=(int)(((2*spatk+iv[3]+(42.0/4.0))*lvl)/100)+5;
System.out.println(spatk);
spdef=(int)(((2*spdef+iv[4]+(42.0/4.0))*lvl)/100)+5;
System.out.println(spdef);
spd=(int)(((2*spd+iv[5]+(42.0/4.0))*lvl)/100.0)+5;
System.out.println(spd);
hpmax=hp;
setExp();
}
public String toString(){
String ans="";
ans+=name+": ";
ans+=hp+"\n";
for (int i=0;i<4;i++){
if (moves[i]!=null){
ans+=i+". "+moves[i].toString()+"\n";
}
}
return ans;
}
//setters and getters
public String getName(){
return name;
}
public String getType1(){
if(conversion){
return moves[0].getType();
}
return type1;
}
public String getType2(){
return type2;
}
public int getAtk(){
if (burn){
return atk/2;
}
return atk;
}
public int getDef(){
return def;
}
public int getSpatk(){
return spatk;
}
public int getSpdef(){
return spdef;
}
public int getSpd(){
if (para){
return spd/2;
}
return spd;
}
public int getLvl(){
return lvl;
}
public double getAtkMod(){
System.out.println(atkmod+","+statstages[atkmod]);
return statstages[atkmod];
}
public double getDefMod(){
return statstages[defmod];
}
public double getSpatkMod(){
return statstages[spatkmod];
}
public double getSpdefMod(){
return statstages[spdefmod];
}
public double getSpdMod(){
return statstages[spdmod];
}
public double getEvaMod(){
return acceva[evamod];
}
public double getAccMod(){
return acceva[accmod];
}
public boolean getFlinch(){
return flinch;
}
public void setFlinch(boolean tf){
flinch=tf;
}
public boolean getPoison(){
return poison;
}
public boolean getBurn(){
return burn;
}
public boolean getPara(){
return para;
}
public boolean getSleep(){
return sleep;
}
public boolean getFreeze(){
return freeze;
}
public boolean getConfuse(){
return confuse;
}
public boolean getStatus(){
if(para||burn||poison||freeze||sleep){
return true;
}
return false;
}
public void setSeeded(boolean t){
seeded=t;
}
public boolean getSeeded(){
return seeded;
}
public void setPoison(boolean t){
poison=t;
}
public void setBurn(boolean t){
burn=t;
}
public void setPara(boolean t){
para=t;
}
public void setSleep(boolean t){
sleep=t;
}
public void setConfuse(boolean t){
confuse=t;
}
public void setFreeze(boolean t){
freeze=t;
}
public int getPoisonTurns(){
return poiturns;
}
public int getBurnTurns(){
return burnturns;
}
public int getParaTurns(){
return paraturns;
}
public int getSleepTurns(){
return sleepturns;
}
public int getConfuseTurns(){
return confuseturns;
}
public void setPoisonTurns(int i){
poiturns=i;
}
public void setBurnTurns(int i){
burnturns=i;
}
public void setParaTurns(int i){
paraturns=i;
}
public void setSleepTurns(int i){
sleepturns=i;
}
public void setConfuseTurns(int i){
confuseturns=i;
}
public void setHP(int h){
hp=h;
}
public int getHP(){
return hp;
}
public int getHPMax(){
return hpmax;
}
private void setExp(){
if (exp==800000){
earnedexp=(int)(4*Math.pow(lvl,3))/5;
}
else if (exp==1059860){
earnedexp=(int)Math.abs((6.0/5.0)*Math.pow(lvl,3)-15*Math.pow(lvl,2)+100*(lvl)-140);
}
else if (exp==1250000){
earnedexp=(int)(5*Math.pow(lvl,3))/4;
}
else {
earnedexp=(int)Math.pow(lvl,3);
}
}
public boolean Levelup(){//returns if a pokemon can level up and applies it
if(getExpEarned()>=toNextLvl()){
lvl+=1;
return true;
}
return false;
}
public int toNextLvl(){//returns how much exp is needed for a mon based on exp growth rate formulas
if (lvl==100){
return 0;
}
if (exp==800000){
return (int)(4*Math.pow(lvl+1,3))/5-(int)(4*Math.pow(lvl,3))/5;
}
else if (exp==1059860){
return (int)Math.abs((6.0/5.0)*Math.pow(lvl+1,3)-15*Math.pow(lvl+1,2)+100*(lvl+1)-140)-(int)Math.abs((6.0/5.0)*Math.pow(lvl,3)-15*Math.pow(lvl,2)+100*(lvl)-140);
}
else if (exp==1250000){
return (int)(5*Math.pow(lvl+1,3))/4-(int)(5*Math.pow(lvl,3))/4;
}
else {
return (int)Math.pow(lvl+1,3)-(int)Math.pow(lvl,3);
}
}
public int getExpEarned(){//returns how much exp a pokemon has at its lvl based on the mons exp growth rate
if (lvl==100){
return 0;
}
if (exp==800000){
return earnedexp-(int)(4*Math.pow(lvl,3))/5;
}
else if (exp==1059860){
return earnedexp-(int)Math.abs((6.0/5.0)*Math.pow(lvl,3)-15*Math.pow(lvl,2)+100*(lvl)-140);
}
else if (exp==1250000){
return earnedexp-(int)(5*Math.pow(lvl,3))/4;
}
else {
return earnedexp-(int)Math.pow(lvl,3);
}
}
public int getExpVal(){
return expv;
}
public void addBattled(Pokemon foe){
battledagainst.add(foe);
}
public int[] getIvs(){
return iv;
}
public void setIvs(int[] i){
iv=i;
}
public void setMoves(Moves[] i){
moves=i;
}
public Moves[] getMoves(){
return moves;
}
public void addExp(int ex){
earnedexp+=ex;
}
public void setExp(int ex){
earnedexp=ex;
}
public int getbindTurns(){
return bindturns;
}
public void setbindTurns(int t){
bindturns=t;
}
public int getclampTurns(){
return clampturns;
}
public void setclampTurns(int t){
clampturns=t;
}
public void setConversion(boolean tf){
conversion=tf;
}
public boolean getConversion(){
return conversion;
}
public void reset(){//used when a pokemon is switched out of battle
flinch=false;
seeded=false;
confuse=false;
confuseturns=0;
atkmod=6;
defmod=6;
spdefmod=6;
spatkmod=6;
spdmod=6;
clampturns=0;
bindturns=0;
evamod=6;
accmod=6;
recharge=false;
for(Moves m:moves){
if(m!=null){
m.setDisable(0);
}
}
conversion=false;
}
public void statReset(){//restes all stat mods
atkmod=6;
defmod=6;
spdefmod=6;
spatkmod=6;
spdmod=6;
evamod=6;
accmod=6;
}
public boolean getRecharge(){
return recharge;
}
public void setRecharge(boolean tf){
recharge=tf;
}
public void heal(){//fully heals them
reset();
poison=false;
burn=false;
para=false;
confuse=false;
freeze=false;
for(Moves m:moves){
if(m!=null){
m.setPP(m.getPPMax());
}
}
hp=hpmax;
}
public void statusHeal(){//heals a pokemons status's
poison=false;
para=false;
freeze=false;
burn=false;
sleep=false;
}
public boolean noMoves(){//whether the pokemon has any usable moves left (have pp and arnet disabled)
if((getMoves()[0]==null||getMoves()[0].getPP()<=0)&&(getMoves()[1]==null||getMoves()[1].getPP()<=0)&&(getMoves()[2]==null||getMoves()[2].getPP()<=0)&&(getMoves()[3]==null||getMoves()[3].getPP()<=0)){
return true;
}
return false;
}
public boolean stab(String mvtype){//checks if move type matches pokemon type
if(type1.equals(mvtype)){
return true;
}
if(type2.equals(mvtype)){
return true;
}
if(getType1().equals(mvtype)){
return true;
}
return false;
}
}////////////////////////////////////////////////////////////////////////////////////////////////add move pp reset