-
Notifications
You must be signed in to change notification settings - Fork 0
/
Spells.java
681 lines (510 loc) · 26.1 KB
/
Spells.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
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
/********************************************************************
// Spells.java Author: Snubiss
//
// Date: November 12, 2018
// Modified: December 2, 2018
//
//
// Defines the instance data, constructors and associated
// methods for our game spells. The purpose of this class is to catalogue
// our games spell data for our player's to use. If you want to
// add another spell then you would add it here.
//
// Modifications since Phase II: Added slap ability to cheat detection.
//
//********************************************************************/
/* SPELL ID's
1 - Slap - Cheater Move
2 - Attack
3 - Slash
4 - Kick
5 - Heal (Special)
6 - Staff
7 - Fireball
8 - Curse
9 - Claw
10 - Wand
11 - Slam (Special)
*/
package Rastellini2;
public class Spells {
public Spells(){
}
private static int rng(int minnum, int maxnum){
int randomnumber = (int)(Math.random()*(maxnum+1-minnum))+ minnum;
return randomnumber;
}
// Spell Name list.
public static String getSpellName(int spellID){
// Create a string placeholder
String temp = "";
switch(spellID){
case 1: temp = "Slap";
break;
case 2: temp = "Attack";
break;
case 3: temp = "Slash";
break;
case 4: temp = "Kick";
break;
case 5: temp = "Heal";
break;
case 6: temp = "Staff";
break;
case 7: temp = "Fireball";
break;
case 8: temp = "Curse";
break;
case 9: temp = "Claw";
break;
case 10: temp = "Wand";
break;
case 11: temp = "Slam";
break;
}
return temp;
}
public void cast(Graphics display, Player player, Player enemy, int spellID) throws InterruptedException{
// Clear our combat messages before we cast spells.
display.clearCombat();
// If our player's attack was a successful or our user casted a special.
if(player.attackCheck(player) || spellID == player.specialAbility){
// Animate our player.
display.setAnimate(display, player, player.getPlayerNumber());
// Cast our spell based on our spell ID.
switch(spellID){
case 1: this.slap(display, player, enemy);
break;
case 2: this.attack(display, player, enemy);
break;
case 3: this.slash(display, player, enemy);
break;
case 4: this.kick(display, player, enemy);
break;
case 5: this.heal(display, player, enemy);
break;
case 6: this.staff(display, player, enemy);
break;
case 7: this.fireball(display, player, enemy);
break;
case 8: this.curse(display, player, enemy);
break;
case 9: this.claw(display, player, enemy);
break;
case 10: this.wand(display, player, enemy);
break;
case 11: this.slam(display, player, enemy);
break;
}
}
else{
display.setCombat(" " + player.getName() + " MISSED!",0);
player.setPlayerTurn(false);
enemy.setPlayerTurn(true);
}
}
// SPELL ID # 1
public void slap(Graphics display, Player player, Player enemy){
// Generate some fresh damage for our attack.
player.setDamage(rng((player.getMainStat()*9)/10, ((player.getMainStat()*11)/10)));
boolean crit = player.critCheck(player);
if (crit){
// Double our players damage
player.setDamage(player.getDamage() * 2);
// Set our dialogue on screen to show we scored a critical strike.
display.setCombat("CRITICAL STRIKE!!",3);
}
// Subtract players damage from the enemy
enemy.setHitPoints(enemy.getHitPoints() - player.getDamage());
// Generate a random number for our players dialogue.
int Dialogue = rng(1,1);
// Decide what our players dialogue response is.
switch(Dialogue){
case 1: display.setDialogue(display, player.getName() + " slaps " + enemy.getName() + " like a cheater for " + player.getDamage() + " damage!");
break;
default: display.setDialogue(display, player.getName() + " slaps " + enemy.getName() + " like a cheater for " + player.getDamage() + " damage!");
break;
}
// Remove our crit modifier if we scored a critical strike
if (crit){
int digTemp = player.getDamage();
player.setDamage(digTemp /= 2);
}
// Set player turns after successful attack.
player.setPlayerTurn(false);
enemy.setPlayerTurn(true);
// Refresh our players stats to the screen.
display.refreshPlayer(player,player.getPlayerNumber());
display.refreshPlayer(enemy,enemy.getPlayerNumber());
}// End Attack
// SPELL ID # 2
public void attack(Graphics display, Player player, Player enemy){
// Generate some fresh damage for our attack.
player.setDamage(rng((player.getMainStat()*9)/10, ((player.getMainStat()*11)/10)));
boolean crit = player.critCheck(player);
if (crit){
// Double our players damage
player.setDamage(player.getDamage() * 2);
// Set our dialogue on screen to show we scored a critical strike.
display.setCombat("CRITICAL STRIKE!!",3);
}
// Subtract players damage from the enemy
enemy.setHitPoints(enemy.getHitPoints() - player.getDamage());
// Generate a random number for our players dialogue.
int Dialogue = rng(1,4);
// Decide what our players dialogue response is.
switch(Dialogue){
case 1: display.setDialogue(display, "BAM! " + player.getName() + " gorilla gunked " + enemy.getName() + " for " + player.getDamage() + " damage!");
break;
case 2: display.setDialogue(display, player.getName() + " punched " + enemy.getName() + " square in the face for " + player.getDamage() + " damage. Ouch!");
break;
case 3: display.setDialogue(display, player.getName() + " savagely attacks " + enemy.getName() + " for " + player.getDamage() + " damage!");
break;
default: display.setDialogue(display, player.getName() + " unleashes some move called \"The Tennessee Twizzler\" for " + player.getDamage() + " damage.");
break;
}
// Remove our crit modifier if we scored a critical strike
if (crit){
int digTemp = player.getDamage();
player.setDamage(digTemp /= 2);
}
// Set player turns after successful attack.
player.setPlayerTurn(false);
enemy.setPlayerTurn(true);
// Refresh our players stats to the screen.
display.refreshPlayer(player,player.getPlayerNumber());
display.refreshPlayer(enemy,enemy.getPlayerNumber());
}// End Attack
// SPELL ID # 3
public void slash(Graphics display, Player player, Player enemy){
// Generate some fresh damage for our attack.
player.setDamage(rng((player.getMainStat()*9)/10, ((player.getMainStat()*11)/10)));
boolean crit = player.critCheck(player);
if (crit){
// Double our players damage
player.setDamage(player.getDamage() * 2);
// Set our dialogue on screen to show we scored a critical strike.
display.setCombat("CRITICAL STRIKE!!",3);
}
// Subtract players damage from the enemy
enemy.setHitPoints(enemy.getHitPoints() - player.getDamage());
// Generate a random number for our players dialogue.
int Dialogue = rng(1,4);
// Decide what our players dialogue response is.
switch(Dialogue){
case 1: display.setDialogue(display, player.getName() + " slashes violently at " + enemy.getName() + " for " + player.getDamage() + " damage.");
break;
case 2: display.setDialogue(display, "With a deathly look in his eye. " + player.getName() + " slashes at " + enemy.getName() + " for " + player.getDamage() + " damage.");
break;
default: display.setDialogue(display, enemy.getName() + " cries out in pain as " + player.getName() + " slash's him for " + player.getDamage() + " damage.");
break;
}
// Remove our crit modifier if we scored a critical strike
if (crit){
int digTemp = player.getDamage();
player.setDamage(digTemp /= 2);
}
// Set player turns after successful attack.
player.setPlayerTurn(false);
enemy.setPlayerTurn(true);
// Refresh our players stats to the screen.
display.refreshPlayer(player,player.getPlayerNumber());
display.refreshPlayer(enemy,enemy.getPlayerNumber());
}// End Slash
// SPELL ID # 4
public void kick(Graphics display, Player player, Player enemy){
// Generate some fresh damage for our attack.
player.setDamage(rng((player.getMainStat()*9)/10, ((player.getMainStat()*11)/10)));
boolean crit = player.critCheck(player);
if (crit){
// Double our players damage
player.setDamage(player.getDamage() * 2);
// Set our dialogue on screen to show we scored a critical strike.
display.setCombat("CRITICAL STRIKE!!",3);
}
// Subtract players damage from the enemy
enemy.setHitPoints(enemy.getHitPoints() - player.getDamage());
// Generate a random number for our players dialogue.
int Dialogue = rng(1,4);
// Decide what our players dialogue response is.
switch(Dialogue){
case 1: display.setDialogue(display, player.getName() + "'s shoe flew off while trying to kick " + enemy.getName() + " but struck him anyway for " + player.getDamage() + ". ");
break;
case 2: display.setDialogue(display, player.getName() +" kicked " + enemy.getName() + " in the shin for " + player.getDamage() + " damage!");
break;
default: display.setDialogue(display, enemy.getName() + " cries out in pain as " + player.getName() + " slash's him for " + player.getDamage() + " damage.");
break;
}
// Remove our crit modifier if we scored a critical strike
if (crit){
int digTemp = player.getDamage();
player.setDamage(digTemp /= 2);
}
// Set player turns after successful attack.
player.setPlayerTurn(false);
enemy.setPlayerTurn(true);
// Refresh our players stats to the screen.
display.refreshPlayer(player,player.getPlayerNumber());
display.refreshPlayer(enemy,enemy.getPlayerNumber());
}// End Kick
// SPELL ID # 5 -- SPECIAL ABILITY
public void heal(Graphics display, Player player, Player enemy){
//************************* Healing ****************************//
if(player.getSpecialCount() <= 0){
display.setDialogue(display, player.getName() + " is out of Heals. Only 3 allowed per round !!");
}else{
// Generate a number to give our healing potion that scales base on level.
int heal = rng(100,150) + (player.getLevel()*20);
// Catch any overhealing so we dont go over our max health.
if ((player.getHitPoints()+heal) > player.getMaxHealth()){
heal = player.getMaxHealth() - player.getHitPoints();
}
// Add the potion effect to the players health
player.setHitPoints(player.getHitPoints() + heal);
// Generate a random number for our players dialogue.
int Dialogue = rng(1,4);
// Decide what our players dialogue response is.
switch(Dialogue){
// Update our dialogue to let user know they used a heal potion.
case 1: display.setDialogue(display, player.getName() + " beams with light as he heals for " + heal + " health!");
break;
case 2: display.setDialogue(display, "Light surrounds " + player.getName() + " as he heals for " + heal + ".");
break;
default: display.setDialogue(display, "Light surrounds " + player.getName() + " as he heals for " + heal + ".");
break;
}
// Remove a an item from the players quantity.
player.setSpecialCount((player.getSpecialCount()) - 1);
// Set player turns after successful attack.
player.setPlayerTurn(false);
enemy.setPlayerTurn(true);
// Refresh our players stats to the screen.
display.refreshPlayer(player,player.getPlayerNumber());
display.refreshPlayer(enemy,enemy.getPlayerNumber());
}
}
// SPELL ID # 6
public void staff(Graphics display, Player player, Player enemy){
// Generate some fresh damage for our attack.
player.setDamage(rng((player.getMainStat()*9)/10, ((player.getMainStat()*11)/10)));
boolean crit = player.critCheck(player);
if (crit){
// Double our players damage
player.setDamage(player.getDamage() * 2);
// Set our dialogue on screen to show we scored a critical strike.
display.setCombat("CRITICAL STRIKE!!",3);
}
// Subtract players damage from the enemy
enemy.setHitPoints(enemy.getHitPoints() - player.getDamage());
// Generate a random number for our players dialogue.
int Dialogue = rng(1,4);
// Decide what our players dialogue response is.
switch(Dialogue){
case 1: display.setDialogue(display, "BAM! " + player.getName() + " gorilla gunked " + enemy.getName() + " for " + player.getDamage() + " damage!");
break;
case 2: display.setDialogue(display, player.getName() + " staffs " + enemy.getName() + " square in the face for " + player.getDamage() + " damage. Ouch!");
break;
case 3: display.setDialogue(display, player.getName() + " swings around his staff like a madman and attacks " + enemy.getName() + " for " + player.getDamage() + " damage!");
break;
case 4: display.setDialogue(display, player.getName() + " slams his staff into " + enemy.getName() + "'s toe for " + player.getDamage() + " damage!");
break;
default: display.setDialogue(display, player.getName() + " slams his staff into " + enemy.getName() + "'s toe for " + player.getDamage() + " damage!");
break;
}
if (crit){
int digTemp = player.getDamage();
player.setDamage(digTemp /= 2);
}
// Set player turns after successful attack.
player.setPlayerTurn(false);
enemy.setPlayerTurn(true);
// Refresh our players stats to the screen.
display.refreshPlayer(player,player.getPlayerNumber());
display.refreshPlayer(enemy,enemy.getPlayerNumber());
}// End Staff
// SPELL ID # 7
public void fireball(Graphics display, Player player, Player enemy){
// Generate some fresh damage for our attack.
player.setDamage(rng((player.getMainStat()*9)/10, ((player.getMainStat()*11)/10)));
boolean crit = player.critCheck(player);
if (crit){
// Double our players damage
player.setDamage(player.getDamage() * 2);
// Set our dialogue on screen to show we scored a critical strike.
display.setCombat("CRITICAL STRIKE!!",3);
}
// Subtract players damage from the enemy
enemy.setHitPoints(enemy.getHitPoints() - player.getDamage());
// Generate a random number for our players dialogue.
int Dialogue = rng(1,4);
// Decide what our players dialogue response is.
switch(Dialogue){
case 1: display.setDialogue(display, player.getName() + " slowly gathers energy from around him before casting a flame nova at " + enemy.getName() + " for " + player.getDamage() + " damage!");
break;
case 2: display.setDialogue(display, player.getName() + " launches an explosive fireball at " + enemy.getName() + " for " + player.getDamage() + " damage.");
break;
case 3: display.setDialogue(display, player.getName() + " introduced his balls of fire to " + enemy.getName() + "'s face for " + player.getDamage() + " damage.");
break;
default: display.setDialogue(display, player.getName() + " introduced his balls of fire to " + enemy.getName() + "'s face for " + player.getDamage() + " damage.");
break;
}
// Remove our crit modifier if we scored a critical strike
if (crit){
int digTemp = player.getDamage();
player.setDamage(digTemp /= 2);
}
// Set player turns after successful attack.
player.setPlayerTurn(false);
enemy.setPlayerTurn(true);
// Refresh our players stats to the screen.
display.refreshPlayer(player,player.getPlayerNumber());
display.refreshPlayer(enemy,enemy.getPlayerNumber());
}// End Fireball
// SPELL ID # 8
public void curse(Graphics display, Player player, Player enemy){
// Generate some fresh damage for our attack.
player.setDamage(rng((player.getMainStat()*9)/10, ((player.getMainStat()*11)/10)));
boolean crit = player.critCheck(player);
if (crit){
// Double our players damage
player.setDamage(player.getDamage() * 2);
// Set our dialogue on screen to show we scored a critical strike.
display.setCombat("CRITICAL STRIKE!!",3);
}
// Subtract players damage from the enemy
enemy.setHitPoints(enemy.getHitPoints() - player.getDamage());
// Generate a random number for our players dialogue.
int Dialogue = rng(1,4);
// Decide what our players dialogue response is.
switch(Dialogue){
case 1: display.setDialogue(display, player.getName() + " launches a sickening curse at " + enemy.getName() + "'s face for " + player.getDamage() + " damage.");
break;
case 2: display.setDialogue(display, player.getName() + " mumbles something at " + enemy.getName() + " and hits him for " + player.getDamage() + " damage.");
break;
default: display.setDialogue(display, player.getName() + " mumbles something at " + enemy.getName() + " and hits him for " + player.getDamage() + " damage.");
break;
}
if (crit){
int digTemp = player.getDamage();
player.setDamage(digTemp /= 2);
}
// Set player turns after successful attack.
player.setPlayerTurn(false);
enemy.setPlayerTurn(true);
// Refresh our players stats to the screen.
display.refreshPlayer(player,player.getPlayerNumber());
display.refreshPlayer(enemy,enemy.getPlayerNumber());
}// End Curse
// SPELL ID # 9
public void claw(Graphics display, Player player, Player enemy){
// Generate some fresh damage for our attack.
player.setDamage(rng((player.getMainStat()*9)/10, ((player.getMainStat()*11)/10)));
boolean crit = player.critCheck(player);
if (crit){
// Double our players damage
player.setDamage(player.getDamage() * 2);
// Set our dialogue on screen to show we scored a critical strike.
display.setCombat("CRITICAL STRIKE!!",3);
}
// Subtract players damage from the enemy
enemy.setHitPoints(enemy.getHitPoints() - player.getDamage());
// Generate a random number for our players dialogue.
int Dialogue = rng(1,4);
// Decide what our players dialogue response is.
switch(Dialogue){
case 1: display.setDialogue(display, player.getName() + " claws at his opponent for " + player.getDamage() + " damage!");
break;
default: display.setDialogue(display, player.getName() + " claws at his opponent for " + player.getDamage() + " damage!");
break;
}
// Remove our crit modifier if we scored a critical strike
if (crit){
int digTemp = player.getDamage();
player.setDamage(digTemp /= 2);
}
// Set player turns after successful attack.
player.setPlayerTurn(false);
enemy.setPlayerTurn(true);
// Refresh our players stats to the screen.
display.refreshPlayer(player,player.getPlayerNumber());
display.refreshPlayer(enemy,enemy.getPlayerNumber());
}// End Claw
// SPELL ID # 10
public void wand(Graphics display, Player player, Player enemy){
// Generate some fresh damage for our attack.
player.setDamage(rng((player.getMainStat()*9)/10, ((player.getMainStat()*11)/10)));
boolean crit = player.critCheck(player);
if (crit){
// Double our players damage
player.setDamage(player.getDamage() * 2);
// Set our dialogue on screen to show we scored a critical strike.
display.setCombat("CRITICAL STRIKE!!",4);
}
// Subtract players damage from the enemy
enemy.setHitPoints(enemy.getHitPoints() - player.getDamage());
// Generate a random number for our players dialogue.
int Dialogue = rng(1,4);
// Decide what our players dialogue response is.
switch(Dialogue){
case 1: display.setDialogue(display, player.getName() + " wands her opponent for " + player.getDamage() + " damage!");
break;
case 2: display.setDialogue(display, "Sparks erupt from " + player.getName() + "'s wand as she strikes down " + enemy.getName() + " for " + player.getDamage() + " damage!");
break;
case 3: display.setDialogue(display, "With a sudden flash of light, " + player.getName() + " wands " + enemy.getName() + " for " + player.getDamage() + " damage!");
break;
case 4: display.setDialogue(display, player.getName() + " raises her wand to strike but pauses, then runs up and smacks " + enemy.getName() + " in the face for " + player.getDamage() + " damage!");
break;
default: display.setDialogue(display, player.getName() + " claws at his opponent for " + player.getDamage() + " damage!");
break;
}
// Remove our crit modifier if we scored a critical strike
if (crit){
int digTemp = player.getDamage();
player.setDamage(digTemp /= 2);
}
// Set player turns after successful attack.
player.setPlayerTurn(false);
enemy.setPlayerTurn(true);
// Refresh our players stats to the screen.
display.refreshPlayer(player,player.getPlayerNumber());
display.refreshPlayer(enemy,enemy.getPlayerNumber());
}// End Wand
// SPELL ID # 11
public void slam(Graphics display, Player player, Player enemy){
// Slam damage increase. Percentage based.
final double SLAM_INCREASE = 2.2;
// Generate some fresh damage for our attack.
player.setDamage((int) (rng((player.getMainStat()*9)/10, ((player.getMainStat()*11)/10)) * SLAM_INCREASE));
boolean crit = player.critCheck(player);
if (crit){
// Double our players damage
player.setDamage(player.getDamage() * 2);
// Set our dialogue on screen to show we scored a critical strike.
display.setCombat("CRITICAL STRIKE!!",3);
}
// Subtract players damage from the enemy
enemy.setHitPoints(enemy.getHitPoints() - player.getDamage());
// Generate a random number for our players dialogue.
int Dialogue = rng(1,2);
// Decide what our players dialogue response is.
switch(Dialogue){
case 1: display.setDialogue(display, player.getName() + " SLAMMED " + enemy.getName() + " for " + player.getDamage() + " damage.");
break;
default: display.setDialogue(display, player.getName() + " SLAMMED " + enemy.getName() + " for " + player.getDamage() + " damage.");
break;
}
// Remove our crit modifier if we scored a critical strike
if (crit){
int digTemp = player.getDamage();
player.setDamage(digTemp /= 2);
}
// Remove a an item from the players quantity.
player.setSpecialCount((player.getSpecialCount()) - 1);
// Set player turns after successful attack.
player.setPlayerTurn(false);
enemy.setPlayerTurn(true);
// Refresh our players stats to the screen.
display.refreshPlayer(player,player.getPlayerNumber());
display.refreshPlayer(enemy,enemy.getPlayerNumber());
}// End Slam
}