-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRPSGame.cpp
69 lines (61 loc) · 1.85 KB
/
RPSGame.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
#include <memory>
#include <string>
#include <algorithm>
#include "src/RPSCore.h"
#include "logger/easylogging++.h"
#include "config/RPSConfig.h"
INITIALIZE_EASYLOGGINGPP
//
// Main entry poin.
// To execute the program, please, specify user you want to be like that:
// "RPSGame.exe UserA[/UserB]"
//
int main(int argc, char *argv[])
{
if (RPSConfig::get().Init())
{
LOG(INFO) << "Starting RSPGame(v.0.1)";
std::string strLoggerCfgPath;
if (RPSConfig::get().GetString("LoggerConfig", strLoggerCfgPath))
{
el::Configurations logConf(strLoggerCfgPath);
el::Loggers::reconfigureLogger("default", logConf);
LOG(INFO) << "Logger config successfully loaded";
}
else
{
LOG(WARNING) << "Using logging with default settings";
}
if (argc < 2)
{
LOG(ERROR) << "[CRITICAL] Invalid number of arguments. Please, use following format: \"RPSGame.exe UserA[/UserB]\"";
}
else
{
std::string strUser(argv[1]);
std::transform(strUser.begin(), strUser.end(), strUser.begin(), ::tolower);
if (strUser == "usera" || strUser == "userb")
{
// We are ready for kick-off
std::unique_ptr<RPSCore> pCore = std::make_unique<RPSCore>();
if (pCore->Initialize(strUser))
{
pCore->Run();
}
else
{
LOG(ERROR) << "[CRITICAL] Core can't be initialized";
}
}
else
{
LOG(ERROR) << "[CRITICAL] Wrong user specified. User can be either UserA or UserB";
}
}
}
else
{
LOG(ERROR) << "[CRITICAL] Can't load main configuration file";
}
return 0;
}