-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.cpp
More file actions
64 lines (55 loc) · 2.76 KB
/
Node.cpp
File metadata and controls
64 lines (55 loc) · 2.76 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
//Node.cpp
#include <iostream>
#include <string>
#include <thread>
#include <chrono>
#include <algorithm>
#include "Node.h"
using namespace std;
void print_with_pause(string text, int pause_time = 1500){
cout << text << endl;
this_thread::sleep_for(chrono::milliseconds(pause_time));
}
string to_lower(string str) {
transform(str.begin(), str.end(), str.begin(), ::tolower);
return str;
}
void explore_forest(Node* current_location, bool& found_gem, bool& found_sword, bool& found_chest, bool& found_cave) {
print_with_pause(current_location->description);
if (current_location->gem && !found_gem) {
found_gem = true;
print_with_pause("\033[94m💎 You stumbled upon a glittering gem hidden among the ferns!\033[0m");
}
if (current_location->sword && !found_sword) {
found_sword = true;
print_with_pause("\033[92m🗡️ A gleaming sword, adorned with ancient runes, catches your eye!\033[0m");
}
if (current_location->chest && !found_chest) {
found_chest = true;
print_with_pause("\033[93m🎉 You discover a mysterious treasure chest half-buried beneath a magical oak tree!\033[0m");
}
if (current_location->cave && !found_cave) {
found_cave = true;
print_with_pause("\033[95m⛰️️ A hidden underwater cave beckons you with its iridescent glow!\033[0m");
}
if (found_gem && found_sword && found_chest && found_cave) {
print_with_pause("\033[1m\033[91m🌈 Congratulations! You've found all the magical treasures and completed your quest!\033[0m");
return;
}
string direction;
cout << "\033[93m🔍 Which path will you explore next? (north/south/east/west): \033[0m";
cin >> direction;
direction = to_lower(direction);
if (direction == "north" && current_location->north != nullptr) {
explore_forest(current_location->north, found_gem, found_sword, found_chest, found_cave);
} else if (direction == "south" && current_location->south != nullptr) {
explore_forest(current_location->south, found_gem, found_sword, found_chest, found_cave);
} else if (direction == "east" && current_location->east != nullptr) {
explore_forest(current_location->east, found_gem, found_sword, found_chest, found_cave);
} else if (direction == "west" && current_location->west != nullptr) {
explore_forest(current_location->west, found_gem, found_sword, found_chest, found_cave);
} else {
print_with_pause("\033[91m🪄 You encountered a magical barrier, preventing further exploration in that direction. Perhaps there's another path to discover...\033[0m");
explore_forest(current_location, found_gem, found_sword, found_chest, found_cave);
}
}