-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
84 lines (73 loc) · 1.87 KB
/
Copy pathmain.cpp
File metadata and controls
84 lines (73 loc) · 1.87 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
#include <iostream>
#include "building.h"
#include "unit.h"
#include "map.h"
#include "game.h"
#include <ctime>
#include <unistd.h>
#include "gen.h"
using namespace std;
int Gen::seed_ = 5489; //Default seed in Mersenne Twister
int main()
{
int seed = 0;
int i=0;
int teams = 2;
int perTeam = 1;
char races[16];
char race;
cout << "How many teams? (2, 3 or 4)" << endl;
cin >> teams;
while (teams < 2 || teams > 4)
{
cout << "Must be between 2 and 4, please enter a valid number" << endl;
cin >> teams;
}
cout << "How many players per team? (between 1 and 4)" << endl;
cin >> perTeam;
while (perTeam < 1 || perTeam > 4)
{
cout << "Must be between 1 and 4, please enter a valid number" << endl;
cin >> perTeam;
}
for(int p = 0; p < perTeam; p++)
{
for(int t = 0; t < teams; t++)
{
cout << "Player " << p << " of team " << t << "? (T, P or Z)" << endl;
cin >> race;
while (race != 't' && race != 'T' && race != 'p' && race != 'P' && race !='Z' && race !='z')
{
cout << "Invalid race, please enter a valid value (T/t, P/p, Z/z)" << endl;
cin >> race;
}
races[p*teams + t] = race;
}
}
cout << "Enter a seed (0 will randomize a seed)" << endl;
cin >> seed;
while (seed < 0 || seed > 32767)
{
cout << "Please enter a value between 0 and 32767" << endl;
cin >> seed;
}
if (seed != 0)
{
Gen::setSeed(seed);
}
else
{
Gen::setSeed((int)time(NULL));
}
BuildingFactory fac;
Game game(fac, teams, perTeam, races);
game.play();
while(game.play())
{
game.diplayMap();
usleep(5000);
i++;
}
cout << "This game lasted " << i << " turns" << endl;
return 0;
}