-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpokemonBattle.java
More file actions
702 lines (599 loc) · 44.8 KB
/
Copy pathpokemonBattle.java
File metadata and controls
702 lines (599 loc) · 44.8 KB
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
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;
public class pokemonBattle {
public static void main(String[] args) {
//Moves Max PP: 8/5ths of base PP, 40 - 64, 30 - 48, 15 - 24, 10 - 16, 5 - 8
Move acrobatics = new Move("Acrobatics", "Flying", "Phys", 110, 100, 15, null, 0, 0);
Move aerialAce = new Move("Aerial Ace", "Flying", "Phys", 60, 100, 20, null, 0, 0);//guaranteed hit
Move airSlash = new Move("Air Slash", "Flying", "Spec", 75, 95, 15, null, 0, 0);
Move ancientPower = new Move("Ancient Power", "Rock", "Spec", 60, 100, 5, null, 0, 0);
Move aquaTail = new Move("Aqua Tail", "Water", "Phys", 90, 90, 10, null, 0, 0);
Move auraSphere = new Move("Aura Sphere", "Fighting", "Spec", 80, 100, 20, null, 0, 0);//guaranteed hit
Move blizzard = new Move("Blizzard", "Ice", "Spec", 110, 70,5, null, 0, 0);
Move bodyPress = new Move("Body Press", "Fighting", "Phys", 80, 100,10, null, 0, 0);
Move braveBird = new Move("Brave Bird", "Flying", "Phys", 120, 100, 15, null, 0, 0);
Move bulletPunch = new Move("Bullet Punch", "Steel", "Phys", 40, 100, 30, null, 0, 1);
Move closeCombat = new Move("Close Combat", "Fighting", "Phys", 120, 100, 5, null, 0, 0);
Move crossPoison = new Move("Cross Poison", "Poison", "Phys", 70, 100, 20, null, 0, 0);
Move crunch = new Move("Crunch", "Dark", "Phys", 80, 100, 15, null, 0, 0);
Move crushClaw = new Move("Crush Claw", "Normal", "Phys", 75, 95, 10, null, 0, 0);
Move darkPulse = new Move("Dark Pulse", "Dark", "Spec", 80, 100, 15, null, 0, 0);
Move dazzlingGleam = new Move("Dazzling Gleam", "Fairy", "Spec", 80, 100, 10, null, 0, 0);
Move dig = new Move("Dig", "Ground", "Phys", 80, 100, 10, null, 0, 0);
Move doubleEdge = new Move("Double Edge", "Normal", "Phys", 120, 100, 15, null, 0, 0);
Move dracoMeteor = new Move("Draco Meteor", "Dragon", "Spec", 130, 90, 5, null, 0, 0);
Move dragonAscent = new Move("Dragon Ascent", "Flying", "Phys", 120, 100, 5, null, 0, 0);
Move dragonClaw = new Move("Dragon Claw", "Dragon", "Phys", 80, 100, 15, null, 0, 0);
Move earthPower = new Move("Earth Power", "Ground", "Spec", 90, 100, 10, null, 0, 0);
Move earthquake = new Move("Earthquake", "Ground", "Phys", 100, 100, 10, null, 0, 0);
Move energyBall = new Move("Energy Ball", "Grass", "Spec", 90, 100, 10, null, 0, 0);
Move extremeSpeed = new Move("Extreme Speed", "Normal", "Phys", 80, 100, 5, null, 0, 2);
Move flamethrower = new Move("Flamethrower", "Fire", "Spec", 90, 100, 15, null, 0, 0);
Move flareBlitz = new Move("Flare Blitz", "Fire", "Phys", 120, 100, 15, null, 0, 0);
Move fly = new Move("Fly", "Flying", "Phys", 90, 95, 15, null, 0, 0);
Move foulPlay = new Move("Foul Play", "Dark", "Spec", 95, 100, 15, null, 0, 0);
Move gigaImpact = new Move("Giga Impact", "Normal", "Phys", 150, 90, 5, null, 0, 0);
Move hammerArm = new Move("Hammer Arm", "Fighting", "Phys", 100, 90, 10, null, 0, 0);
Move hurricane = new Move("Hurricane", "Flying", "Spec", 110, 70, 10, null, 0, 0);
Move hydroPump = new Move("Hydro Pump", "Water", "Spec", 110, 80, 5, null, 0, 0);
Move hyperBeam = new Move("Hyper Beam", "Normal", "Spec", 150, 90, 5, null, 0, 0);
Move hyperVoice = new Move("Hyper Voice", "Normal", "Spec", 90, 100, 10, null, 0, 0);
Move iceBeam = new Move("Ice Beam", "Ice", "Spec", 90, 100, 10, null, 0, 0);
Move icePunch = new Move("Ice Punch", "Ice", "Phys", 75, 100, 15, null, 0, 0);
Move ironHead = new Move("Iron Head", "Steel", "Phys", 80, 100, 15, null, 0, 0);
Move ironTail = new Move("Iron Tail", "Steel", "Phys", 100, 75, 15, null, 0, 0);
Move judgement = new Move("Judgement", "Normal", "Spec", 100, 100, 10, null, 0, 0);
Move metalClaw = new Move("Metal Claw", "Steel", "Phys", 50, 95, 35, null, 0, 0);
Move meteorMash = new Move("Meteor Mash", "Steel", "Phys", 90, 90, 10, null, 0, 0);
Move moonblast = new Move("Moonblast", "Fairy", "Spec", 95, 100, 15, null, 0, 0);
Move outrage = new Move("Outrage", "Dragon", "Phys", 120, 100, 10, null, 0, 0);
Move overheat = new Move("Overheat", "Fire", "Spec", 130, 90, 5, null, 0, 0);
Move psychic = new Move("Psychic", "Psychic", "Spec", 90, 100, 10, null, 0, 0);
Move rockSlide = new Move("Rock Slide", "Rock", "Phys", 75, 90, 10, null, 0, 0);
Move scald = new Move("Scald", "Water", "Spec", 80, 100, 15, null, 0, 0);
Move shadowBall = new Move("Shadow Ball", "Ghost", "Spec", 80, 100, 15, null, 0, 0);
Move shadowForce = new Move("Shadow Force", "Ghost", "Phys", 120, 100, 5, null, 0, 0);
Move sludgeBomb = new Move("Sludge Bomb", "Poison", "Spec", 90, 100, 10, null, 0, 0);
Move sludgeWave = new Move("Sludge Wave", "Poison", "Spec", 95, 100, 10, null, 0, 0);
Move steelWing = new Move("Steel Wing", "Steel", "Phys", 70, 90, 25, null, 0, 0);
Move stoneEdge = new Move("Stone Edge", "Rock", "Phys", 100, 80, 5, null, 0, 0);
Move suckerPunch = new Move("Sucker Punch", "Dark", "Phys", 80, 100, 5, null, 0, 1);//had pover of 80 pre gen-7
Move throatChop = new Move("Throat Chop", "Dark", "Phys", 80, 100, 15, null, 0, 0);
Move thunder = new Move("Thunder", "Electric", "Spec", 110, 70, 10, null, 0, 0);
Move thunderbolt = new Move("Thunderbolt", "Electric", "Spec", 90, 100, 15, null, 0, 0);
Move waterPulse = new Move("Water Pulse", "Water", "Spec", 60, 100, 20, null, 0, 0);
Move xScissor = new Move("X-Scissor", "Bug", "Phys", 80, 100, 15, null, 0, 0);
Move zenHeadbutt = new Move("Zen Headbutt", "Psychic", "Phys", 80, 90, 15, null, 0, 0);
//Pokemon Lv. 50 Stat calculaator: https://pycosites.com/pkmn/stat.php Sets: https://calc.pokemonshowdown.com/
Pokemon cynthiasSpiritomb = new Pokemon("Spiritomb", 50, new ArrayList<>(Arrays.asList("Ghost", "Dark")), new ArrayList<>(Arrays.asList(shadowBall, darkPulse, psychic, suckerPunch)), 110, 97, 113, 97, 113, 40);
Pokemon cynthiasRoserade = new Pokemon("Roserade", 50, new ArrayList<>(Arrays.asList("Grass", "Poison")), new ArrayList<>(Arrays.asList(dazzlingGleam, shadowBall, sludgeBomb, energyBall)), 120, 75, 70, 130, 110, 95);
Pokemon cynthiasTogekiss = new Pokemon("Togekiss", 50, new ArrayList<>(Arrays.asList("Fairy", "Flying")), new ArrayList<>(Arrays.asList(airSlash, dazzlingGleam, auraSphere, waterPulse)), 145, 55, 100, 125, 120, 85);
Pokemon cynthiasLucario = new Pokemon("Lucario", 50, new ArrayList<>(Arrays.asList("Fighting", "Steel")), new ArrayList<>(Arrays.asList(closeCombat, meteorMash, psychic, earthquake)), 130, 115, 75, 120, 75, 95);
Pokemon cynthiasMilotic = new Pokemon("Milotic", 50, new ArrayList<>(Arrays.asList("Water", null)), new ArrayList<>(Arrays.asList(hydroPump, blizzard, iceBeam, scald)), 155, 65, 84, 105, 130, 86);
Pokemon cynthiasGarchomp = new Pokemon("Garchomp", 50, new ArrayList<>(Arrays.asList("Dragon", "Ground")), new ArrayList<>(Arrays.asList(outrage, earthquake, stoneEdge, gigaImpact)), 183, 150, 115, 100, 105, 122);
Pokemon cyrusHoundoom = new Pokemon("Mega Houndoom", 50, new ArrayList<>(Arrays.asList("Dark", "Fire")), new ArrayList<>(Arrays.asList(overheat, shadowBall, sludgeBomb, darkPulse)), 135, 95,95, 145, 95, 120);
Pokemon cyrusHonchkrow = new Pokemon("Honchkrow", 50, new ArrayList<>(Arrays.asList("Dark", "Flying")), new ArrayList<>(Arrays.asList(foulPlay, psychic, acrobatics, doubleEdge)), 160, 130, 57, 110, 57, 76);
Pokemon cyrusCrobat = new Pokemon("Crobat", 50, new ArrayList<>(Arrays.asList("Poison", "Flying")), new ArrayList<>(Arrays.asList(crossPoison, xScissor, fly, steelWing)), 145, 95, 85, 75, 85, 135);
Pokemon cyrusGyarados = new Pokemon("Gyarados", 50, new ArrayList<>(Arrays.asList("Water", "Flying")), new ArrayList<>(Arrays.asList(aquaTail, crunch, outrage, hurricane)), 155, 130, 84, 65, 105, 86);
Pokemon cyrusWeavile = new Pokemon("Weavile", 50, new ArrayList<>(Arrays.asList("Dark", "Ice")), new ArrayList<>(Arrays.asList(icePunch, throatChop, dig, aerialAce)), 130, 125, 70, 50, 90, 130);
Pokemon cyrusGiratina = new Pokemon("Giratina (Origin Form)", 50, new ArrayList<>(Arrays.asList("Ghost", "Dragon")), new ArrayList<>(Arrays.asList(earthquake, dracoMeteor, thunder, shadowForce)), 210, 125, 105, 125, 105, 95);
Pokemon stevensSkarmory = new Pokemon("Skarmory", 50, new ArrayList<>(Arrays.asList("Steel", "Flying")), new ArrayList<>(Arrays.asList(bodyPress, braveBird, xScissor, ironHead)), 125, 85,145,45, 75, 75);
Pokemon stevensClaydol = new Pokemon("Claydol", 50, new ArrayList<>(Arrays.asList("Ground", "Psychic")), new ArrayList<>(Arrays.asList(iceBeam, dazzlingGleam, psychic, earthPower)), 120, 75, 110, 75, 125, 80);
Pokemon stevensAggron = new Pokemon("Aggron", 50, new ArrayList<>(Arrays.asList("Steel", "Rock")), new ArrayList<>(Arrays.asList(stoneEdge, earthquake, ironTail, dragonClaw)), 130, 115, 185, 65, 65, 55);
Pokemon stevensCradily = new Pokemon("Cradily", 50, new ArrayList<>(Arrays.asList("Rock", "Grass")), new ArrayList<>(Arrays.asList(energyBall, ancientPower, sludgeBomb, hyperBeam)), 146, 86, 102, 86, 112, 48);
Pokemon stevensArmaldo = new Pokemon("Armaldo", 50, new ArrayList<>(Arrays.asList("Rock", "Bug")), new ArrayList<>(Arrays.asList(xScissor, stoneEdge, ironTail, crushClaw)), 135, 130, 105, 75, 85, 50);
Pokemon stevensMetagross = new Pokemon("Metagross", 50, new ArrayList<>(Arrays.asList("Steel", "Psychic")), new ArrayList<>(Arrays.asList(zenHeadbutt, meteorMash, bulletPunch, hammerArm)), 140, 154, 135, 100, 95, 75);
Pokemon arceus = new Pokemon("Arceus", 50, new ArrayList<>(Arrays.asList("Normal", null)), new ArrayList<>(Arrays.asList(judgement, shadowBall, thunder, extremeSpeed)), 180, 125, 125, 125, 125, 125);
Pokemon crobat = new Pokemon("Crobat", 50, new ArrayList<>(Arrays.asList("Poison", "Flying")), new ArrayList<>(Arrays.asList(crossPoison, xScissor, fly, steelWing)), 145, 95, 85, 75, 85, 135);
Pokemon excadrill = new Pokemon("Excadrill", 50, new ArrayList<>(Arrays.asList("Ground", "Steel")), new ArrayList<>(Arrays.asList(throatChop, earthquake, rockSlide, ironHead)), 168, 135, 100, 85, 90, 107);
Pokemon garchomp = new Pokemon("Garchomp", 50, new ArrayList<>(Arrays.asList("Dragon", "Ground")), new ArrayList<>(Arrays.asList(flamethrower, earthquake, outrage, crunch)), 168, 135, 100, 85, 90, 107);
Pokemon gardevoir = new Pokemon("Gardevoir", 50, new ArrayList<>(Arrays.asList("Psychic", "Fairy")), new ArrayList<>(Arrays.asList(moonblast, psychic, thunderbolt, energyBall)), 168, 135, 100, 85, 90, 107);
Pokemon gengar = new Pokemon("Gengar", 50, new ArrayList<>(Arrays.asList("Ghost", "Poison")), new ArrayList<>(Arrays.asList(shadowBall, thunder, psychic, sludgeWave)), 120, 70, 65,135, 80, 115);
Pokemon gyarados = new Pokemon("Gyarados", 50, new ArrayList<>(Arrays.asList("Water", "Flying")), new ArrayList<>(Arrays.asList(aquaTail, crunch, outrage, hurricane)), 155, 130, 84, 65, 105, 86);
Pokemon infernape = new Pokemon("Infernape", 50, new ArrayList<>(Arrays.asList("Fire", "Fighting")), new ArrayList<>(Arrays.asList(flareBlitz, acrobatics, closeCombat, earthquake)), 136, 109, 76, 109, 76, 113);
Pokemon lucario = new Pokemon("Lucario", 50, new ArrayList<>(Arrays.asList("Fighting", "Steel")), new ArrayList<>(Arrays.asList(closeCombat, meteorMash, psychic, earthquake)), 130, 115, 75, 120, 75, 95);
Pokemon metagross = new Pokemon("Metagross", 50, new ArrayList<>(Arrays.asList("Steel", "Psychic")), new ArrayList<>(Arrays.asList(zenHeadbutt, meteorMash, bulletPunch, hammerArm)), 140, 154, 135, 100, 95, 75);
Pokemon milotic = new Pokemon("Milotic", 50, new ArrayList<>(Arrays.asList("Water", null)), new ArrayList<>(Arrays.asList(hydroPump, blizzard, iceBeam, scald)), 155, 65, 84, 105, 130, 86);
Pokemon rayquaza = new Pokemon("Rayquaza", 50, new ArrayList<>(Arrays.asList("Dragon", "Flying")), new ArrayList<>(Arrays.asList(dragonAscent, earthquake, outrage, extremeSpeed)), 165, 155, 95, 155, 95, 100);
Pokemon roserade = new Pokemon("Roserade", 50, new ArrayList<>(Arrays.asList("Grass", "Poison")), new ArrayList<>(Arrays.asList(dazzlingGleam, shadowBall, sludgeBomb, energyBall)), 120, 75, 70, 130, 110, 95);
Pokemon spiritomb = new Pokemon("Spiritomb", 50, new ArrayList<>(Arrays.asList("Ghost", "Dark")), new ArrayList<>(Arrays.asList(shadowBall, darkPulse, psychic, suckerPunch)), 110, 97, 113, 97, 113, 40);
Pokemon togekiss = new Pokemon("Togekiss", 50, new ArrayList<>(Arrays.asList("Fairy", "Flying")), new ArrayList<>(Arrays.asList(airSlash, dazzlingGleam, auraSphere, waterPulse)), 145, 55, 100, 125, 120, 85);
Pokemon tyranitar = new Pokemon("Tyranitar", 50, new ArrayList<>(Arrays.asList("Rock", "Dark")), new ArrayList<>(Arrays.asList(foulPlay, earthquake, stoneEdge, icePunch)), 160, 139, 115, 100, 105, 66);
Pokemon weavile = new Pokemon("Weavile", 50, new ArrayList<>(Arrays.asList("Dark", "Ice")), new ArrayList<>(Arrays.asList(icePunch, throatChop, dig, aerialAce)), 130, 125, 70, 50, 90, 130);
Pokemon whiteKyurem = new Pokemon("White Kyurem", 50, new ArrayList<>(Arrays.asList("Dragon", "Ice")), new ArrayList<>(Arrays.asList(iceBeam, shadowBall, dracoMeteor, hyperVoice)), 185, 125, 95, 175, 105, 100);
//Pokemon Teams
ArrayList<Pokemon> team1 = new ArrayList<>(Arrays.asList(weavile, metagross, togekiss, crobat, garchomp, rayquaza));
ArrayList<Pokemon> team2 = new ArrayList<>(Arrays.asList(infernape, gyarados, spiritomb, excadrill, roserade, whiteKyurem));
ArrayList<Pokemon> team3 = new ArrayList<>(Arrays.asList(gengar, milotic, tyranitar, lucario, gardevoir, arceus));
ArrayList<Pokemon> cynthiasTeam = new ArrayList<>(Arrays.asList(cynthiasSpiritomb, cynthiasRoserade, cynthiasTogekiss, cynthiasLucario, cynthiasMilotic, cynthiasGarchomp));
ArrayList<Pokemon> cyrusTeam = new ArrayList<>(Arrays.asList(cyrusHoundoom, cyrusHonchkrow, cyrusCrobat, cyrusGyarados, cyrusWeavile, cyrusGiratina));
ArrayList<Pokemon> stevensTeam = new ArrayList<>(Arrays.asList(stevensSkarmory, stevensClaydol, stevensAggron, stevensCradily, stevensArmaldo, stevensMetagross));
//Array of pokemon teams to choose from
ArrayList<ArrayList<Pokemon>> pokeTeams = new ArrayList<>(Arrays.asList(team1, team2, team3));
//Trainers - https://bulbapedia.bulbagarden.net/wiki/Prize_money
Trainer user;
Trainer cynthia = new Trainer("Champion Cynthia", cynthiasTeam, 200);
Trainer cyrus = new Trainer("Team Galactic Boss Cyrus", cyrusTeam, 280);
Trainer steven = new Trainer("Champion Steven", stevensTeam, 200);
//Array of available Trainers to choose from
ArrayList<Trainer> trainers = new ArrayList<>(Arrays.asList(cynthia, cyrus, steven));
String rayquazaAscii = """
⠀⠀⠀⠀⢀⣤⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠸⣟⢦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⢸⡀⠳⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢧⠀⠘⢆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣴⣿⡿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠘⡇⠀⠈⢳⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⡶⠛⢉⡼⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⢸⡀⢠⡾⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣰⣾⠟⠙⠀⣠⠞⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢧⠈⡇⠀⠀⠀⠀⠀⠀⠀⢀⣤⣾⠟⢋⣀⣀⣠⠾⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⢀⡀⠀⢀⣨⠗⠛⠒⠒⣶⡶⣢⣤⣶⠟⣫⡴⠒⠋⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⢀⣾⣿⣿⣿⡷⣶⣶⣶⣺⣭⠾⠟⠉⣡⢞⣿⠦⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣾⡿⢣⢞⣿⣿⣭⡽⢿⡏⠀⠤⠄⠿⠋⠀⢻⡆⢷⣏⡓⢦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⣴⣿⠏⣀⣼⣿⣯⣿⣷⣤⡿⢿⣧⠀⢘⣁⣀⣀⣀⡛⠳⢬⣝⣦⣈⠓⢄⣀⣾⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⣿⣿⣿⠛⠻⠟⣻⡏⠉⢀⢿⣿⡿⢳⣄⡘⣯⠉⠓⠲⢤⣤⡈⠙⠯⣓⢮⣿⣿⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠉⠀⠁⠀⠀⢸⡟⠀⢀⣾⣿⠟⠀⠀⠙⣿⣾⣧⠀⠀⠀⠙⢻⣶⠄⠈⠳⣝⣿⢯⢷⣶⣶⣶⣶⣤⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠠⣿⡀⣀⣼⣿⣯⣤⣤⣦⡀⠈⢿⡻⢳⡀⠀⠀⠀⢹⡳⡶⠞⡛⢹⣧⠀⢿⣦⠀⠈⢿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠉⠉⠉⣹⣿⣿⣿⣿⣿⣷⣦⣀⣽⣆⣳⣶⣶⣶⣾⣧⠀⠙⣶⠟⠉⢻⣾⡏⠀⠀⢻⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣀⣴⣿⠿⠿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣟⣿⣟⣻⡀⠀⣸⣄⣠⠾⣿⣷⠀⠀⣾⣷⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⣀⡼⣿⠿⣿⣄⣤⣴⣿⣿⡿⢭⣽⣿⡽⠿⠟⣻⣿⡟⢛⣿⡶⠟⠉⢹⣦⡘⣿⡄⢠⣿⣿⣯⣻⣷⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⣤⢾⡿⠃⢉⣤⣿⣿⣿⣟⣯⣟⠓⣿⣿⠿⣿⣷⠶⠿⠋⠀⣸⣼⣧⡀⢀⣿⡟⢳⡈⣷⣼⠛⠛⠿⣿⣟⡻⣿⣷⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⢠⡞⢡⠟⢡⢿⣽⠿⠿⣿⣿⣿⣿⣿⡿⠁⠉⠉⠉⠁⠀⠀⠀⢰⣿⣁⣵⣧⣾⣿⡧⠾⠋⣹⡧⠀⠀⠀⠀⠉⠛⢿⣿⣿⣿⣶⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⢠⣿⡄⠈⠀⢸⡾⠁⠀⠀⠹⠛⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⡟⣾⣟⣿⠟⣹⣧⠶⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⢿⣿⣿⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⣿⣿⡇⠀⠀⢸⠃⠀⣴⠟⠛⠻⠿⠿⠿⣧⠀⠀⠀⠀⠀⠀⣠⠎⠀⠉⣹⠿⡿⣻⡟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠻⣽⣿⣿⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀
⣿⣿⠀⠀⠀⣠⠧⠾⢯⣀⣀⡀⠀⠀⣀⣿⣆⠀⢀⣠⠴⠊⠀⠀⣠⣮⣷⣿⣿⠟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⣿⣯⣿⣷⣤⣀⠀⠀⠀⠀⠀
⢻⣿⡀⢀⡞⠁⠀⠀⠀⠀⠉⠉⠉⠉⢉⣽⠟⠋⠉⠁⠀⣀⠀⢈⡿⢿⢿⡿⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣿⣿⣿⣿⣿⣷⣤⡀⠀⠀
⠀⠱⣝⢿⣶⣶⢄⣀⡀⠀⠀⠀⠀⠀⣾⠃⠀⣠⠖⠍⠛⣿⣏⣭⣾⠿⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣿⣿⣿⣿⣿⣶⡄
⠀⠀⠈⠙⢷⣉⠉⠛⠚⠿⠿⢶⣶⣶⣿⡶⣶⢻⣤⡴⣶⣻⠿⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⣯⣿⢿⣯⠁⠀⠀⠀
⠀⠀⠀⠀⠀⠙⣷⡤⠤⠤⣄⣀⣀⡀⢈⣛⣿⣽⠿⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⡿⠃⠀⢻⡆⠀⠀⠀
⠀⠀⠀⠀⠀⢸⣿⣗⠤⣄⡀⠀⠉⢩⣽⡟⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠈⠉⠙⠛⠲⢿⣶⣤⣾⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
""";
//Create Scanner
Scanner scanner = new Scanner(System.in);
Random random = new Random();
boolean accepted = false;//used to confirm move selection
String choice = "";
String moveSelection = "";//stored value of move selected by user
Move userMove = null;//the move the user has picked for this turn
Move compMove;//the move the computer is using this turn
int speedTie;//used for determining which pokemon goes first in the event their speeds are the same
//Greets user and gets the pokemon the user would like to use
pokemonSelection(pokeTeams);
accepted = false;
while (!accepted) {
System.out.print("\nPlease select the number of the team you'd like to use: ");
choice = scanner.nextLine();
//ensures the number of the team is valid
if (choice.equals("1") || choice.equals("2") || choice.equals("3")) {
accepted = true;
}
}
//set user's chosen pokemon to their Pokemon
user = new Trainer("user", pokeTeams.get(Integer.parseInt(choice) - 1), 120);
//Get the trainer the user would like to face
trainerSelection(trainers);
accepted = false;
while (!accepted) {
System.out.print("Please select the number of the Trainer you would like to face: ");
choice = scanner.nextLine();
//ensures the number of the trainer is valid
if (choice.equals("1") || choice.equals("2") || choice.equals("3")) {
accepted = true;
}
}
//set user's chosen pokemon to their pokemon
Trainer comp = trainers.get(Integer.parseInt(choice) - 1);
//Prints text for start of the battle
startBattle(user, comp);
// repeats battle sequence until we get a winner. True while neither pokemon has fainted.
while (user.remainingPokemon > 0 && comp.remainingPokemon > 0) {
//print out user's pokemon's moves and a number to select them with, alongside the remaining pp
System.out.println("What will " + user.currentPokemon.name + " do?");
for (int i = 0; i < 4; i++) {
System.out.println((i + 1) + ". " + user.currentPokemon.moves.get(i).name + " PP: " + user.currentPokemon.moves.get(i).currentPP + "/" + user.currentPokemon.moves.get(i).pp);
}
//Gives the additional option to switch pokemon
System.out.println("5. Switch");
//needs to be reset every iteration of while loop
accepted = false;
//Asks the user to enter which move they want to use until they give an acceptable answer
while (!accepted) {
System.out.print("Please enter the number of the move you want to use: ");
moveSelection = scanner.nextLine();
//Only if the user selected a move
//check that the user has entered the number of a move
if (moveSelection.equals("1") || moveSelection.equals("2") || moveSelection.equals("3") || moveSelection.equals("4")) {
accepted = true;
//check that the move still has pp
if (user.currentPokemon.moves.get(Integer.parseInt(moveSelection) - 1).currentPP == 0) {
System.out.println("You don't have enough PP to use that move");
accepted = false;
}
else{
//if there is enough pp, reduce the remaining pp by 1
user.currentPokemon.moves.get(Integer.parseInt(moveSelection) - 1).currentPP -= 1;
//userMove becomes the move the user wants to use
userMove = user.currentPokemon.moves.get(Integer.parseInt(moveSelection) - 1);
}
}
//if the user selected to switch pokemon
else if (moveSelection.equals("5")) {
String oldPokemon = user.currentPokemon.name;
userSwitchPokemon(user);
//switching happens instead of using a move for that turn
System.out.printf("%s, switch out!\nCome Back!\n", oldPokemon);
System.out.printf("Go! %s!", user.currentPokemon.name);
userMove = null;
accepted = true;
}
}
System.out.println();
//computerMove
compMove = comp.currentPokemon.moves.get(random.nextInt(1, 5) - 1);
speedTie = random.nextInt(0, 2);//used for determining which pokemon goes first in the event their speeds are the same
//Perorm both players attacks and print the result
battleSequence(user, user.currentPokemon, userMove, comp, comp.currentPokemon, compMove, speedTie);
//Displays match outcome when either pokemon has fainted
if (user.remainingPokemon == 0 || comp.remainingPokemon == 0) {
//if (user.currentPokemon.hasFainted || comp.currentPokemon.hasFainted) {
matchEnd(user, comp);
};
};
scanner.close();
}
public static void pokemonSelection(ArrayList<ArrayList<Pokemon>> pokeDex) {
//Greeting Message
System.out.println("*****************************************");
System.out.println(" Welcome to the Pokemon Battle Simulator");
System.out.println("*****************************************");
//Outputs each of the team of Pokemon and a number to select them
System.out.println("Which team of Pokemon would you like to use: ");
for (int i = 0; i < pokeDex.size(); i++) {
//goes through the team array and prints the name of each pokemon
System.out.print("Team " + (i + 1) + ". ");
for (Pokemon poke : pokeDex.get(i)) {
System.out.print(poke.name + ", ");
}
System.out.println();
}
}
public static void trainerSelection(ArrayList<Trainer> trainers) {
//Outputs each of the trainer's names and a number to select them
System.out.println("\nWhich Trainer would you like to face: ");
for (int i = 0; i < trainers.size(); i++) {
System.out.println((i + 1) + ". " + trainers.get(i).name);
}
}
//displays message welcoming you when copde is first ran
public static void startBattle(Trainer user, Trainer comp) {
// Start Battle Dialogue
System.out.println("\nYou are challenged by " + comp.name);
System.out.println(comp.name + " sent out " + comp.currentPokemon.name + "!");
System.out.println("Go! " + user.currentPokemon.name + "!");
System.out.println(battleScreen(user.currentPokemon, comp.currentPokemon));
}
//returns screen to display current battle status
public static String battleScreen(Pokemon userPokemon, Pokemon compPokemon) {
return String.format("""
____________________________________________________
| |
| %s lv.%d
| Hp: %d / %d
| |
| |
| |
| |
| %s lv.%d
| Hp: %d / %d
____________________________________________________
""", compPokemon.name, compPokemon.level, compPokemon.currentHp, compPokemon.hp,
userPokemon.name, userPokemon.level, userPokemon.currentHp, userPokemon.hp);
//compPokemon.gender, userPokemon.gender, //didn't display correctly, scraped legacy idea
}
//uses official pokemon damage formula to calculate battle damage
public static int calculateDamage(Pokemon attackingPokemon, Move move, Pokemon defendingPokemon) {
//Damage = (((((Level, 0.4 + 2), Base Power, (Attack/Defense)) / 50) + 2), Modifiers), and Random Number.
double baseDamage;
//Accuracy:
Random atkDmgRand = new Random();
int accuracy = atkDmgRand.nextInt(1, 101);
if (move.accuracy < accuracy) {
System.out.println(attackingPokemon.name + "'s attack missed!");
return 0;
}
//Phys/Special split. Uses different attack stats based on whether the move is a physical or a special move.
//Status moves deal no damage but have an effect instead
if (move.category.equals("Phys")) {
//physical move
baseDamage = ((((attackingPokemon.level * 0.4) + 2) * move.power * (attackingPokemon.atk / defendingPokemon.def)) / 50) + 2;
}
else if (move.category.equals("Spec")) {
//special move
baseDamage = ((((attackingPokemon.level * 0.4) + 2) * move.power * (attackingPokemon.spAtk / defendingPokemon.spDef)) / 50) + 2;
}
else {
//Status move
baseDamage = 0;
}
//System.out.println("Base damage after calculation: " + baseDamage);
//type effectiveness
double multiplier = 1;//multiplier we are going to multiply the moves damage with
//list of pokemon types
ArrayList<String> typesList = new ArrayList<>(Arrays.asList("Normal", "Fire", "Water", "Electric", "Grass",
"Ice", "Fighting", "Poison", "Ground", "Flying", "Psychic", "Bug", "Rock", "Ghost", "Dragon", "Dark", "Steel", "Fairy"));
//for each pokemon type
for (int i = 0; i < 18; i++) {
if (move.type.equals(typesList.get(i))) {
//multiply the damage by the type-on-type damage multiplyer. e.g Fire is 2x effective against grass, fire is 1/2 effective against water
multiplier = Double.parseDouble(defendingPokemon.weaknesses.get(i));
baseDamage *= multiplier;
}
}
//chooses relevant text to display when multiplier is not 1
if (multiplier == 2.0 || multiplier == 4.0) {
System.out.println("It's super effective!");
} else if (multiplier == 0.5 || multiplier == 0.25) {
System.out.println("It's not very effective...");
} else if (multiplier == 0.0) {
System.out.println("It doesn't effect " + defendingPokemon.name + "...");
}
//System.out.printf("The base damage after typings: %f\n", baseDamage);
//STAB - Same-Type Attack Bonus. If the pokemon's and moves type are the same, the move does 1.5x damage
if (move.type.equals(attackingPokemon.type.get(0)) || move.type.equals(attackingPokemon.type.get(1))) {
baseDamage *= 1.5;
}
//System.out.printf("The base damage after stab: %f\n", baseDamage);
//Adds randomly fluctuating battle damage
baseDamage *= atkDmgRand.nextDouble(0.85, 1.0000000000000001);
//System.out.printf("The base damage after fluctuation: %f\n", baseDamage);
//critical hits
if (atkDmgRand.nextInt(1, 17) == 1) {
baseDamage *= 1.5;//Gen 6 onwards formula
System.out.println("A critical hit!");
}
//Modifiers:
//System.out.println("The damage is: " + baseDamage);
//Math.floor(baseDamage)
//System.out.printf("The attacking pokemon is %s, with an attack of %f\n", attackingPokemon.name, attackingPokemon.atk);
//System.out.printf("The attacking pokemon is %s, with an attack of %f\n", defendingPokemon.name, defendingPokemon.def);
//System.out.println("The Damage is: " + baseDamage + "\n" + move.name + " has base damage: " + move.power);
return (int) Math.floor(baseDamage);
}
//displays move use, calculates the damage and applies it to defending pokemon
public static void battleAttack(Pokemon atkPokemon, Move atkMove, Pokemon defPokemon) {
//when the user has chosen a move instead of switching pokemon
if (atkMove != null) {
//prints the name of the move the user selected
System.out.println(atkPokemon.name + " used "+ atkMove.name + "!");
//calculate moves Damage
int damage = calculateDamage(atkPokemon, atkMove, defPokemon);
//Deal damage
defPokemon.currentHp -= damage;
//secondary move effects
Random secondaryRandom = new Random();
int secondaryEffectChance = secondaryRandom.nextInt(1, 101);
if (atkMove.secondaryChance < secondaryEffectChance) {
/*
Switch Statement
*/
}
}
}
//deals with actual fighting sequence, adds checks to ensure a fainted pokemon cannot attack
public static void battleTurn(Trainer user, Pokemon atkPokemon, Move atkMove, Trainer comp, Pokemon defPokemon, Move defMove, Boolean flipDisplay) {
//player's move
battleAttack(atkPokemon, atkMove, defPokemon);
faintedCheck(defPokemon);
//posts-move result. flipDisplay is used to ensure the user's pokemon is always displayed in the bottom right of the battleScreen.
if (flipDisplay) {
System.out.println(battleScreen(atkPokemon, defPokemon));
} else {
System.out.println(battleScreen(defPokemon, atkPokemon));
}
// if the defending pokemon has fainted, tell the user
if (defPokemon.hasFainted) {
if (flipDisplay) {
System.out.println("The foe's " + defPokemon.name + " fainted!");
comp.remainingPokemon -= 1;
compSwitchPokemon(user, comp);
} else {
System.out.println(defPokemon.name + " fainted!");
user.remainingPokemon -= 1;
//only switches pokemon if the user has a pokemon left to fight
if (user.remainingPokemon > 0) {
userSwitchPokemon(user);
}
}
}
//if the defending pokemon lives, he attacks. We then check if the other pokemon fainted from the attack
else {
battleAttack(defPokemon, defMove, atkPokemon);
faintedCheck(atkPokemon);
};
}
//checks to see if a pokemon has fainted. Sets hp to 0 so we don't have a negative health value.
public static void faintedCheck(Pokemon defPokemon) {
if (defPokemon.currentHp <= 0) {
defPokemon.currentHp = 0;//sets hp to 0 so it's not displaying a negative value
defPokemon.hasFainted = true;
}
}
//calculates battle order based on the pokemons speed. Also used to ensure the sys.outs are displayed in the correct order and under the right conditions.
public static void battleSequence(Trainer user, Pokemon userPokemon, Move userMove, Trainer comp, Pokemon compPokemon, Move compMove, int speedTie) {
//used to decide who attacks first.
int userPriority = 0;
int compPriority = 0;
if (userMove != null) {
userPriority = userMove.priority;
} else if (compMove != null) {
compPriority = compMove.priority;
}
//if the users move has priority over the computers
if (userPriority > compPriority) {
userAttacksFirst(user, userPokemon, userMove, comp, compPokemon, compMove);
}
//if the computers move has priority over the users
else if (userPriority < compPriority) {
compAttacksFirst(user, userPokemon, userMove, comp, compPokemon, compMove);
}
//if both moves have the same priority
else {
//if user's pokemon is faster
if (userPokemon.spd > compPokemon.spd) {
userAttacksFirst(user, userPokemon, userMove, comp, compPokemon, compMove);
}
//if computer's pokemon is faster
else if (userPokemon.spd < compPokemon.spd) {
compAttacksFirst(user, userPokemon, userMove, comp, compPokemon, compMove);
}
//speed tie, random who goes first
else {
//if the random number for deciding speed rolled 0, the user moves first
if (speedTie == 0) {
//player's attack first
userAttacksFirst(user, userPokemon, userMove, comp, compPokemon, compMove);
}
//if the random number for deciding speed rolled 1, the user computer first
else {
//computer attacks first
compAttacksFirst(user, userPokemon, userMove, comp, compPokemon, compMove);
}
}
}
}
//calls functions in correct order for the user attacking first
public static void userAttacksFirst(Trainer user, Pokemon userPokemon, Move userMove, Trainer comp, Pokemon compPokemon, Move compMove) {
//player's attack
battleTurn(user, userPokemon, userMove, comp, compPokemon, compMove, true);
//after the computer's attack, tells the user the result of the battle
if (userPokemon.hasFainted) {
System.out.println(battleScreen(userPokemon, compPokemon));
System.out.println(userPokemon.name + " fainted!");
user.remainingPokemon -= 1;
//only switches pokemon if the user has a pokemon left to fight
if (user.remainingPokemon > 0) {
userSwitchPokemon(user);
}
} else if (!compPokemon.hasFainted) {
System.out.println(battleScreen(userPokemon, compPokemon));
}
}
//calls functions in correct order for the computer attacking first
public static void compAttacksFirst(Trainer user, Pokemon userPokemon, Move userMove, Trainer comp, Pokemon compPokemon, Move compMove) {
//computer's attck
battleTurn(user, compPokemon, compMove, comp, userPokemon, userMove, false);
////after the players's attack, tells the user the result of the battle
if (compPokemon.hasFainted) {
System.out.println(battleScreen(userPokemon, compPokemon));
System.out.println("The foe's " + compPokemon.name + " fainted!");
comp.remainingPokemon -= 1;
compSwitchPokemon(user, comp);
} else if (!userPokemon.hasFainted && userMove != null) {
System.out.println(battleScreen(userPokemon, compPokemon));
}
}
//used to switch user's pokemon during battle
public static void userSwitchPokemon(Trainer user) {
System.out.println("Your team is: ");
for (int i = 0; i < user.team.size(); i++) {
if (user.team.get(i).currentHp == 0) {
System.out.println((i + 1) + ". " + user.team.get(i).name + " (Fainted!)");
}
else {
System.out.println((i + 1) + ". " + user.team.get(i).name);
}
}
Scanner switchScanner = new Scanner(System.in);
boolean accepted = false;
while (!accepted) {
System.out.print("Which Pokemon would you like to switch to?: ");
String option = switchScanner.nextLine();
if (option.equals("1") || option.equals("2") || option.equals("3") || option.equals("4") || option.equals("5") || option.equals("6")) {
if (user.team.get(Integer.parseInt(option) - 1).currentHp > 0) {
user.currentPokemon = user.team.get(Integer.parseInt(option) - 1);
accepted = true;
}
else {
System.out.println(user.team.get(Integer.parseInt(option) - 1).name + " can't battle!");
accepted = false;
}
}
}
//for better spacing in the terminal message
System.out.println();
}
//Computer switches pokemon
public static void compSwitchPokemon(Trainer user, Trainer comp) {
for (int i = 0; i < comp.team.size(); i++) {
//finds the index of the pokemon that fainted, and selects the next pokemon
if (comp.currentPokemon.name.equals(comp.team.get(i).name)) {
//prevents out of bounds error when team has all fainted
if (i != 5) {
comp.currentPokemon = comp.team.get(i + 1);
System.out.print(comp.name + " sent out " + comp.currentPokemon.name + "!\n");
System.out.print(battleScreen(user.currentPokemon, comp.currentPokemon));
break;
}
}
}
}
//decides which final message to print when the winner has been decided
public static void matchEnd(Trainer user, Trainer comp) {
if (user.remainingPokemon == 0) {
playerLost(user.prizeMoney);
} else {
//choses which trainer defeat message to print
switch(comp.name) {
case "Champion Cynthia" -> {cynthiaLost(comp.prizeMoney);}
case "Team Galactic Boss Cyrus" -> {cyrusLost(comp.prizeMoney);}
case "Champion Steven" -> {stevenLost(comp.prizeMoney);}
default -> {System.out.println("Congratulations, you won");}
}
}
}
//prints if the player defeated Cynthia
public static void cynthiaLost(int prizeMoney) {
//payout = level of last pokemon in opponent's party * base (Champion $200) https://bulbapedia.bulbagarden.net/wiki/Prize_money
System.out.println();
System.out.println("You have defeated Champion Cynthia");
System.out.println("...Just a few minutes ago, you were the most powerful challenger.");
System.out.println("And just now, you became the most powerful of all the Trainers.");
System.out.println("You are now our newest Champion!");
System.out.println("You got $" + prizeMoney + " for winning!");
System.out.println();
}
//prints if the player defeated Cyrus
public static void cyrusLost(int prizeMoney) {
//payout = level of last pokemon in opponent's party * base (Champion $200) https://bulbapedia.bulbagarden.net/wiki/Prize_money
System.out.println();
System.out.println("You have defeated Team Galactic Boss Cyrus");
System.out.println("Not after all the sacrifices we've made to get this far!");
System.out.println("What of my new world?!\nOf my new galaxy?!");
System.out.println("Was this all a dream to be swept away by your reality?!");
System.out.println("You got $" + prizeMoney + " for winning!");
System.out.println();
}
public static void stevenLost(int prizeMoney) {
System.out.println();
System.out.println("You have defeated Champion Steven");
System.out.println("Come to think of it, ever since our paths first crossed in Granite Cave in Dewford,\nI had this feeling.");
System.out.println("I thought that you would eventually become champion.\nMy predictions usually come true.");
System.out.println("And where will you go from here?");
System.out.println("... ... ... ... ...\n... ... ... ... ...");
System.out.println("Fufufu, even I couldn't tell you that.");
System.out.println("You got $" + prizeMoney + " for winning!");
System.out.println();
}
//prints if the player lost to the opponent
public static void playerLost(int prizeMoney) {
//Lost money = player's highest pokemon lvl * base (120 at 8 badges) https://bulbapedia.bulbagarden.net/wiki/Black_out
System.out.println();
System.out.println("You are out of usable Pokemon!");
System.out.println("You paid out $" + prizeMoney + " to the winner.");
System.out.println("... ... ... ...");
System.out.println("You blacked out!");
System.out.println();
}
}