Repository navigation
Expand file tree
/
Copy pathCommandProcessingDriver.cpp
More file actions
118 lines (96 loc) · 2.55 KB
/
Copy pathCommandProcessingDriver.cpp
File metadata and controls
118 lines (96 loc) · 2.55 KB
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
#include "CommandProcessing.h"
#include "GameEngine.h"
using namespace std;
int main(int argc, char* argv[])
{
//if no argument
if (argc == 1)
{
cout << "no argumnet" << endl;
CommandProcessing::CommandProcessor cp;
while (true)
{
cp.getCommand();
}
}
//if console
else if (argc == 2 && strcmp(argv[1], "-console") == 0)
{
cout << "argssss" << endl;
CommandProcessing::CommandProcessor cp;
while (true)
{
cp.getCommand();
}
}
//if filename is mentioned
else if (argc == 3 && strcmp(argv[1], "-file") == 0)
{
//CommandProcessing::CommandProcessor cp;
CommandProcessing::FileCommandProcessorAdapter fcp(argv[2]);
while (true)
{
fcp.getCommand();
}
}
//If tournament mode
else if (strcmp(argv[1], "tournament") == 0)
{
cout << "tournament command" << endl;
string mapfiles = argv[3];
string playerstrategies = argv[5];
int numberofgames = atoi(argv[7]);
int maxnumberofturns = atoi(argv[9]);
vector<string> listmapfiles;
vector<string> listplayerstrategies;
//Splitting mapfiles argument into a vector
int start = 0;
do {
// Find the index of occurrence
int idx = mapfiles.find(".map", start);
if (idx == string::npos) {
break;
}
int length = idx - start;
listmapfiles.push_back(mapfiles.substr(start, length+4));
start += (length+4);
} while (true);
listmapfiles.push_back(mapfiles.substr(start));
//Splitting mapfiles argument into a vector
start = 0;
do {
// Find the index of occurrence
int idx = playerstrategies.find(".p", start);
if (idx == string::npos) {
break;
}
int length = idx - start;
listplayerstrategies.push_back(playerstrategies.substr(start, length));
start += (length+2);
} while (true);
listplayerstrategies.push_back(playerstrategies.substr(start));
// for(string t: listplayerstrategies)
// cout << t <<endl;
//Validating the command
CommandProcessing::CommandProcessor cp;
bool temp = cp.validate(listmapfiles, listplayerstrategies, numberofgames, maxnumberofturns);
if(temp == false)
{
cout << "Terminating program..." << endl;
exit(0);
}
//Calling GameEngine
GameEngine::GameEngine ge;
ge.tournament(listmapfiles, listplayerstrategies, numberofgames, maxnumberofturns);
}
//else
else
{
cout << argc << endl;
cout << "asdsada" << endl;
cout << argv[0] << endl;
cout << argv[1] << endl;
cout << argv[2] << endl;
cout << "Invalid command line arguments." << endl;
}
}