Skip to content

Commit 60e1d48

Browse files
committed
Add new logging feature
1 parent 8ac4301 commit 60e1d48

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
.vscode/
1+
.vscode/
2+
3+
# no spoilers!
4+
LOGS.txt

bin/adventure

440 Bytes
Binary file not shown.

src/adventure.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <vector>
99
#include <thread>
1010
#include <chrono>
11+
#include <fstream>
1112

1213
using namespace std;
1314
using std::this_thread::sleep_for;
@@ -21,7 +22,7 @@ void clrscr()
2122

2223
std::vector<string> enemies { "Zombie", "Ghost", "Ghoul", "Skeleton", "Demon" };
2324

24-
signed char input;
25+
unsigned char input;
2526

2627
class Character
2728
{
@@ -56,6 +57,21 @@ Character Player;
5657

5758
Enemy E;
5859

60+
void log_completion()
61+
{
62+
ofstream logfile;
63+
64+
logfile.open("LOGS.txt");
65+
logfile << "Congratulations!" << endl <<
66+
"Your character, " << Player.name << ", defeated leagues of enemies and claimed the treasure!\n" <<
67+
"They were level " << Player.level << ", with " << Player.exp << " exp points and a remaining health of " << Player.health << " after defeating all of the enemies!\n" <<
68+
"\nI owe you my thanks for playing my game!\no7\n";
69+
70+
logfile.close();
71+
72+
return;
73+
}
74+
5975
void battle(string e_name)
6076
{
6177
E.name = e_name;
@@ -212,6 +228,11 @@ int main()
212228
cout << "With the last enemy defeated, you have found your way to the treasure!" << endl;
213229
cout << "Congratulations for completing the game!" << endl;
214230

231+
sleep_for(milliseconds(3000));
232+
233+
log_completion();
234+
cout << "pssst... a hiddle file has been placed somewhere close to this game... it has something special for you!" << endl;
235+
215236
sleep_for(milliseconds(3000));
216237
break;
217238
}

0 commit comments

Comments
 (0)