-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdesert.cpp
281 lines (267 loc) · 8.49 KB
/
desert.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
/*********************************************************************
** Program name: desert.cpp
** Author: Andrew Ngo
** Date: 03/10/2018
** Description: Class and function implementation for a Desert class,
* derived from Space.
*********************************************************************/
#include "desert.hpp"
#include "space.hpp"
#include <iostream>
#include <cstdlib>
#include <string>
Desert::Desert()
{}
/*********************************************************************
** Description: event(): Possible events for a Desert area.
*********************************************************************/
void Desert::event(Game* game)
{
int random = (rand() % 10);
switch (random)
{
case 0:
{
if (game->getStats() < 170)
{
std::cout << "A malnourished desert coyote attacks you!" << std::endl;
if (game->getStats() < 120)
{
std::cout << "You managed to barely fend it off and took some damage. You become a bit better at combat. (-10 HP, +10 Atk)" << std::endl;
game->hp(-10);
game->atkup(15);
break;
}
if (game->getStats() >= 120)
{
std::cout << "You fight it off without any problems. You become a bit better at fighting. (+10 Atk, +10 Def)";
game->atkup(10);
game->defup(10);
break;
}
}
break;
}
case 1:
{
if (game->getWeapon() < 3)
{
std::cout << "You see a glinting piece of metal buried in the sand. You approach it and unearth a powerful sword! (+50 Atk)";
game->atkup(50);
game->setWeapon(3);
break;
}
if (game->getHealth() < 100)
{
std::cout << "You come across a fresh water oasis and drink to quench your thirst. (HP restored)";
if (game->getHealth() > 80)
{
game->setHealth(100);
break;
}
else game->hp(20);
break;
}
if (game->getStats() >= 150)
{
std::cout << "Traversing the desert makes you thirsty and tired, but tougher in mind and body. (-10 HP, +10 Atk, + 10 Def)";
game->hp(-10);
game->atkup(10);
game->defup(10);
break;
}
break;
}
case 2:
{
if (game->getStats() >= 150)
{
std::cout << "You stumble across two hungry wolves that lunge upon seeing you!" << std::endl;
if (game->getStats() >= 200)
{
std::cout << "They were no match for you. (+10 Atk, +10 Def)";
game->atkup(10);
game->defup(10);
break;
}
if (game->getStats() < 200)
{
std::cout << "A two vs one fight is tough, but you prevail and your strength increases. (-15 HP, +15 Atk, +10 Def)";
game->hp(-15);
game->atkup(15);
game->defup(10);
break;
}
}
if (game->getArmor() < 2)
{
std::cout << "You find a leather cloak, a bit sandy but still good for protection from the elements. (+20 Def)";
game->defup(20);
game->setArmor(2);
break;
}
break;
}
case 3:
{
if (game->getStats() > 160)
{
std::cout << "You're forced to traverse a long distance without water. (-15 HP)";
game->hp(-15);
break;
}
if (game->getStats() <= 160)
{
std::cout << "The raging desert winds assault your senses. (-5 HP)";
game->hp(-5);
break;
}
break;
}
}
std::cout << std::endl;
}
/*********************************************************************
** Description: greet(): messages that get printed to console in a desert area.
*********************************************************************/
void Desert::greet()
{
int random = (rand() % 6);
switch (random)
{
case 0:
{
std::cout << "The arid air parches your throat.";
break;
}
case 1:
{
std::cout << "Swirling sand dances in the distance.";
break;
}
case 2:
{
std::cout << "As you enter the zone, you feel the sand give way beneath your feet.";
break;
}
case 3:
{
std::cout << "In the distance, you see mountains of golden sand.";
break;
}
case 4:
{
std::cout << "As you cross into the zone, a barren landscape greets you.";
break;
}
case 5:
{
std::cout << "You cough and shield your eyes as a sandstorm blows past you.";
break;
}
}
std::cout << std::endl;
}
/*********************************************************************
** Description: getName(): possible names for Desert areas, including
* one that can be explored.
*********************************************************************/
std::string Desert::getName()
{
setCanExplore(false);
std::string name;
int random = (rand() % 7);
switch (random)
{
case 0:
{
name = "Wildspire Wastes";
break;
}
case 1:
{
name = "Arid Barrens";
break;
}
case 2:
{
name = "Dried Lake";
break;
}
case 3:
{
name = "Parched Flats";
break;
}
case 4:
{
name = "Scorched Sands";
break;
}
case 5:
{
name = "Desolated Field";
break;
}
case 6:
{
name = "Ancient Ruins";
setCanExplore(true);
break;
}
}
return name;
}
/*********************************************************************
** Description: explore(): possible exploration events for Desert.
*********************************************************************/
void Desert::explore(Game* game)
{
int random = (rand() % 3);
{
switch (random)
{
case 0:
{
std::cout << "The ruins are filled with traps. You accidentally stumble across a dart trap. Fortunately, whatever poison on it has long since expired. (-15 HP)";
game->hp(-15);
break;
}
case 1:
{
std::cout << "These ruins are the tomb of an ancient king. ";
if (game->getSpecialDef() == false)
{
std::cout << "Several protective charms adorn the inner chambers. Sensing great power from them, you touch one. Your defensive power greatly increases!";
game->defup(100);
game->setSpecialDef(true);
break;
}
else
{
std::cout << "There doesn't seem to be anything else of value here.";
break;
}
}
case 2:
{
if (game->getHealth() > 50)
{
std::cout << "Exploring the ruins, the floor suddenly gives way beneath you. You are injured, but able to escape. Unfortunately, this gives the Pursuer some time to catch up. (-15 HP, -3 Time)";
game->hp(-15);
game->adjTimeLimit(3);
break;
}
else if (game->getHealth() < 50)
{
std::cout << "Your breath runs ragged as fatigue sets in. You are forced to take a rest. (+10 HP, -2 Time)";
game->hp(10);
game->adjTimeLimit(2);
break;
}
}
}
setCanExplore(false);
std::cout << std::endl;
}
}