-
Notifications
You must be signed in to change notification settings - Fork 0
/
Encounter.cpp
311 lines (302 loc) · 9.92 KB
/
Encounter.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
/**
* This class handles the Encounters that can occur whenever the player moves forward.
*
* I am so sorry to whoever reads this it's so badly written
* It was the first thing I started on and I didn't really have a good idea of what I wanted to do
* I wish I could go back and redo this but I think that'll take too much time :'(
*
* Creator: Luke Welton (law0047)
* Filename: Encounter.cpp
*
* I did not use any outside sources for this file.
**/
#include <cstdlib>
#include <iostream>
#include "Encounter.h"
#include "System.h"
Encounter::Encounter(int diff, int t) {
difficulty = diff;
type = t == 0 ? rand() % 8 + 1 : t;
}
bool Encounter::displayIntro() {
string encounterMessage = "";
bool noEncounter = false;
switch (type) {
case 1: {
encounterMessage = "You ran into Dr. " + System::getRandomLastName() + "!\n";
encounterMessage += "\"I'm looking for someone to help me grade some papers.\"\n"
"\"Would you like to help out?\" (Y/N)";
break;
}
case 2: {
encounterMessage = "You ran into Dr. " + System::getRandomLastName() + "!\n";
encounterMessage += "\"Pop quiz time!\"\n"
"\"But I'm not even class!\" you say.\n"
"\"Too bad!\"\n";
int quiz = rand() % 3;
switch (quiz) {
case 3: {
type = 23;
switch (difficulty) {
case 3: {
encounterMessage += "What is the derivative of 140,231 with respect to z?";
break;
}
case 2: {
encounterMessage += "What is tan(135) in degrees?";
break;
}
case 1:
default: {
encounterMessage += "What is 22 + 49?";
break;
}
}
break;
}
case 2: {
type = 22;
switch (difficulty) {
case 3: {
encounterMessage += "What is the fear of colors?";
break;
}
case 2: {
encounterMessage += "Which of Newton's Laws of Physics reads as following:\n"
"An object in motion tends to stay in motion unless acted upon by an outside force.\n"
"(Enter an Integer): ";
break;
}
case 1:
default: {
encounterMessage += "What is the study of rocks?";
break;
}
}
break;
}
case 1:
default: {
type = 21;
switch (difficulty) {
case 3: {
encounterMessage += "What programming language is this program written in?";
break;
}
case 2: {
encounterMessage += "What kind of loop is used in programming\n"
"to iterate a series of statements a set number of times?";
break;
}
case 1:
default: {
encounterMessage += "What is 5 % 3?";
break;
}
}
break;
}
}
break;
}
case 3: {
encounterMessage = "You ran into your friend " + System::getRandomFirstName() + "!\n";
encounterMessage += "\"There's a party going on at " + System::getRandomFirstName() + "'s place,\"\n";
encounterMessage += "\"Do you wanna join?\" (Y/N)";
break;
}
case 4: {
encounterMessage = "You ran into your friend " + System::getRandomFirstName() + "!\n";
encounterMessage += "\"Do you think you could help me out with this project?\"\n"
"\"I'll pay you.\" (Y/N)";
break;
}
case 5: {
encounterMessage = "You ran into a job recruiter!\n"
"\"You look like a smart, dependable grad student!\"\n"
"\"Would you like to work part-time at my company?\" (Y/N)";
break;
}
case 6: {
encounterMessage = "You found a puzzle on the floor!\n";
switch (difficulty) {
case 3: {
encounterMessage += "What is the limit of 1/(n^2-1) as n goes to infinity?";
break;
}
case 2: {
encounterMessage += "What is the square root of 1156?";
break;
}
case 1:
default: {
encounterMessage += "What is 2 + 2?";
break;
}
}
break;
}
case 7: {
encounterMessage = "You found a pizza on the floor!\n"
"Would you like to eat it? (Y/N)";
break;
}
case 8: {
encounterMessage = "A wild puzzle appeared!\n";
switch (difficulty) {
case 3: {
encounterMessage += "What is the name of the company that made Pokemon Go?";
break;
}
case 2: {
encounterMessage += "What is the name of the company who distributes Pokemon games?";
break;
}
case 1:
default: {
encounterMessage += "What is the name of Pokemon's mascot?";
break;
}
}
break;
}
default: {
encounterMessage = "You thought you heard someone call your name in the hallway,\n"
"But you looked behind you and didn't see anyone.\n"
"That was weird.";
noEncounter = true;
break;
}
}
cout << encounterMessage << endl;
return noEncounter;
}
bool Encounter::answerEncounter() {
string answer;
bool correct = false;
switch (type) {
case 23: {
cin >> answer;
switch (difficulty) {
case 3: {
correct = answer == "0";
break;
}
case 2: {
correct = answer == "1";
break;
}
case 1: {
correct = answer == "71";
break;
}
}
break;
}
case 22: {
cin >> answer;
switch (difficulty) {
case 3: {
System::toLowerCase(answer);
correct = answer == "chromophobia" || answer == "chromatophobia";
break;
}
case 2: {
correct = answer == "1";
break;
}
case 1: {
System::toLowerCase(answer);
correct = answer == "geology";
break;
}
}
break;
}
case 21: {
cin >> answer;
switch (difficulty) {
case 3: {
System::toUpperCase(answer);
correct = answer == "C++";
break;
}
case 2: {
System::toLowerCase(answer);
correct = answer == "for" || answer == "for loop";
break;
}
case 1: {
correct = answer == "2";
break;
}
}
break;
}
case 6: {
cin >> answer;
switch (difficulty) {
case 3: {
correct = answer == "0";
break;
}
case 2: {
correct = answer == "34";
break;
}
case 1: {
correct = answer == "4";
break;
}
}
break;
}
case 8: {
cin >> answer;
System::toLowerCase(answer);
switch (difficulty) {
case 3: {
correct = answer == "niantic";
break;
}
case 2: {
correct = answer == "nintendo";
break;
}
case 1: {
correct = answer == "pikachu";
break;
}
}
break;
}
case 1: case 3: case 4:
case 5: case 7: default: {
vector<char> yn;
yn.push_back('Y');
yn.push_back('N');
answer = System::charLoop(yn);
correct = answer == "Y";
break;
}
}
return correct;
}
char Encounter::getAttr() {
switch (type) {
case 1: case 4:
case 5: {
return 'M';
}
case 3: case 7:{
return 'H';
}
case 21: case 22: case 23:
case 6: case 8: {
return 'I';
}
default: {
return 'R';
}
}
}