-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
50 lines (48 loc) · 1.38 KB
/
main.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
#include <iostream>
#include "definitions.h"
#include "board.h"
#include "player.h"
#include "aiPlayer.h"
#include "humanPlayer.h"
#include "game.h"
int main(int argc, char const *argv[])
{
if (argc == 2)
{
try
{
// create the board from the file given as argument
Board board(argv[1]);
//an array of pointers to players
Player **players = new Player *[PLAYERS];
players[0] = new HumanPlayer("Harry Potter", 'H', YELLOW);
players[1] = new AiPlayer("Lucius Malfoy", 'L', GREEN);
players[2] = new AiPlayer("Draco Malfoy", 'D', RED);
players[3] = new AiPlayer("Severus Snape", 'S', BLUE);
players[4] = new AiPlayer("Voldemort", 'V', MAGENTA);
Game game(board, players);
game.generateRandomPositions();
game.gameLoop();
for (int i = 0; i < PLAYERS; i++)
{
delete players[i];
}
delete[] players;
}
catch (std::runtime_error &e)
{
std::cerr << e.what() << std::endl;
}
}
else if (argc == 1)
{
std::cerr << "A file is required to start the game!" << std::endl;
return 1;
}
else
{
std::cerr << "Only one file can be given to generate the board!" << std::endl;
return 1;
}
return 0;
}