-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
140 lines (94 loc) · 2.23 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
/***********************************************************
Application : Game-Player
Author(s) : G0D-Developer & YashasDDev
Version : 4.3
Copyright : © 2021 G0D-Developer & YashasDDev
Description : Play games :P
***********************************************************/
#include <iostream>
#include <string>
#include <fstream>
#include "colours.h"
#include "TicTacToe.h"
#include "GuessMyNum.h"
#define PURPLE cout << "\033[0;35m" << endl;
#define WHITE cout << "\033[0;37m" << endl;
#define RED cout << "\033[0;31m" << endl;
#define GREEN cout << "\033[0;32m" << endl;
int menu();
bool isLoggedIN () {
string username, password, un, pw;
WHITE
cout << "Username: ";
PURPLE
cin >> username;
WHITE
cout << "Password: ";
PURPLE
cin >> password;
WHITE
ifstream read(username + ".txt");
getline (read, un);
getline (read, pw);
if ( un == username && pw == password ) {
return true;
} else {
return false;
}
}
int login () {
int choice;
cout << "1. Register \n";
cout << "2. Login \n";
cin >> choice;
if ( choice == 1 ) {
string username, password;
WHITE
cout << "Username: ";
PURPLE
cin >> username;
WHITE
cout << "Password: ";
PURPLE
cin >> password;
WHITE
ofstream file;
file.open(username + ".txt");
file << username << endl << password;
file.close();
login();
} else if ( choice == 2 ) {
bool status = isLoggedIN();
if ( !status ) {
RED
cout << "Login Failed! \a \n";
return 0;
} else if ( status ) {
GREEN
cout << "Login Successful! \a \n \n";
menu();
}
}
}
int main() {
login();
return 0;
}
int menu() {
int choice;
BLUE
std::cout << "Welcome to Game Player! \n\n";
std::cout << "1. Tic Tac Toe \n";
std::cout << "2. Guess My Number \n";
std::cout << "More coming soon! \n";
PURPLE
std::cin >> choice;
if (choice == 1) {
ticTacToe();
} else if (choice == 2) {
guessMyNum();
} else {
cout << "Invalid Choice! \a \n";
menu();
}
}