-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasement.cpp
More file actions
195 lines (166 loc) · 5.26 KB
/
Basement.cpp
File metadata and controls
195 lines (166 loc) · 5.26 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
/****************************************************************************************************
** 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 "Basement.hpp"
Basement::Basement(string n) : Room(n)
{
}
void Basement::describeRoom()
{
if (roomLit)
{
cout << "You are standing in the basement. " << endl;
cout << endl;
}
}
char Basement::roomMenu()
{
if (!roomLit)
{
cout << "As you open the door to the basement you are confronted with total darkness." << endl;
cout << "Perhaps it would be wise not to proceed any further until a light source has been found." << endl;
cout << endl;
cout << endl;
cout << "What would you like to do?" << endl;
cout << "1. Decend further into the basement without a light source." << endl;
cout << "2. Attempt to light up the basement." << endl;
cout << "3. Return to the Foyer." << endl;
cout << "4. Manage Inventory." << endl;
cout << "5. Quit Game." << endl;
cout << endl;
//input validation
int choice = inputValidation("Enter your choice:");
while (choice <= 0 || choice > 5)
choice = inputValidation("The valid choices are 1-4. Please try again.");
cout << endl;
if (choice == 1)
{
cout << "You decide to proceed into the pitch black room." << endl;
cout << "You suddenly hear a monstrous roar which does not sound "<< endl;
cout << "like any animal you are familiar with. You lose your footing " << endl;
cout << "as you begin to plumet down the stairs. You crash against something " << endl;
cout << "as you fall to the ground. You decide to quickly return to the Foyer " << endl;
cout << "so that you may address your wounds. " << endl;
cout << endl;
cout << endl;
//wait for the user to press enter before continuing
string pause;
cout << "PRESS ENTER TO CONTINUE" << endl;
getline(cin, pause);
cin.clear();
cin.ignore();
cout << "\033[2J\033[1;1H"; //comment out for VS
//lose health
//lose sanity?
return 'U';
}
else if (choice == 2)
{
return 'X';
}
else if (choice == 3)
{
return 'U';
}
else if (choice == 4)
{
return 'I';
}
else
return 'Q';
}
else if (roomLit && doorIsUnlocked)//testing
{
cout << "A secret passage is now revealed. " << endl;
cout << "You get the feeling that you are close to the end. " << endl;
cout << endl;
cout << "What would you like to do?" << endl;
cout << "1. Go through the passage." << endl;
cout << "2. Return to the Foyer." << endl;
cout << "3. Manage Inventory." << endl;
cout << "4. Quit Game." << endl;
cout << endl;
//input validation
int 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)
{
return 'D';
}
else if (choice == 2)
{
return 'U';
}
else if (choice == 3)
{
return 'I';
}
else if (choice == 4)
{
return 'Q';
}
}
else
{
string imageLines = "";
ifstream inputFile;
string fileName = "EEBasement.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;
///////////////////////////////////////////////////////////////////////////////
cout << "With the basement lit up you now notice a bizarre relief on one of the walls, " << endl;
cout << "a large wooden trunk, and a furnace." << endl;
cout << "The sound of chanting can be heard from somewhere nearby. " << endl;
cout << endl;
cout << endl;
cout << "What would you like to do?" << endl;
cout << "1. Search the Basement." << endl;
cout << "2. Return to the Foyer." << endl;
cout << "3. Manage Inventory." << endl;
cout << "4. Quit Game." << endl;
cout << endl;
//input validation
int 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)
{
return 'S';
}
else if (choice == 2)
{
return 'U';
}
else if (choice == 3)
{
return 'I';
}
else
return 'Q';
}
}