-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameEngine.h
More file actions
executable file
·102 lines (93 loc) · 2.76 KB
/
Copy pathGameEngine.h
File metadata and controls
executable file
·102 lines (93 loc) · 2.76 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
#ifndef GAMEENGINE_H
#define GAMEENGINE_H
#include "Factory.h"
#include "Player.h"
#include "TileList.h"
#include "Menu.h"
#include "Utils.h"
#include <string>
#include <sstream>
#include <vector>
using std::string;
class GameEngine
{
public:
//Constructor
GameEngine(Menu *menu);
//Destructor
~GameEngine();
//Fill bag with seed and call playGame()
bool playGame(char const *argv);
//Play game
bool playGame();
//Play a single round
bool playRound();
//Add a new player
Player *addPlayer(string name, bool isAi);
//Add an existing player from save
Player *addPlayer(std::string name, int score, Mosaic *mosaic, bool isAi);
//Helper method for new game
void addPlayers();
//Fill bag using seed
void fillBag(int argc, char **argv);
//Import already filled bag
void fillBag(TileList *bag);
//Import already filled lid
void fillLid(TileList *lid);
//Fill center pile with tiles from vector
void fillCenterPile(std::vector<TileType> centerPileOne);
//Draw tiles from bag and fill factories
void fillFactories(Factory *factories[]);
//Set a pointer to the player whose turn it is
void setPlayerTurn(int playerIndex);
//Displays a help menu
void helpMenu(std::string state);
//Displays game board
void outputBoard();
//Get a random name for the AI
std::string nameAi();
//Return AI logic
std::string returnAiOutput();
//Get valid factory choice for AI
std::string getSuitableFactory(std::string check, TileType colour);
// Getters
Factory *getFactory(int);
Player *getPlayer(int playerIndex);
bool isTurn(Player);
void fillBag(int seed);
void shuffleBag();
bool isPlayer1Turn();
std::vector<TileType> getCenterPile();
TileList *getBag();
TileList *getLid();
Player *getPlayerTurnID();
public:
int playerTurnCount = 0;
int numberOfPlayers;
int pileNum;
int factoryModifier = 0;
int numberOfCenterPiles = 0;
int passThroughKey = 0;
int playerCount = 0;
int numberOfAiPlayers;
std::vector<int> drawnPlayerId;
private:
void changePlayerTurn();
bool hasPlayerWon();
int drawFromCenter(TileType colour, std::vector<TileType>& centerPile);
bool containsFirstPlayer(std::vector<TileType> ¢erPileOne, std::vector<TileType> ¢erPileTwo);
bool roundOver();
bool factoriesAreEmpty();
bool centerPileContains(TileType tileType, std::vector<TileType> centerPile);
bool validLineNum(int lineNum);
bool validFactoryNum(int factoryNum);
std::vector<Player *> players;
Factory **factories;
std::vector<TileType> centerPileOne;
std::vector<TileType> centerPileTwo;
Player *playerTurnID;
TileList *bag;
TileList *lid;
Menu *menu;
};
#endif