-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cc
53 lines (50 loc) · 1.41 KB
/
main.cc
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
#include "constants.h"
#include "game.h"
#include <iostream>
#include <memory>
#include <thread>
using namespace std;
int main(int argc, char* argv[])
{
bool isGraphics = true;
bool bonusEnabled = false;
int seed;
int startLevel = 0;
string file1 = SEQUENCE_1;
string file2 = SEQUENCE_2;
for (int i = 1; i < argc; ++i) {
if (TEXT_ARG == argv[i]) {
isGraphics = false;
}
if (BONUS_ARG == argv[i]) {
bonusEnabled = true;
}
if (SEED_ARG == argv[i] && i + 1 < argc) {
try {
seed = stoi(argv[i + 1]);
} catch (...) {
cerr << "Fatal error, invalid seed: " << argv[i + 1] << endl;
}
}
if (SCRIPT_1 == argv[i] && i + 1 < argc) {
file1 = argv[i + 1];
}
if (SCRIPT_2 == argv[i] && i + 1 < argc) {
file2 = argv[i + 1];
}
if (START_LEVEL == argv[i] && i + 1 < argc) {
try {
startLevel = stoi(argv[i + 1]);
} catch (...) {
cerr << "Fatal error, invalid start level: " << argv[i + 1] << endl;
}
}
}
try {
Game game(isGraphics, seed, file1, file2, startLevel, bonusEnabled);
game.startGame();
} catch (...) {
cerr << "Fatal error, could not create game. Contact DMK for more info" << endl;
}
return 0;
}