-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
1590 lines (1466 loc) · 67.4 KB
/
main.cpp
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
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <iostream>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <stdio.h>
#include <memory>
#include <algorithm>
using namespace std;
#include "Unit.h"
class Hero : public Unit {
protected:
int deathBlowResist;
public:
Hero() {}
void attack() {
}
void dying() {
if (hp == 0) {
int randomNumber = rand() % 101;
if (deathBlowResist >= randomNumber) {
cout << "Hero " << name << " didn't die this time." << endl;
}
else {
alive = false;
cout << "Hero " << name << " died." << endl;
//hero olur karakter dummy olarak atanir.
}
}
}
};
class Crusader : public Hero {
public:
Crusader(string na, int pst) {
name = na;
type = "Crusader";
position = pst;
maxHp = 33;
hp = 33;
dodge = 5;
prot = 0;
speed = 1;
temporalSpeed = 1;
accMod = 0;
baseCrit = 3;
minDmg = 6;
maxDmg = 12;
deathBlowResist = 67;
stunResist = 40;
}
};
class Vestal : public Hero {
public:
Vestal(string na, int pst) :Hero() {
name = na;
type = "Vestal";
position = pst;
maxHp = 24;
hp = 24;
dodge = 0;
prot = 0;
speed = 4;
temporalSpeed = 4;
accMod = 0;
baseCrit = 1;
minDmg = 4;
maxDmg = 8;
deathBlowResist = 77;
stunResist = 30;
}
};
class Monster : public Unit {
protected:
Monster() {}
void dying() {
alive = false;
cout << "Monster " << name << " died." << endl;
}
};
class Bone_Soldier : public Monster {
public:
Bone_Soldier(string na, int pst) :Monster() {
name = na;
type = "Bone Soldier";
position = pst;
maxHp = 10;
hp = 10;
dodge = 10;
prot = 15;
speed = 2;
temporalSpeed = 2;
accMod = 0;
baseCrit = 0;
minDmg = 3;
maxDmg = 8;
stunResist = 25;
}
};
class Bone_Defender :public Monster {
public:
Bone_Defender(string na, int pst) :Monster() {
name = na;
type = "Bone Defender";
position = pst;
maxHp = 22;
hp = 22;
dodge = 8;
prot = 45;
speed = 1;
temporalSpeed = 1;
accMod = 0;
baseCrit = 0;
minDmg = 2;
maxDmg = 4;
stunResist = 45;
}
};
class StunSkill {
protected:
StunSkill() {}
};
class Skill {
protected:
int position;
int target;
public:
};
class MoveSkill : public Skill {
public:
MoveSkill() {}
static void Move_Skill_Forward1(const shared_ptr<Unit>& Forward1) {
Forward1->setPosition((Forward1->getPosition()) - 1);
cout << Forward1->getName() << " moves 1 step forward!" << endl;
}
static void Move_Skill_Backward1(const shared_ptr<Unit>& Backward1) {
Backward1->setPosition((Backward1->getPosition()) + 1);
cout << Backward1->getName() << " moves 1 step backward!" << endl;
}
};
bool comparatorHero(const shared_ptr<Hero>& lhs, const shared_ptr<Hero>& rhs) {
return lhs->getPosition() < rhs->getPosition();
}
bool comparatorMonster(const shared_ptr<Monster>& lhs, const shared_ptr<Monster>& rhs) {
return lhs->getPosition() < rhs->getPosition();
}
class AttackSkill : public Skill {
protected:
int dmgMod;
int baseAcc;
double critMod;
int stunEffect;
int stunBase;
public:
AttackSkill() {}
void attackFunc(shared_ptr<Unit> attacker, shared_ptr<Unit> defender) {
int randomNumber = rand() % 101;
int hitChange = baseAcc + attacker->getAccMod() - defender->getDodge();
if (hitChange >= randomNumber) { // saldirir ve crit hesaplamasi yapilir
double criticalChance = attacker->getBaseCrit() + critMod;
randomNumber = rand() % 101;
if (criticalChance >= randomNumber) { // crit vurur
double critHit = attacker->getMaxDmg() * 1.5;
cout << attacker->getName() << ", CRIT damage : " << critHit << endl;
defender->getDamage(critHit);
int stunChange = 20 + stunBase - defender->getStunResist();
randomNumber = rand() % 101;
if (randomNumber <= stunChange && stunEffect == 1) {
defender->setStun(true);
cout << defender->getName() << " stunned." << endl;
}
else {
// stun yemez
}
}
else {
double dmg = rand() % (attacker->getMaxDmg() - attacker->getMinDmg()) + attacker->getMinDmg();
double rawDmg = dmg * (100 + dmgMod) / 100.0;
double actualDmg = rawDmg - rawDmg * (defender->getProt() / 100.0);
cout << attacker->getName() << ", NORMAL damage : " << actualDmg << endl;
defender->getDamage(actualDmg);
int stunChange = stunBase - defender->getStunResist();
randomNumber = rand() % 101;
if (randomNumber <= stunChange && stunEffect == 1) {
defender->setStun(true);
cout << defender->getName() << " stunned." << endl;
}
else {
// stun yemez
}
} // normal vurur
}
else {
cout << attacker->getName() << " missed the Hit!" << endl; // missing
}
cout << defender->getName() << "(Hp : " << defender->getHp() << ")" << endl;
// return defender->getHp();
}
};
class Smite : public AttackSkill {
public:
Smite() {
dmgMod = 0;
baseAcc = 85;
critMod = 0;
stunEffect = 0;
}
void attack(shared_ptr<Unit> attacker, vector<shared_ptr<Monster>> &defender) {
int target;
cout << "Smite Selected!" << endl;
cout << "Select a target to attack!" << endl;
cout << "1-" << defender[0]->getName() << "(Hp : " << defender[0]->getHp() << ")" << endl;
cout << "2-" << defender[1]->getName() << "(Hp : " << defender[1]->getHp() << ")" << endl;
cout << "Number of Target : ";
cin >> target;
cout << endl;
if (target != 1 && target != 2) {
cout
<< "Number of Target selected 1 automatically because your selection is not an option! "
<< endl;
target = 1;
}
if (defender[target - 1]->isAlive() == false) {
cout << "Selected target is dead !" << endl;
for (int t = 0; t < 2; t++) {
if (defender[t]->isAlive() == true) {
target = t + 1;
cout << defender[t]->getName() << " is selected as a target." << endl;
break;
}
}
}
if (defender[0]->isAlive() == true || defender[1]->isAlive() == true) {
cout << "Using Smite on " << defender[target - 1]->getName() << "(Hp : "
<< defender[target - 1]->getHp() << ")" << endl;
attackFunc(attacker, defender[target - 1]);
}
else {
cout << "There is no living target you can attack , end of your turn !" << endl;
}
}
};
class Stunning_Blow : public AttackSkill, public StunSkill {
public:
Stunning_Blow() {
dmgMod = -50;
baseAcc = 90;
critMod = 0;
stunBase = 100;
stunEffect = 1;
}
void attack(shared_ptr<Unit> attacker, vector<shared_ptr<Monster>> &defender) {
int target;
cout << "Stunning Blow Selected!" << endl;
cout << "Select a target to attack!" << endl;
cout << "1-" << defender[0]->getName() << "(Hp : " << defender[0]->getHp() << ")" << endl;
cout << "2-" << defender[1]->getName() << "(Hp : " << defender[1]->getHp() << ")" << endl;
cout << "Number of Target : ";
cin >> target;
cout << endl;
if (target != 1 && target != 2) {
cout
<< "Number of Target selected 1 automatically because your selection is not an option! "
<< endl;
target = 1;
}
if (defender[target - 1]->isAlive() == false) {
cout << "Selected target is dead !" << endl;
for (int t = 0; t < 2; t++) {
if (defender[t]->isAlive() == true) {
target = t + 1;
cout << defender[t]->getName() << " is selected as a target." << endl;
break;
}
}
}
if (defender[0]->isAlive() == true || defender[1]->isAlive() == true) {
cout << "Using Stunning Blow on " << defender[target - 1]->getName() << "(Hp : "
<< defender[target - 1]->getHp() << ")" << endl;
attackFunc(attacker, defender[target - 1]);
}
else {
cout << "There is no living target you can attack , end of your turn !" << endl;
}
}
};
class Holy_Lance : public AttackSkill, public MoveSkill {
public:
Holy_Lance() {
dmgMod = 0;
baseAcc = 85;
critMod = 6.5;
stunEffect = 0;
}
void attack(shared_ptr<Unit> attacker, vector<shared_ptr<Monster>> &defender, vector<shared_ptr<Hero>> &allies) {
int target;
cout << "Holy Lance selected!" << endl;
cout << "Select a target to attack!" << endl;
cout << "2-" << defender[1]->getName() << "(Hp : " << defender[1]->getHp() << ")" << endl;
cout << "3-" << defender[2]->getName() << "(Hp : " << defender[2]->getHp() << ")" << endl;
cout << "4-" << defender[3]->getName() << "(Hp : " << defender[3]->getHp() << ")" << endl;
cout << "Number of Target : ";
cin >> target;
cout << endl;
if (target != 2 && target != 3 && target != 4) {
cout
<< "Number of Target selected 2 automatically because your selection is not an option! "
<< endl;
target = 2;
}
if (defender[target - 1]->isAlive() == false) {
cout << "Selected target is dead !" << endl;
for (int t = 1; t < 4; t++) {
if (defender[t]->isAlive() == true) {
target = t + 1;
cout << defender[t]->getName() << " is selected as a target." << endl;
break;
}
}
}
if (defender[2]->isAlive() == true || defender[1]->isAlive() == true || defender[3]->isAlive() == true) {
cout << "Using Holy Lance to attack to " << defender[target - 1]->getName()
<< "(Hp : " << defender[target - 1]->getHp() << ")" << endl;
attackFunc(attacker, defender[target - 1]);
cout << defender[target - 1]->getName() << "(Hp : " << defender[target - 1]->getHp() << ")" << endl;
for (int j = 0; j <= 3; j++) {
if (attacker->getPosition() == allies[j]->getPosition()) {
MoveSkill::Move_Skill_Forward1(allies[j]);
MoveSkill::Move_Skill_Backward1(allies[j - 1]);
}
}
sort(allies.begin(), allies.end(), &comparatorHero);
}
else {
cout << "There is no living target you can attack , end of your turn !" << endl;
}
}
};
class Mace_Bash : public AttackSkill {
public:
Mace_Bash() {
dmgMod = 0;
baseAcc = 85;
critMod = 0;
stunEffect = 0;
}
void attack(shared_ptr<Unit> attacker, vector<shared_ptr<Monster>> &defenders) {
int target;
cout << "Mace Bash Selected!" << endl;
cout << "Select a target to attack!" << endl;
cout << "1-" << defenders[0]->getName() << "(Hp : " << defenders[0]->getHp() << ")" << endl;
cout << "2-" << defenders[1]->getName() << "(Hp : " << defenders[1]->getHp() << ")" << endl;
cout << "Number of Target : ";
cin >> target;
cout << endl;
if (target != 1 && target != 2) {
cout << "Number of Target selected 1 automatically because your selection is not an option! " << endl;
target = 1;
}
if (defenders[target - 1]->isAlive() == false) {
cout << "Selected target is dead !" << endl;
for (int t = 0; t < 2; t++) {
if (defenders[t]->isAlive() == true) {
target = t + 1;
cout << defenders[t]->getName() << " is selected as a target." << endl;
break;
}
}
}
if (defenders[0]->isAlive() == true || defenders[1]->isAlive() == true) {
cout << "Using Mace Bash to attack to " << defenders[target - 1]->getName() << "(Hp : "
<< defenders[target - 1]->getHp() << ")" << endl;
attackFunc(attacker, defenders[target - 1]);
}
else {
cout << "There is no living target you can attack , end of your turn !" << endl;
}
}
};
class Dazzling_Light : public AttackSkill, public StunSkill {
public:
Dazzling_Light() {
dmgMod = -75;
baseAcc = 90;
critMod = 5;
stunBase = 100;
stunEffect = 1;
}
void attack(shared_ptr<Unit> attacker, vector<shared_ptr<Monster>> &defenders) {
int target;
cout << "Dazzling Light Selected!" << endl;
cout << "Select a target to attack!" << endl;
cout << "1-" << defenders[0]->getName() << "(Hp : " << defenders[0]->getHp() << ")" << endl;
cout << "2-" << defenders[1]->getName() << "(Hp : " << defenders[1]->getHp() << ")" << endl;
cout << "3-" << defenders[2]->getName() << "(Hp : " << defenders[2]->getHp() << ")" << endl;
cout << "Number of Target : ";
cin >> target;
cout << endl;
if (target != 1 && target != 2 && target != 3) {
cout << "Number of Target selected 1 automatically because your selection is not an option! "<< endl;
target = 1;
}
if (defenders[target - 1]->isAlive() == false) {
cout << "Selected target is dead !" << endl;
for (int t = 0; t < 3; t++) {
if (defenders[t]->isAlive() == true) {
target = t + 1;
cout << defenders[t]->getName() << " is selected as a target." << endl;
break;
}
}
}
if (defenders[0]->isAlive() == true || defenders[1]->isAlive() == true || defenders[2]->isAlive() == true) {
cout << "Using Dazzling Light to attack to " << defenders[target - 1]->getName() << "(Hp : "
<< defenders[target - 1]->getHp() << ")" << endl;
attackFunc(attacker, defenders[target - 1]);
}
else {
cout << "There is no living target you can attack , end of your turn !" << endl;
}
}
};
class Graveyard_Slash : public AttackSkill {
public:
Graveyard_Slash() {
dmgMod = 0;
baseAcc = 85;
critMod = 6;
stunEffect = 0;
}
void attack(shared_ptr<Unit> attacker, vector<shared_ptr<Hero>> &defenders) {
int target = rand() % 3 + 1;
cout << attacker->getName() << " is selected Graveyard Slash to attack to " <<defenders[4 - target]->getName() << endl;
if (defenders[target - 1]->isAlive() == false) {
for (int t = 0; t < 2; t++) {
if (defenders[t]->isAlive() == true) {
target = t + 1;
cout << defenders[t]->getName() << " is selected as a target." << endl;
break;
}
}
}
if (defenders[0]->isAlive() == true || defenders[1]->isAlive() == true || defenders[2]->isAlive() == true) {
cout << "Using Graveyard Slash to attack to " << defenders[4 - target]->getName() << "(Hp : "
<< defenders[4 - target]->getHp() << ")" << endl;
attackFunc(attacker, defenders[4 - target]);
}
else {
cout << "There is no target to attack. " << endl;
}
}
};
class Graveyard_Stumble : public AttackSkill, public MoveSkill {
public:
Graveyard_Stumble() {
dmgMod = -50;
baseAcc = 45;
critMod = 0;
stunEffect = 0;
}
void attack(shared_ptr<Unit> attacker, vector<shared_ptr<Hero>> &defenders) {
int target = rand() % 2 + 1;
cout << attacker->getName() << " is selected Graveyard Stumble to attack to " <<defenders[4 - target]->getName() << endl;
if (defenders[target - 1]->isAlive() == false) {
for (int t = 0; t < 1; t++) {
if (defenders[t]->isAlive() == true) {
target = t + 1;
cout << defenders[t]->getName() << " is selected as a target." << endl;
break;
}
}
}
if (defenders[0]->isAlive() == true || defenders[1]->isAlive() == true) {
cout << "Using Graveyard Stumble to attack to " << defenders[4 - target]->getName() << "(Hp : "
<< defenders[4 - target]->getHp() << ")" << endl;
attackFunc(attacker, defenders[4 - target]);
}
else {
cout << "There is no target to attack. " << endl;
}
}
};
class Axeblade : public AttackSkill {
public:
Axeblade() {
dmgMod = 0;
baseAcc = 72;
critMod = 6;
stunEffect = 0;
}
void attack(shared_ptr<Unit> attacker, vector<shared_ptr<Hero>> &defenders) {
//int numOfSkill = rand() % 3 + 1;
int target = rand() % 2 + 1;
cout << attacker->getName() << " is selected AxeBlade to attack to " <<defenders[4 - target]->getName() << endl;
if (defenders[target - 1]->isAlive() == false) {
//cout << "Selected target is dead !" << endl;
for (int t = 0; t < 1; t++) {
if (defenders[t]->isAlive() == true) {
target = t + 1;
cout << defenders[t]->getName() << " is selected as a target." << endl;
break;
}
}
}
if (defenders[0]->isAlive() == true || defenders[1]->isAlive() == true) {
cout << "Using AxeBlade to attack to " << defenders[4 - target]->getName() << "(Hp : "
<< defenders[4 - target]->getHp() << ")" << endl;
attackFunc(attacker, defenders[4 - target]);
}
else {
cout << "There is no target to attack. " << endl;
}
}
};
class Dead_Weight : public AttackSkill, public StunSkill {
public:
Dead_Weight() {
dmgMod = -25;
baseAcc = 82;
critMod = 6;
stunBase = 100;
stunEffect = 1;
}
void attack(shared_ptr<Unit> attacker, vector<shared_ptr<Hero>> &defenders) {
int target = rand() % 2 + 1;
cout << attacker->getName() << " is selected Dead Weight to attack to " <<defenders[4 - target]->getName() << endl;
if (defenders[target - 1]->isAlive() == false) {
for (int t = 0; t < 1; t++) {
if (defenders[t]->isAlive() == true) {
target = t + 1;
cout << defenders[t]->getName() << " is selected as a target." << endl;
break;
}
}
}
if (defenders[0]->isAlive() == true || defenders[1]->isAlive() == true) {
cout << "Using Dead Weight to attack to " << defenders[4 - target]->getName() << "(Hp : "
<< defenders[4 - target]->getHp() << ")" << endl;
attackFunc(attacker, defenders[4 - target]);
}
else {
cout << "There is no target to attack. " << endl;
}
}
};
class UtilitySkill : public Skill {
protected:
int minHp = 0;
int maxHp = 0;
int prot = 0;
public:
void utilityFunc(shared_ptr<Unit> healer, shared_ptr<Unit> target) {
if (target->isAlive() == true) {
if (maxHp) {
int randomNumber = rand() % (maxHp - minHp) + minHp;
cout << randomNumber;
target->increaseHp(randomNumber);
}
if (prot) {
target->setProt(healer->getProt() + prot);
cout << "Using Bulwark of Faith on " << target->getName() << ", +20 protection for 3 round." << endl;
target->setProtRound(3);
}
else {
}
}
}
// string effect gelecek +20 Prot for 3 round
};
class Bulwark_Of_Faith : public UtilitySkill {
public:
Bulwark_Of_Faith() {
prot = 20;
bool active = false;
}
void apply(shared_ptr<Unit> healer, shared_ptr<Unit> target) {
cout << "Bulwark of Faith Selected!" << endl;
utilityFunc(healer, target);
target->setProtRound(3);
}
};
class Divine_Grace : public UtilitySkill {
public:
Divine_Grace() {
minHp = 4;
maxHp = 5;
}
void apply(shared_ptr<Unit> attacker, vector<shared_ptr<Hero>> &targets) {
int target;
cout << "Divine Grace Selected!" << endl;
cout << "Select a Ally to heal!" << endl;
cout << "1-" << targets[0]->getName() << "(Hp : " << targets[0]->getHp() << ")" << endl;
cout << "2-" << targets[1]->getName() << "(Hp : " << targets[1]->getHp() << ")" << endl;
cout << "3-" << targets[2]->getName() << "(Hp : " << targets[2]->getHp() << ")" << endl;
cout << "4-" << targets[3]->getName() << "(Hp : " << targets[3]->getHp() << ")" << endl;
cout << "Number of Ally : ";
cin >> target;
cout << endl;
if (target != 1 && target != 2 && target != 3 && target != 4) {
cout << "Number of Ally selected 1 automatically because your selection is not an option! "
<< endl;
target = 1;
}
if (targets[target - 1]->isAlive() == false) {
cout << "Selected ally is dead !" << endl;
for (int t = 0; t < 3; t++) {
if (targets[t]->isAlive() == true) {
target = t + 1;
cout << targets[t]->getName() << " is selected as a ally to heal." << endl;
break;
}
}
}
if (targets[target - 1]->isAlive() == true) {
cout << targets[target - 1]->getName() << " is heald by ";
utilityFunc(attacker, targets[target - 1]);
cout << endl;
cout << targets[target - 1]->getName() << "(Hp : " << targets[target - 1]->getHp() << ")" << endl;
}
}
};
class Divine_Comfort : public UtilitySkill {
public:
Divine_Comfort() {
minHp = 1;
maxHp = 3;
}
void apply(shared_ptr<Unit> Healer, vector<shared_ptr<Hero>> &targets) {
int randomNumber = rand() % (3) + 1;
cout << "Divine Comfort Selected!" << endl;
cout << "All units healed by " << randomNumber << endl;
for (int j = 3; j >= 0; j--) {
if (targets[j]->isAlive() == true) {
targets[j]->increaseHp(randomNumber);
cout << targets[j]->getName() << "(Hp : " << targets[j]->getHp() << ")";
if (j != 0) {
cout << " ,";
}
}
}
cout << endl;
}
};
class Knitting_Bones : public UtilitySkill {
public:
Knitting_Bones() {
minHp = 2;
maxHp = 3;
}
void apply(shared_ptr<Unit> healer, vector<shared_ptr<Monster>> &targets) {
int target = rand() % 4 + 1;
cout << healer->getName() << " is selected Knitting Bones to heal to " << targets[target - 1]->getName() << endl;
cout << targets[target - 1]->getName() << " is healed by ";
utilityFunc(healer, targets[target - 1]);
cout << endl;
cout << targets[target - 1]->getName() << "(Hp : " << targets[target - 1]->getHp()<< ")" << endl;
int randomNumber = rand() % 2 + 2;
for (int j = 3; j >= 0; j--) {
if (targets[j]->isAlive() == true) {
targets[j]->increaseHp(randomNumber);
cout << targets[j]->getName() << "(Hp : " << targets[j]->getHp() << ")";
if (j != 0) {
cout << " ,";
}
}
}
cout << endl;
}
};
int main() {
srand(time(0));
shared_ptr<Vestal> ptrFirstVestal = make_shared<Vestal>("Vestal #1", 3);
shared_ptr<Vestal> ptrSecondVestal = make_shared<Vestal>("Vestal #2", 4);
shared_ptr<Crusader> ptrFirstCrusader = make_shared<Crusader>("Crusader #1", 1);
shared_ptr<Crusader> ptrSecondCrusader = make_shared<Crusader>("Crusader #2", 2);
shared_ptr<Bone_Defender> ptrFirstBoneD = make_shared<Bone_Defender>("Bone Defender #1", 2);
shared_ptr<Bone_Defender> ptrSecondBoneD = make_shared<Bone_Defender>("Bone Defender #2", 4);
shared_ptr<Bone_Soldier> ptrFirstBoneS = make_shared<Bone_Soldier>("Bone Soldier #1", 1);
shared_ptr<Bone_Soldier> ptrSecondBoneS = make_shared<Bone_Soldier>("Bone Soldier #2", 3);
//Crusader Skills
Smite Skill_Smite;//Attack
Stunning_Blow Skill_Stunning_Blow;//Attack
Holy_Lance Skill_Holy_Lance;//Attack + Move
Bulwark_Of_Faith Skill_Bulwark_Of_Faith;//Utility
//Vestal Skills
Mace_Bash Skill_Mace_Bash;//Attack
Dazzling_Light Skill_Dazzling_Light;//Attack
Divine_Grace Skill_Divine_Grace;//Utility (Heal)
Divine_Comfort Skill_Divine_Comfort;//Utility (Heal)
//Bone Soldier Skills
Graveyard_Slash Skill_Graveyard_Slash;//Attack
Graveyard_Stumble Skill_Graveyard_Stumble;//Attack + Move
//Bone Defender Skills
Axeblade Skill_Axeblade;//Attack
Dead_Weight Skill_Dead_Weight;//Attack
Knitting_Bones Skill_Knitting_Bones;//Utility (Heal)
//Move Skills
MoveSkill Move_Forward1;
MoveSkill Move_Backward1;
//Unit attackOrderArray[8];
shared_ptr<Unit> attackOrderArray[8];
vector< shared_ptr<Hero> >heroes;
vector<shared_ptr<Monster>> monsters;
vector<shared_ptr<Hero>>::iterator heroPtr;
heroPtr = heroes.begin();
vector<shared_ptr<Monster>>::iterator monsterPtr;
monsterPtr = monsters.begin();
monsters.push_back(ptrFirstBoneS);
monsters.push_back(ptrFirstBoneD);
monsters.push_back(ptrSecondBoneS);
monsters.push_back(ptrSecondBoneD);
heroes.push_back(ptrFirstCrusader);
heroes.push_back(ptrSecondCrusader);
heroes.push_back(ptrFirstVestal);
heroes.push_back(ptrSecondVestal);
sort(heroes.begin(), heroes.end(), &comparatorHero);
attackOrderArray[0] = ptrSecondVestal;
attackOrderArray[1] = ptrFirstVestal;
attackOrderArray[2] = ptrSecondCrusader;
attackOrderArray[3] = ptrFirstCrusader;
attackOrderArray[4] = ptrFirstBoneS;
attackOrderArray[5] = ptrFirstBoneD;
attackOrderArray[6] = ptrSecondBoneS;
attackOrderArray[7] = ptrSecondBoneD;
int numberOfRound = 1;
int numberOfSkill;
bool gameover = false;
do {
cout << " _______________" << endl;
cout << "______________________________________| R O U N D " << numberOfRound << " |_______________________________________" << endl;
cout << endl;
int randSpeed;
shared_ptr<Unit>temp;
// Increase speeds with random number
for (int i = 0; i < 8; i++) {
randSpeed = rand() % 8 + 1;
attackOrderArray[i]->increaseSpeed(randSpeed);
}
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 7; j++) {
if (attackOrderArray[j]->getTemporalSpeed() >
attackOrderArray[j + 1]->getTemporalSpeed()) {
temp = attackOrderArray[j];
attackOrderArray[j] = attackOrderArray[j + 1];
attackOrderArray[j + 1] = temp;
}
}
}
for (int l = 0; l < 8; ++l) {
attackOrderArray[l]->setTemporalSpeed(attackOrderArray[l]->getSpeed());
}
for (int k = 0; k < 7; ++k) {
if (attackOrderArray[k]->getType() == "Crusader" && attackOrderArray[k]->getProtRound() != 0) {
attackOrderArray[k]->setProtRound(attackOrderArray[k]->getProtRound() - 1);
}
else if (attackOrderArray[k]->getType() == "Crusader") {
attackOrderArray[k]->setProt(0);
}
}
for (int i = 7; i >= 0; i--) {
int actRandomChance;
actRandomChance = rand() % 100 + 1;
// Check game end conditions
bool allHeroesDied = true;
bool allMonstersDied = true;
for (int h = 0; h < heroes.size(); h++) {
if(heroes[h]->isAlive()) {
allHeroesDied = false;
}
}
for (int m = 0; m < monsters.size(); m++) {
if(monsters[m]->isAlive()) {
allMonstersDied = false;
}
}
if(allHeroesDied || allMonstersDied) {
gameover = true;
break;
}
if (attackOrderArray[i]->isAlive() == true && attackOrderArray[i]->isStun() == false) {
if (attackOrderArray[i]->getType() == "Vestal" || attackOrderArray[i]->getType() == "Crusader") {
cout << "_______________________|Current Positions and Health Amounts of Heroes|_______________________" << endl; cout << endl;
cout << " (4) (3) (2) (1)" << endl;
for (int k = 3; k >= 0; k--) {
if (k != 0) {
cout << heroes[k]->getName() << "(Hp:" << heroes[k]->getHp() << "),";
}
else {
cout << heroes[k]->getName() << "(Hp:" << heroes[k]->getHp() << ")";
}
}
cout << endl;
cout << "______________________________________________________________________________________________" << endl; cout << endl;
}
else {
cout << "______________________|Current Positions and Health Amounts of Monsters|______________________" << endl; cout << endl;
cout << " (1) (2) (3) (4)" << endl;
for (int k = 0; k <= 3; k++) {
if (k != 3) {
cout << monsters[k]->getName() << "(Hp:" << monsters[k]->getHp() << "),";
}
else {
cout << monsters[k]->getName() << "(Hp:" << monsters[k]->getHp() << ")";
}
}
cout << endl;
cout << "______________________________________________________________________________________________" << endl; cout << endl;
}
cout << attackOrderArray[i]->getName() << " 's turn! " << endl;
cout << "Select a skill!" << endl;
cout << endl;
if (attackOrderArray[i]->getType() == "Vestal") {
if (attackOrderArray[i]->getPosition() == 1) {
cout << "1 : Mace Bash (Attack)" << endl;
cout << "6 : Move Backward 1 (Move)" << endl;
cout << "Number of Skill : ";
cin >> numberOfSkill;
cout << endl;
if (numberOfSkill != 1 && numberOfSkill != 6) {
if (actRandomChance >= 1 && actRandomChance <= 10) {
cout << "Number of Skill selected 6 automatically because your selection is not an option! " << endl;
numberOfSkill = 6;
}
else {
cout << "Number of Skill selected 1 automatically because your selection is not an option!" << endl;
numberOfSkill = 1;
}
}
}
else if (attackOrderArray[i]->getPosition() == 2) {
cout << "1 : Mace Bash (Attack)" << endl;
cout << "2 : Dazzling Light (Attack)" << endl;
cout << "4 : Divine Comfort (Utility)" << endl;
cout << "5 : Move 1 step Forward (Move)" << endl;
cout << "6 : Move 1 step Backward (Move)" << endl;
cout << "Number of Skill : ";
cin >> numberOfSkill;
cout << endl;
if (numberOfSkill != 1 && numberOfSkill != 2 && numberOfSkill != 4 && numberOfSkill != 5 && numberOfSkill != 6) {
int randomMove = rand() % 2 + 1;
int randomAttack = rand() % 3 + 1;
if (actRandomChance >= 1 && actRandomChance <= 10) {
if (randomMove == 1) {
cout << "Number of Skill selected 5 automatically because your selection is not an option! " << endl;
numberOfSkill = 5;
}
else {
cout << "Number of Skill selected 6 automatically because your selection is not an option! " << endl;
numberOfSkill = 6;
}
}
else {
if (randomAttack == 1) {
cout << "Number of Skill selected 1 automatically because your selection is not an option! " << endl;
numberOfSkill = 1;
}
else if (randomAttack == 2) {
cout << "Number of Skill selected 2 automatically because your selection is not an option! " << endl;
numberOfSkill = 2;
}
else {
cout << "Number of Skill selected 4 automatically because your selection is not an option! " << endl;
numberOfSkill = 4;
}
}
}
}
else if (attackOrderArray[i]->getPosition() == 3) {
cout << "2 : Dazzling Light (Attack)" << endl;
cout << "3 : Divine Grace (Utility)" << endl;
cout << "4 : Divine Comfort (Utility)" << endl;
cout << "5 : Move 1 step Forward (Move)" << endl;
cout << "6 : Move 1 step Backward (Move)" << endl;
cout << "Number of Skill : ";
cin >> numberOfSkill;
cout << endl;
if (numberOfSkill != 3 && numberOfSkill != 2 && numberOfSkill != 4 && numberOfSkill != 5 && numberOfSkill != 6) {
int randomMove = rand() % 2 + 1;
int randomAttack = rand() % 3 + 1;
if (actRandomChance >= 1 && actRandomChance <= 10) {
if (randomMove == 1) {
cout << "Number of Skill selected 5 automatically because your selection is not an option! " << endl;
numberOfSkill = 5;
}
else {
cout << "Number of Skill selected 6 automatically because your selection is not an option! " << endl;
numberOfSkill = 6;
}
}
else {
if (randomAttack == 1) {
cout << "Number of Skill selected 2 automatically because your selection is not an option! " << endl;
numberOfSkill = 2;
}
else if (randomAttack == 2) {
cout << "Number of Skill selected 3 automatically because your selection is not an option! " << endl;
numberOfSkill = 3;
}
else {
cout << "Number of Skill selected 4 automatically because your selection is not an option! " << endl;
numberOfSkill = 4;
}
}
}
}
else if (attackOrderArray[i]->getPosition() == 4) {
cout << "2 : Dazzling Light (Attack)" << endl;
cout << "3 : Divine Grace (Utility)" << endl;
cout << "4 : Divine Comfort (Utility)" << endl;
cout << "5 : Move 1 step Forward (Move)" << endl;
cout << "Number of Skill : ";
cin >> numberOfSkill;
cout << endl;
if (numberOfSkill != 3 && numberOfSkill != 2 && numberOfSkill != 4 && numberOfSkill != 5) {
int randomMove = rand() % 2 + 1;
int randomAttack = rand() % 3 + 1;
if (actRandomChance >= 1 && actRandomChance <= 10) {