-
Notifications
You must be signed in to change notification settings - Fork 0
/
TheGame.cpp
79 lines (69 loc) · 1.54 KB
/
TheGame.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
#include "TheGame.h"
//-----------------------------------------------------------------------------------------------//
TheGame::TheGame(int _argc, const char* _argv[])
{
mode = nullptr;
argc = _argc;
for (int i = 1; i < argc; i++)
{
argv.push_back(_argv[i]);
}
}
//-----------------------------------------------------------------------------------------------//
void TheGame::start()
{
if (argc != 1 && argc != 2 && argc != 3)
{
cout << "Error: invalid command line inputs!";
return;
}
if (argc == 1) // no any input
{
mode = new SimpleMode;
}
else if (argv[0] == SAVE)
{
if (argc == 2 || argv[1] == SILENT)
{
mode = new SaveMode;
}
else //the second input is invalid
{
cout << "Error: invalid command line inputs!";
return;
}
}
else if (argv[0] == LOAD)
{
if (argc == 2)
{
mode = new LoadMode;
}
else if (argv[1] == SILENT)
{
mode = new SilentMode;
}
else // the second input is invalid
{
cout << "Error: invalid command line inputs!";
return;
}
}
else // the first input us not load or save
{
cout << "Error: invalid command line inputs!";
return;
}
clear_screen();
mode->Game(); // start the game mode that was choosen
}
//-----------------------------------------------------------------------------------------------//
TheGame::~TheGame()
{
if (mode)
{
delete mode;
}
mode = nullptr;
}
//-----------------------------------------------------------------------------------------------//