-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforest.cpp
240 lines (223 loc) · 6.7 KB
/
forest.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
/*********************************************************************
** Program name: forest.hpp
** Author: Andrew Ngo
** Date: 03/10/2018
** Description: Class and function declaration for a Forest class,
* derived from Space.
*********************************************************************/
#include "forest.hpp"
#include "space.hpp"
#include "game.hpp"
#include <iostream>
#include <cstdlib>
#include <string>
Forest::Forest()
{}
/*********************************************************************
** Description: event(): Possible events for a Forest area.
*********************************************************************/
void Forest::event(Game* game)
{
int random = (rand() % 10);
switch (random)
{
case 0:
{
if (game->getWeapon() < 1)
{
std::cout << "You find an unattended axe sticking out of a tree stump. Approaching it cautiously, you remove it and arm yourself (+15 Atk)";
game->atkup(15);
game->setWeapon(1);
break;
}
if (game->getArmor() < 1)
{
std::cout << "Stumbling across the remains of a campfire, you find a worn-out, but sturdy pair of boots. They fit you! (+10 Def)";
game->defup(10);
game->setArmor(1);
break;
}
}
case 1:
{
if (game->getStats() < 180)
{
std::cout << "You are assailed by a forest goblin! It tackles you, but you manage to defeat it! (-5 HP, +5 Atk)";
game->hp(-5);
game->atkup(5);
break;
}
if (game->getStats() >= 180)
{
std::cout << "You come across an unguarded goblin encampment and snatch a Forest Fruit from their stores.";
game->addItem(1);
break;
}
}
case 2:
{
if (game->getHealth() < 90)
{
std::cout << "A bit weary from all the travel, you sit and rest next to a stream (HP slightly restored)";
game->hp(10);
break;
}
if (game->getHealth() > 90)
{
std::cout << "Coming across a training dummy used by a long-gone adventurer, you practice fighting and using your weapon. (+10 Atk)";
game->atkup(10);
break;
}
break;
}
case 9:
{
if (game->getWeapon() <= 1)
{
std::cout << "The remains of an adventurer sit against a tree, a sword sitting next to him or her. It will find better use in your hands. (+30 Atk)";
game->atkup(30);
game->setWeapon(2);
break;
}
else
{
std::cout << "You sense the presence of the Pursuer. An ominous feeling shrouds your mind, but you manage to hide from it for now. (-3 Time)";
game->adjTimeLimit(3);
break;
}
}
}
std::cout << std::endl;
}
/*********************************************************************
** Description: greet(): possible messages for Forest areas.
*********************************************************************/
void Forest::greet()
{
int random = (rand() % 6);
switch (random)
{
case 0:
{
std::cout << "A verdant forest greets your eyes as you enter the zone.";
break;
}
case 1:
{
std::cout << "The scent of vegetation tickles your nose.";
break;
}
case 2:
{
std::cout << "You hear the sound of a stream trickling and birds chirping.";
break;
}
case 3:
{
std::cout << "The sounds of nature surround the zone.";
break;
}
case 4:
{
std::cout << "As you enter the zone, twigs crunch beneath your shoes.";
break;
}
case 5:
{
std::cout << "You wander across oak-brown trees with clumps of moss.";
break;
}
}
std::cout << std::endl;
}
/*********************************************************************
** Description: getName(): possible names for Forest areas, including
* two that can be explored.
*********************************************************************/
std::string Forest::getName()
{
setCanExplore(false);
std::string name;
int random = (rand() % 7);
switch (random)
{
case 0:
{
name = "Serene Grove";
setCanExplore(true);
break;
}
case 1:
{
name = "Ancient Forest";
break;
}
case 2:
{
name = "Waterfall Woods";
break;
}
case 3:
{
name = "Whispering Forest";
break;
}
case 4:
{
name = "Vibrant Thicket";
break;
}
case 5:
{
name = "Verdant Woodland";
break;
}
case 6:
{
name = "Verdant Sanctuary";
setCanExplore(true);
break;
}
}
return name;
}
/*********************************************************************
** Description: explore(): possible exploration events for Forest.
*********************************************************************/
void Forest::explore(Game* game)
{
int random = (rand() % 3);
{
switch (random)
{
case 0:
{
std::cout << "Unfortunately, you didn't find anything of value..";
break;
}
case 1:
{
std::cout << "You come across an ancient hero's hideout. You sense the presence of protective wards and rest well. (HP Restored, +5 Def)";
game->hp(100);
game->defup(5);
break;
}
case 2:
{
if (game->getInvSize() < 5)
{
std::cout << "You found an adventurer's abandoned flask of water and put it in your pouch.";
game->addItem(2);
break;
}
else if (game->getInvSize() >= 5)
{
std::cout << "You found some items, but your pouch is full!";
break;
}
}
}
setCanExplore(false);
std::cout << std::endl;
}
}