-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
371 lines (329 loc) · 15.3 KB
/
main.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
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
#include "characters.h"
#include "mobs.h"
#include "fightMech.h"
#include "locations.h"
#include "shop.h"
#include "ASCII.h"
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main() {
while(true){
srand(time(0)); // Seed the random number generator
cout << "Welcome to Dragon Quest!" << endl;
displayDragonQuest();
Character player;
int alpha = 0;
while (alpha == 0) {
cout << "\nChoose the type of Warrior you want to become: " << endl;
cout << "1. Swordsman" << endl;
cout << "2. Spartan" << endl;
cout << "3. Wizard" << endl;
cout << "4. Archer" << endl;
cout << "0. Exit the game" << endl;
int c1; //choice 1
cin >> c1;
cout << endl;
if (c1 == 0) {
cout << "Exiting the game. Goodbye!" << endl;
break;
}
player = selectCharacter(c1); // Select character based on user input
if(player.type == "Swordsman"){
displaySword();
}
if(player.type == "Spartan"){
}
if(player.type == "Wizard"){
displayMage();
}
if(player.type == "Archer"){
displayArcher();
}
displayStats(player); // Display player stats
cout << "Good morning player you have woken up in your village!" << endl << "Your goal is to become strong enough and kill the dragon that has been tormenting the lands" << endl << "Kill mobs and trade goods to increase your stats" << endl;
string location;
location = "Village";
int beta = 0;
while(beta == 0){
if(location == "Village"){
cout << "What do you want to do in the village?" << endl;
cout << "Press 1 to look for mobs" << endl;
cout << "press 2 to sleep and replenish Health" << endl;
cout << "Press 3 to travel" << endl;
int c2;
cin >> c2; //choice 2
cout << endl;
Mob opponent;
switch (c2)
{
case 1:
cout << "a mob appeared" << endl;
opponent = spawnRandomMob(location);
if(opponent.name == "Wolf"){
displayWolf();
}
if(opponent.name == "Skeleton"){
displaySkeleton();
}
if(opponent.name == "Witch"){
displayWitch();
}
if(opponent.name == "Thug"){
}
displayStatsMob(opponent);
cout << "A " << opponent.name << " stands in front of you " << endl << "Do you want to fight or run away" << endl;
fight(opponent, player);
if(player.hp <= 0){
cout << " You Died!" << endl;
cout << "\t\t GAME OVER " << endl;
alpha = alpha + 1;
beta = beta + 1;
}
break;
case 2:
cout << "you heatlh has replenished" << endl;
player.hp = 120;
displayStats(player);
break;
case 3:
cout << "Where do you want to travel" << endl;
location = chooseLocation();
break;
default:
cout << "Enter a valid option" << endl;
cout << "What do you want to do in the village?" << endl;
cout << "Press 1 to look for mobs" << endl;
cout << "press 2 to sleep and replenish Health" << endl;
cout << "Press 3 to travel" << endl;
}
}
else if( location == "Jungle"){
cout << "You are in the Jungle. Wild creatures lurk behind every tree!" << endl;
cout << "Press 1 to search for mobs" << endl;
cout << "Press 2 to enter the cave" << endl;
cout << "Press 3 to travel " << endl;
int c2;
cin >> c2;
cout << endl;
if (c2 == 1) {
Mob opponent = spawnRandomMob(location);
if(opponent.name == "Wolf"){
displayWolf();
}
if(opponent.name == "Skeleton"){
displaySkeleton();
}
if(opponent.name == "Witch"){
displayWitch();
}
if(opponent.name == "Thug"){
}
displayStatsMob(opponent);
cout << "A " << opponent.name << " approaches!" << endl;
fight(opponent, player); // Engage in combat
if(player.hp <= 0){
cout << " You Died!" << endl;
cout << "\t\t GAME OVER " << endl;
alpha = alpha + 1;
beta = beta + 1;
}
}else if(c2 == 2){
displayCentaur();
cout << "Beware you are entering the cave of Cenaturs" << endl;
cout << "The half human half horse is a tough beast to kill " << endl;
cout << "do you wish to enter?"<< endl;
cout << "Press y for yes and n for no" << endl;
char c3;
cin >> c3;
cout << endl;
if( c3 == 'y' || c3 == 'Y'){
Mob opponent = spawnCentaur(location);
displayStatsMob(opponent);
cout << "The " << opponent.name << " Bellows at you!" << endl;
fight(opponent, player);
if(player.hp <= 0){
cout << " You Died!" << endl;
cout << "\t\t GAME OVER " << endl;
alpha = alpha + 1;
beta = beta + 1;
}
}
else if(c3 == 'n' || c3 == 'N'){
cout << "you ran away" << endl;
}
}
else if (c2 == 3) {
location = chooseLocation(); // Travel to another location
} else {
cout << "Invalid option." << endl;
}
}
else if( location == "Town"){
cout << "You are now in the Town. It's a peaceful place to rest and trade." << endl;
cout << "Press 1 to look for mobs" << endl;
cout << "Press 2 to buy Items" << endl;
cout << "Press 3 to sleep in the travern and replenish health " << endl;
cout << "Press 4 to travel " << endl;
int c2;
cin >> c2;
cout << endl;
if (c2 == 1) {
Mob opponent = spawnRandomMob(location);
displayStatsMob(opponent);
if(opponent.name == "Wolf"){
displayWolf();
}
if(opponent.name == "Skeleton"){
displaySkeleton();
}
if(opponent.name == "Witch"){
displayWitch();
}
if(opponent.name == "Thug"){
}
cout << "A " << opponent.name << " appears!" << endl;
fight(opponent, player);
if(player.hp <= 0){
cout << " You Died!" << endl;
cout << "\t\t GAME OVER " << endl;
alpha = alpha + 1;
beta = beta + 1;
}
}
else if(c2 == 2) {
player = shop(player);
}
else if(c2 == 3) {
cout << "Rent for the travern is 5 coins, do you want to sleep and replenish health?" << endl;
char c3;
cout << " Press y for yes and n for no" << endl;
cin >> c3;
cout << endl;
if(c3 == 'y' || c3 == 'Y'){
if(player.purse >= 5){
cout << "Your health is FULL!" << endl;
player.purse -= 5;
player.hp = 120;
displayStats(player);
}
else{
cout << "You dont have enough money, go kill some mobs" << endl;
}
}else if(c3 == 'n' || c3 == 'N'){
cout << "You can come back to the travern anytime to regain health" << endl;
}
}
else if (c2 == 4) {
location = chooseLocation(); // Travel to another location
} else {
cout << "Invalid option." << endl;
}
}
else if( location == "Castle"){
cout << "You are at the Castle. It stands tall and mysterious." << endl;
cout << "Press 1 to search for mobs" << endl;
cout << "Press 2 to enter the dungeons" << endl;
cout << "Press 3 to travel to another location" << endl;
int c2;
cin >> c2;
cout << endl;
if (c2 == 1) {
Mob opponent = spawnRandomMob(location);
if(opponent.name == "Wolf"){
displayWolf();
}
if(opponent.name == "Skeleton"){
displaySkeleton();
}
if(opponent.name == "Witch"){
displayWitch();
}
if(opponent.name == "Thug"){
}
displayStatsMob(opponent);
cout << "A " << opponent.name << " challenges you!" << endl;
fight(opponent, player);
if(player.hp <= 0){
cout << " You Died!" << endl;
cout << "\t\t GAME OVER " << endl;
alpha = alpha + 1;
beta = beta + 1;
}
}
else if (c2 == 2){
displayminataur1();
cout << "Beware you are entering the lair of minotaurs" << endl;
cout << "The half human half bull is a tough beast to kill " << endl;
cout << "do you wish to enter?"<< endl;
cout << "Press y for yes and n for no" << endl;
char c3;
cin >> c3;
cout << endl;
if( c3 == 'y' || c3 == 'Y'){
Mob opponent = spawnMinotaur(location);
displayStatsMob(opponent);
cout << "The " << opponent.name << " Bellows at you!" << endl;
fight(opponent, player);
if(player.hp <= 0){
cout << " You Died!" << endl;
cout << "\t\t GAME OVER " << endl;
alpha = alpha + 1;
beta = beta + 1;
}
}
else if(c3 == 'n' || c3 == 'N'){
cout << "you ran away" << endl;
}
}
else if (c2 == 3) {
location = chooseLocation(); // Travel to another location
} else {
cout << "Invalid option." << endl;
}
}
else if( location == "Dragon's Lair"){
cout << "Press 1 to enter the Lair" << endl;
cout << "Press 2 to travel to another location" << endl;
int c2;
cin >> c2;
cout << endl;
if (c2 == 1) {
Mob opponent = spawnDragon(location);
displayStatsMob(opponent);
cout << "The " << opponent.name << " spits fire in the sky!" << endl;
fight(opponent, player);
if(player.hp <= 0){
cout << " You Died!" << endl;
cout << "\t\t GAME OVER " << endl;
alpha = alpha + 1;
beta = beta + 1;
}
if(opponent.hp <= 0){
cout << "You killed the dragon!" << endl;
cout << "Congratulations" << endl;
cout << "You have successfully completed the game" << endl;
alpha = alpha + 1;
beta = beta + 1;
}
}
else if (c2 == 2){
location = chooseLocation();
}
}
}
}
cout << "You are dead " << endl;
cout << "Press 1 to play again" << endl;
cout << "Press 2 to quit" << endl;
int c4;
cin >> c4;
cout << endl;
if(c4 == 1){
}else{
break;
}
}
return 0;
}