-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.cpp
More file actions
2007 lines (1792 loc) · 62 KB
/
Game.cpp
File metadata and controls
2007 lines (1792 loc) · 62 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
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
/****************************************************************************************************
** Program name: Eldritch Estate text adventure Game (CS 162 Final Project)
** Author: Alejandro Romero
** Date: 2/14/2017
** Description: This program is an H.P Lovecraft inspired horror mystery themed text adventure game.
** The goal of the game will be for the player to piece together clues to solve a mystery and stop a
** powerful creature before they go insane. (Sanity loss will be how I implement my time limit.)
** The game will take place at an estate which contains many rooms (linked pointer variables)
** to be explored. The program also makes use of containers for inventory and discard piles.
** The game is won once the final boss has been defeated, and lost if the player dies (health reached 0)
** or goes insane before they can solve the mystery. (sanity reaches 0).
******************************************************************************************************/
#include "Game.hpp"
/*****************************************************************************************************
** Name: Game Constructor Function
** Description: Creates and links together all Rooms of the game.
** It also creates and initializes the stats for the Player and Creatures(enemies).
*****************************************************************************************************/
Game::Game()
{
//declare rooms
foyer = new Foyer("Foyer");
study = new Study("Study");
diningRoom = new DiningRoom("Dining Room");
kitchen = new Kitchen("Kitchen");
hallway = new Hallway("Hallway");
basement = new Basement("Basement");
masterBedRoom = new MasterBedRoom("Master Bedroom");
guestRoom = new GuestRoom("Guest Bedroom");
ceremonyChamber = new CeremonyChamber("Ceremony Chambers");
conservatory = new Conservatory("Conservatory");
garden = new Garden("Garden");
//declare enemies(creatures)
cultist = new Creature(6, 2, 25, "Cultist");
azathoth = new Creature(8, 3, 100, "Azathoth");
srand(time(0));
//link rooms to point to one another.
foyer->setPointer('R', study);
foyer->setPointer('L', diningRoom);
foyer->setPointer('U', hallway);
foyer->setPointer('D', basement);
study->setPointer('L', foyer);
study->setPointer('R', conservatory);
diningRoom->setPointer('R', foyer);
diningRoom->setPointer('L', kitchen);
kitchen->setPointer('R', diningRoom);
basement->setPointer('U', foyer);
basement->setPointer('D', ceremonyChamber);
hallway->setPointer('D', foyer);
hallway->setPointer('R', masterBedRoom);
hallway->setPointer('L', guestRoom);
masterBedRoom->setPointer('L', hallway);
guestRoom->setPointer('R', hallway);
ceremonyChamber->setPointer('U', basement);
conservatory->setPointer('L', study);
conservatory->setPointer('U', garden);
garden->setPointer('D', conservatory);
basement->setLightsOn(false); ///testing
//initialize the players properties.
health = 100;
sanity = 75;
extralife = 0; //If you have health elixer.
inventory.push_back("Notebook"); // USE FOR START (Real Playthrough.)
//inventory.push_back("Lantern"); // USE FOR TESTING ONLY.
//inventory.push_back("Strange Rune"); // USE FOR TESTING ONLY.
//inventory.push_back("Revolver"); // USE FOR TESTING ONLY.
//inventory.push_back("Elder Sign"); // USE FOR TESTING ONLY.
//basement->setHasRune(true); //TESTING ONLY
curLoc = foyer;
MAX_INVT_SIZE = 8;
isDead = false;
hasWon = false;
}
/*****************************************************************************************************
** Name: Game Play Function
** Description: This funtion handles all the main functions for the gameplay. It allows the players to
** interact with the rooms by searching, calling event functions, and displaying room images.
** The play loop stopes when the player either wins, dies, or goes insane.
*****************************************************************************************************/
void Game::play()
{
char choice;
do
{
resetConsole();
//display room tag line
curLoc->describeRoom();
//run the room menu
choice = curLoc->roomMenu();
if (choice == 'R')
{
//move right to the next room
curLoc = curLoc->getRight();
}
else if (choice == 'L')
{
//move left to the next room
curLoc = curLoc->getLeft();
}
else if (choice == 'U')
{
//move upto the next room
curLoc = curLoc->getUp();
}
else if (choice == 'D')
{
//move down to the next room
curLoc = curLoc->getDown();
}
else if (choice == 'X')
{
//run the room's event function
if (curLoc == study)
{
studyEvent();
}
else if (curLoc == basement)
{
basementEvent();
}
else if (curLoc == hallway)
{
hallwayEvent();
}
else if (curLoc == ceremonyChamber)
{
CeremonialChamberEvent();
}
}
else if (choice == 'S')
{
//run the room's Search function
if (curLoc == foyer)
{
searchFoyer();
}
else if (curLoc == study)
{
searchStudy();
}
else if (curLoc == diningRoom)
{
searchDiningRoom();
}
else if (curLoc == kitchen)
{
searchKitchen();
}
else if (curLoc == basement)
{
searchBasement();
}
else if (curLoc == hallway)
{
searchHallway();
}
else if (curLoc == masterBedRoom)
{
searchMasterBedRoom();
}
else if (curLoc == guestRoom)
{
searchGuestRoom();
}
else if (curLoc == ceremonyChamber)
{
searchCeremonyChamber();
}
else if (curLoc == conservatory)
{
searchConservatory();
}
else if (curLoc == garden)
searchGarden();
}
else if (choice == 'I')
{
//manage the players inventory
manageInvt();
}
//check if the player has died
if (isDead)
{
//resetConsole();
if (health <= 0)
{
cout << "An icy chill creeps down your spine as everything around you begins to " << endl;
cout << "turn white. You have died. " << endl;
cout << endl;
pause();
}
else if (sanity <= 0)
{
cout << "You have been consumed by madness." << endl;
cout << endl;
pause();
}
}
//decriment sanity here?
sanity--;
//check the time
if (sanity == 50)
{
resetConsole();
cout << "You thought you just saw something out of the corner of your eyes, yet " << endl;
cout << "there is nothing there. Something about this place just isn't right, " << endl;
cout << "perhaps you should make haste. " << endl;
cout << endl;
pause();
}
else if (sanity == 30)
{
resetConsole();
cout << "You begin to hear voices in your head. Are you losing your mind?" << endl;
cout << "You best figure out what's going on and get out as soon as possible." << endl;
cout << endl;
pause();
}
else if (sanity == 0)
{
resetConsole();
cout << "Who are you? What are you doing in here? Why are the walls closing in?" << endl;
cout << "All of the sudden the ground seems to open as shadowy hands reach out to pull you in." << endl;
cout << "You curl up in the fetal position as the voices grow louder and the hands draw closer..." << endl;
cout << endl;
isDead = true;
pause();
}
}
while (choice != 'Q' && !isDead && !hasWon);
//display the win or lose screen depending on the outcome
if (hasWon)
{
winScreen();
}
else
{
loseScreen();
}
//deallocate memory here.
delete foyer;
delete study;
delete diningRoom;
delete kitchen;
delete hallway;
delete basement;
delete masterBedRoom;
delete guestRoom;
delete ceremonyChamber;
delete conservatory;
delete garden;
delete cultist; //testing
delete azathoth;
}
/*****************************************************************************************************
** Name: Study Event Function
** Description: Handles the study special event which does not allow users to enter conservatory until
** The Skeleton Key has been found/aquired.
*****************************************************************************************************/
void Game::studyEvent()
{
if (inInventory("Skeleton Key"))
{
cout << "You use the skeleton key to unlock the door." << endl;
conservatory->setDoorToUnlock(true);
curLoc = curLoc->getRight();
}
else
{
conservatory->setDoorToUnlock(false);
cout << "You attempt to open the door to the conservatory, only to find it locked." << endl;
cout << "You will have to find some way to open the door if you want to pass through." << endl;
cout << endl;
pause();
}
}
/*****************************************************************************************************
** Name: Basement Event Function
** Description: Handles the basement special event which does not allow users fully interact with basement
** until the lantern has been found/aquired.
*****************************************************************************************************/
void Game::basementEvent()
{
if (inInventory("Lantern") && inInventory("Strange Rune"))
{
cout << "You use your Lantern to light up the basement." << endl;
cout << "The strange rune begins to heat up as it pulsates faster." << endl;
cout << endl;
basement->setLightsOn(true);
inventory.remove("Lantern");
discard.push_back("Lantern");
pause();
}
else if (inInventory("Lantern") && !inInventory("Strange Rune"))
{
cout << "You use your Lantern to light up the basement by hanging it on a post." << endl;
cout << endl;
basement->setLightsOn(true);
inventory.remove("Lantern");
discard.push_back("Lantern");
pause();
}
else
{
cout << "You do not have any sources of light in your inventory." << endl;
cout << endl;
pause();
}
}
/*****************************************************************************************************
** Name: Hallway Event Function
** Description: Handles the Hallway special event which deals with combat and controls how interaction with
** the room changes depending on the status of the enemy cultist.
*****************************************************************************************************/
void Game::hallwayEvent()
{
if (inInventory("Ornate Dagger") && inInventory("Health Elixer"))
{
cout << "With a dagger in one hand and a health elixer in the other, you feel prepared to take on your enemy." << endl;
while (cultist->getHP() > 0 && health > 0)
{
int enemyDmgDone = 0;
int enemyDmgTaken = 0;
int newEnemyHP = 0;
int playersDmg = 0;
//enemy's turn
cout << "The cultist is attacking!" << endl;
enemyDmgDone = cultist->rollToAtk();
cout << "The cultist does " << enemyDmgDone << " points of damage." << endl;
health -= enemyDmgDone;
cout << "You now have " << health << " health points." << endl;
cout << endl;
//players turn
playersDmg = rand() % 12 + 2;
cout << "You attack the cultist for " << playersDmg << " points of damage." << endl;
cultist->setHP(cultist->getHP() - playersDmg);
cout << "The cultist now has " << cultist->getHP() << " health points." << endl;
cout << endl;
pause();
}
if (cultist->getHP() <= 0)
{
cout << "You have defeated the cultist!" << endl;
hallway->setEnemyDefeated(true);
cout << endl;
pause();
}
if (health <= 0 && extralife == 1)
{
extralife--;
cout << "You gasp for breath as the cultist knocks you down." << endl;
cout << "You quickly chug the elixer while you have the chance." << endl;
cout << "A sense of renewed energy uplifts you." << endl;
health = 50;
cout << endl;
pause();
}
else if (health <= 0)
{
cout << "You have been bested by the cultist.." << endl;
isDead = true;
pause();
}
}
else if (inInventory("Health Elixer") && !inInventory("Ornate Dagger"))
{
cout << "Armed with nothing but your fist and a health elixer, you attempt to take down the cultist." << endl;
while (cultist->getHP() > 0 && health > 0)
{
int enemyDmgDone = 0;
int enemyDmgTaken = 0;
int newEnemyHP = 0;
int playersDmg = 0;
//enemy's turn
cout << "The cultist is attacking!" << endl;
enemyDmgDone = cultist->rollToAtk();
cout << "The cultist does " << enemyDmgDone << " points of damage." << endl;
health -= enemyDmgDone;
cout << "You now have " << health << " health points." << endl;
cout << endl;
//players turn
playersDmg = rand() % 6 + 1;
cout << "You attack the cultist for " << playersDmg << " points of damage." << endl;
cultist->setHP(cultist->getHP() - playersDmg);
cout << "The cultist now has " << cultist->getHP() << " health points." << endl;
cout << endl;
pause();
}
if (cultist->getHP() <= 0)
{
cout << "You have defeated the cultist!" << endl;
hallway->setEnemyDefeated(true);
cout << endl;
pause();
}
if (health <= 0 && extralife == 1)
{
extralife--;
cout << "You gasp for breath as the cultist knocks you down." << endl;
cout << "You quickly chug the elixer while you have the chance." << endl;
cout << "A sense of renewed energy uplifts you." << endl;
health = 50;
cout << endl;
pause();
}
else if (health <= 0)
{
cout << "You have been bested by the cultist.." << endl;
isDead = true;
pause();
}
}
else if (inInventory("Ornate Dagger") && !inInventory("Health Elixer"))
{
cout << "You hold your dagger steady as you prepare to take on your foe." << endl;
while (cultist->getHP() > 0 && health > 0)
{
int enemyDmgDone = 0;
int enemyDmgTaken = 0;
int newEnemyHP = 0;
int playersDmg = 0;
//enemy's turn
cout << "The cultist is attacking!" << endl;
enemyDmgDone = cultist->rollToAtk();
cout << "The cultist does " << enemyDmgDone << " points of damage." << endl;
health -= enemyDmgDone;
cout << "You now have " << health << " health points." << endl;
cout << endl;
//players turn
playersDmg = rand() % 12 + 2;
cout << "You attack the cultist for " << playersDmg << " points of damage." << endl;
cultist->setHP(cultist->getHP() - playersDmg);
cout << "The cultist now has " << cultist->getHP() << " health points."<< endl;
cout << endl;
pause();
}
if (cultist->getHP() <= 0)
{
cout << "You have defeated the cultist!" << endl;
hallway->setEnemyDefeated(true);
cout << endl;
pause();
}
else if (health <= 0)
{
cout << "The cultist has bested you..." << endl;
isDead = true;
cout << endl;
pause();
}
}
else
{
cout << "Armed with nothing but your fist, you attempt to take down the cultist." << endl;
while (cultist->getHP() > 0 && health > 0)
{
int enemyDmgDone = 0;
int enemyDmgTaken = 0;
int newEnemyHP = 0;
int playersDmg = 0;
//enemy's turn
cout << "The cultist is attacking!" << endl;
enemyDmgDone = cultist->rollToAtk();
cout << "The cultist does " << enemyDmgDone << " points of damage." << endl;
health -= enemyDmgDone;
cout << "You now have " << health << " health points." << endl;
cout << endl;
//players turn
playersDmg = rand() % 6 + 1;
cout << "You attack the cultist for " << playersDmg << " points of damage." << endl;
cultist->setHP(cultist->getHP() - playersDmg);
cout << "The cultist now has " << cultist->getHP() << " health points."<< endl;
cout << endl;
pause();
}
if (cultist->getHP() <= 0)
{
cout << "You have defeated the cultist!" << endl;
hallway->setEnemyDefeated(true);
cout << endl;
pause();
}
else if (health <= 0)
{
cout << "The cultist has bested you..." << endl;
cout << endl;
isDead = true;
pause();
}
}
}
/*****************************************************************************************************
** Name: Ceremonial Chambers Event Function
** Description: Handles the ceremonial chambers special event which deals with combat and controls how
** interaction with the room changes depending on the status of the enemy Boss Azathoth.
*****************************************************************************************************/
void Game::CeremonialChamberEvent()
{
string imageLines = "";
ifstream inputFile;
string fileName = "EEAzathoth.txt";
inputFile.open(fileName.c_str());
if (inputFile)
{
while (inputFile)
{
string temp;
getline(inputFile, temp);
temp += "\n";
imageLines += temp;
}
cout << imageLines << endl;
inputFile.close();
}
else
cout << "ERROR: Image file wasn't found..." << endl;
if (inInventory("Elder Sign"))
{
cout << "The Elder Sign beckons to you. You hold it out towards the creature as if you already know the results." << endl;
cout << "In an unfamilar alien tongue the creature seems to cry out in pain when it attempts to lash out at you." << endl;
cout << "The elder sign has created some kind of ward around you, weakening the enemy." << endl;
cout << endl;
// set Azathoth's attack die value to lower number.
azathoth->setDVal(4);
}
if (inInventory("Revolver"))
{
cout << "You grab the Revolver and take Aim, hoping that there are still some rounds left." << endl;
cout << "BANG!,BANG!,BANG!,BANG!,BANG!, CLICK,CLICK. At least you got 5 shots." << endl;
cout << "An anamolous green ooze seeps through the holes in the tentacles." << endl;
cout << endl;
azathoth->setHP(50);
}
if (inInventory("Ornate Dagger") && inInventory("Health Elixer"))
{
cout << "With a dagger in one hand and a health elixer in the other, you feel prepared to take on your enemy." << endl;
while (azathoth->getHP() > 0 && health > 0)
{
int enemyDmgDone = 0;
int enemyDmgTaken = 0;
int newEnemyHP = 0;
int playersDmg = 0;
//enemy's turn
cout << "Azathoth is attacking!" << endl;
enemyDmgDone = azathoth->rollToAtk();
cout << "Azathoth does " << enemyDmgDone << " points of damage." << endl;
health -= enemyDmgDone;
cout << "You now have " << health << " health points." << endl;
cout << endl;
//players turn
playersDmg = rand() % 12 + 2;
cout << "You attack Azathoth for " << playersDmg << " points of damage." << endl;
azathoth->setHP(azathoth->getHP() - playersDmg);
cout << "Azathoth now has " << azathoth->getHP() << " health points." << endl;
cout << endl;
pause();
}
if (azathoth->getHP() <= 0)
{
cout << "You have defeated Azathoth!" << endl;
ceremonyChamber->setEnemyDefeated(true);
hasWon = true;
cout << endl;
pause();
}
if (health <= 0 && extralife == 1)
{
extralife--;
cout << "You gasp for breath as one of Azathoth's tentacles knock you down." << endl;
cout << "You quickly chug the elixer while you have the chance." << endl;
cout << "A sense of renewed energy uplifts you." << endl;
health = 50;
cout << endl;
pause();
}
else if (health <= 0)
{
cout << "You have defeated by Azathoth.." << endl;
isDead = true;
pause();
}
}
else if (inInventory("Health Elixer") && !inInventory("Ornate Dagger"))
{
cout << "Armed with nothing but your fist and a health elixer, you attempt to take down the cultist." << endl;
while (azathoth->getHP() > 0 && health > 0)
{
int enemyDmgDone = 0;
int enemyDmgTaken = 0;
int newEnemyHP = 0;
int playersDmg = 0;
//enemy's turn
cout << "Azathoth is attacking!" << endl;
enemyDmgDone = azathoth->rollToAtk();
cout << "Azathoth does " << enemyDmgDone << " points of damage." << endl;
health -= enemyDmgDone;
cout << "You now have " << health << " health points." << endl;
cout << endl;
//players turn
playersDmg = rand() % 6 + 1;
cout << "You attack Azathoth for " << playersDmg << " points of damage." << endl;
azathoth->setHP(azathoth->getHP() - playersDmg);
cout << "Azathoth now has " << azathoth->getHP() << " health points." << endl;
cout << endl;
pause();
}
if (azathoth->getHP() <= 0)
{
cout << "You have defeated Azathoth!" << endl;
ceremonyChamber->setEnemyDefeated(true);
hasWon = true;
cout << endl;
pause();
}
if (health <= 0 && extralife == 1)
{
extralife--;
cout << "You gasp for breath as one of Azathoth's tentacles knock you down." << endl;
cout << "You quickly chug the elixer while you have the chance." << endl;
cout << "A sense of renewed energy uplifts you." << endl;
health = 50;
cout << endl;
pause();
}
else if (health <= 0)
{
cout << "You have been defeated by Azathoth.." << endl;
isDead = true;
pause();
}
}
else if (inInventory("Ornate Dagger") && !inInventory("Health Elixer"))
{
cout << "You hold your dagger steady as you prepare to take on your foe." << endl;
while (azathoth->getHP() > 0 && health > 0)
{
int enemyDmgDone = 0;
int enemyDmgTaken = 0;
int newEnemyHP = 0;
int playersDmg = 0;
//enemy's turn
cout << "Azathoth is attacking!" << endl;
enemyDmgDone = azathoth->rollToAtk();
cout << "Azathoth does " << enemyDmgDone << " points of damage." << endl;
health -= enemyDmgDone;
cout << "You now have " << health << " health points." << endl;
cout << endl;
//players turn
playersDmg = rand() % 12 + 2;
cout << "You attack Azathoth for " << playersDmg << " points of damage." << endl;
azathoth->setHP(azathoth->getHP() - playersDmg);
cout << "Azathoth now has " << azathoth->getHP() << " health points." << endl;
cout << endl;
pause();
}
if (azathoth->getHP() <= 0)
{
cout << "You have defeated Azathoth!" << endl;
ceremonyChamber->setEnemyDefeated(true);
hasWon = true;
cout << endl;
pause();
}
else if (health <= 0)
{
cout << "Azathoth has defeated you..." << endl;
isDead = true; //testing now.
cout << endl;
pause();
}
}
else
{
cout << "Armed with nothing but your fist, you attempt to take down the monstrosity." << endl;
while (azathoth->getHP() > 0 && health > 0)
{
int enemyDmgDone = 0;
int enemyDmgTaken = 0;
int newEnemyHP = 0;
int playersDmg = 0;
//enemy's turn
cout << "Azathoth is attacking!" << endl;
enemyDmgDone = azathoth->rollToAtk();
cout << "Azathoth does " << enemyDmgDone << " points of damage." << endl;
health -= enemyDmgDone;
cout << "You now have " << health << " health points." << endl;
cout << endl;
//players turn
playersDmg = rand() % 6 + 1;
cout << "You attack Azathoth for " << playersDmg << " points of damage." << endl;
azathoth->setHP(azathoth->getHP() - playersDmg);
cout << "Azathoth now has " << azathoth->getHP() << " health points." << endl;
cout << endl;
pause();
}
if (azathoth->getHP() <= 0)
{
cout << "You have defeated Azathoth!" << endl;
ceremonyChamber->setEnemyDefeated(true);
hasWon = true;
cout << endl;
pause();
}
else if (health <= 0)
{
cout << "Azathoth has defeated you..." << endl;
cout << endl;
isDead = true;
pause();
}
}
}
/*****************************************************************************************************
** Name: Foyer Search Function
** Description: Deals with the player using the rooms search menu. Some option allow the user to obtain
** items, while other options may harm the user or have no effect on gameplay.
*****************************************************************************************************/
void Game::searchFoyer()
{
int choice;
do
{
resetConsole();
cout << "What would you like to search?" << endl;
cout << "1. Investigate the painting on the wall." << endl;
cout << "2. Check under the divan." << endl;
cout << "3. Search the cabinets." << endl;
cout << "4. Return to room menu." << endl;
cout << endl;
//input validation
choice = inputValidation("Enter your choice:");
while (choice <= 0 || choice > 4)
choice = inputValidation("The valid choices are 1-4. Please try again.");
cout << endl;
if (choice == 1)
{
resetConsole();
cout << "The painting on the wall dipicts a bunch of women in the raw dancing around a large bonfire " << endl;
cout << "under what appears to be an eclipsed moon. Something about the picture is quite unsettling. " << endl;
cout << endl;
pause();
sanity--;
//make option for if painting was already investigated.
}
else if (choice == 2)
{
resetConsole();
cout << "You check under the luxurious divan. " << endl;
//if you haven't already recieved the item
if (!inDiscardPile("Ornate Dagger") && !inInventory("Ornate Dagger"))
{
cout << "You found an Ornate Dagger." << endl;
cout << endl;
//verify inventory has space
if (inventory.size() == MAX_INVT_SIZE)
{
cout << "But you have no space in your inventory, discard and item first." << endl;
pause();
}
else
{
//add Ornate Dagger to inventory
inventory.push_back("Ornate Dagger");
cout << "Ornate Dagger Obtained." << endl;
cout << endl;
pause();
}
}
else
{
cout << "You've already checked here." << endl;
cout << endl;
pause();
}
}
else if (choice == 3)
{
resetConsole();
cout << "You search through the victorian cabinets" << endl;
cout << "You find nothing of interest." << endl;
cout << endl;
pause();
}
else if (choice != 4)
cout << "The valid choices are 1 - 4. Please try again." << endl;
} while (choice != 4);
}
/*****************************************************************************************************
** Name: Study Search Function
** Description : Deals with the player using the rooms search menu.Some option allow the user to obtain
** items, while other options may harm the user or have no effect on gameplay.
*****************************************************************************************************/
void Game::searchStudy()
{
int choice;
do
{
resetConsole();
cout << "What would you like to search?" << endl;
cout << "1. Check the desk." << endl;
cout << "2. Examine the Bust." << endl;
cout << "3. Search the bookshelf." << endl;
cout << "4. Back to room menu." << endl;
cout << endl;
//input validation
choice = inputValidation("Enter your choice:");
while (choice <= 0 || choice > 4)
choice = inputValidation("Invalid choice. Enter a menu option instead:");
cout << endl;
if (choice == 1)
{
resetConsole();
cout << "You check around the desk..." << endl;
//if you haven't already recieved the item
if (!inDiscardPile("Strange Note") && !inInventory("Strange Note"))
{
cout << "You find a strange note." << endl;
cout << endl;
//verify inventory has space
if (inventory.size() == MAX_INVT_SIZE)
{
cout << "But you have no space in your inventory, discard and item first." << endl;
cout << endl;
pause();
}
else
{
//read strange note.
cout << "It reads:" << endl << endl;
cout << "Alas, the time has finally arrived. The stars are aligned and the ceremony " << endl;
cout << "is ready to be performed. What splendors of knowledge..No, what vast power " << endl;
cout << "will be my reward once the 'Ancient One' has awoken. To ensure there would " << endl;
cout << "be no interferences I unfortunately had to have Mortimer silenced." << endl;
cout << endl;
cout << "Glorious be the reign of AZATHOTH!," << endl << "G.W" << endl;
cout << endl;
//add Strange Note to inventory
inventory.push_back("Strange Note");
cout << "Strange Note obtained." << endl;
cout << endl;
pause();
}
}
else
{
cout << "You've already looked here." << endl;
cout << endl;
pause();
}
}
else if (choice == 2)
{
resetConsole();
cout << "You examine the crooked bust of one of the Westons and notice something shiny poking out from under. " << endl;
//if you haven't already recieved the item
if (!inDiscardPile("Old Brass Key") && !inInventory("Old Brass Key"))
{
cout << "You find an Old Brass Key." << endl;
cout << endl;
//verify inventory has space
if (inventory.size() == MAX_INVT_SIZE)
{
cout << "But you have no space in your inventory, discard and item first." << endl;
pause();
}
else
{
//add Old-Brass-Key to inventory
inventory.push_back("Old Brass Key");
cout << "Old Brass Key obtained." << endl;
cout << endl;
pause();
}
}
else
{
cout << "You've already looked here!" << endl << endl;
pause();
}
}
else if (choice == 3)
{
resetConsole();
cout << "You search the large bookshelf for anything of interest." << endl;
cout << "Most books seem to be about investments but a few of the newer ones seem " << endl;
cout << "to be about occult, ancient lore and alchemy." << endl;
cout << "Otherwise you find nothing of interest."<< endl;
cout << endl;
pause();
}
else if (choice != 4)
cout << "Invalid choice. Enter a menu option instead:" << endl;
} while (choice != 4);
}
/*****************************************************************************************************
** Name: Dining Room Search Function
** Description : Deals with the player using the rooms search menu.Some option allow the user to obtain
** items, while other options may harm the user or have no effect on gameplay.
*****************************************************************************************************/
void Game::searchDiningRoom()
{
int choice;
do
{
resetConsole();
cout << "What would you like to search?" << endl;
cout << "1. Investigate the serving trolley." << endl;
cout << "2. Check under the rug." << endl;
cout << "3. Search the china cabinets." << endl;
cout << "4. Return to room menu." << endl;
cout << endl;
//input validation
choice = inputValidation("Enter your choice:");
while (choice <= 0 || choice > 4)
choice = inputValidation("The valid choices are 1-4. Please try again.");
cout << endl;
if (choice == 1)
{