-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameEngine.h
91 lines (83 loc) · 2.99 KB
/
GameEngine.h
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
#ifndef GAME_ENGINE_H
#define GAME_ENGINE_H
#include <memory>
#include <algorithm>
#include "Types.h"
#include "Factory.h"
#include "Mosaic.h"
#include "TileBag.h"
#include "Player.h"
#include "Util.h"
#include "Saveload.h"
#include "Linked_List.h"
class GameEngine{
public:
GameEngine();
~GameEngine();
//a function start the game engine, return 0 if the game ends or hit a save;
int start(int mode);
private:
//the save load object
std::shared_ptr<Saveload> saveloadObj;
//the tilebag object
std::shared_ptr<TileBag> tilebag;
//the boxlid vector
vector<char> boxlid;
//All Centre Factory
vector<Factory> centreFactories;
//All Non-Centre Factories
vector<Factory> factories;
//Vector to store all players
vector<Player> listOfPlayers;
//Vector to store all mosaic board for players
vector<Mosaic> playersMosaic;
//Current player for the round, represented by an integer
int currentPlayer;
//First player for next round, -1 indicates a new game
int firstPlayerNextRound;
//Number of player
int numOfPlayer;
//Number of Factory
int numOfFactory;
//Number of Center Factory
int numOfCentreFactory;
//Floor Line or broken
vector<char> floorLine;
//User Turn Command in a linkedList
std::shared_ptr<Linked_List> userCommand;
//BotHumanList for players
vector<int> botHumanList;
//when user starts a new game, game engine calls this method
void newGame();
//game engine calls this method to load a game.
int loadGame();
//Parsing Data
void dataParsing(string gameName);
//this function is used to get userName and create player objects
void setUpPlayers();
//this function setup all the objects for the new game
void objSetup();
//this function set up factories for each round
void setFactories();
//this function returns a 4 or less elements vector array
vector<char> distributeTiles(vector<char> &undistributed_tiles);
//Add tiles into the boxLid
void addTilesToBoxLid(vector<char> tiles);
//below functions are different phases of the game
int startRound();
bool checkEndOfRound();
bool checkEndOfGame();
void playerTurn();
bool playerInput();
void updateTurn(int factoryNo, char tileColour, int mosaicRow, int centreFactToPlace);
bool factoryValidate(int factoryNo, char tileColour);
bool mosaicRowValidate(int mosaicRow, char tileColour);
bool centreFactoryValidate(int factoryNo);
void calculatePoints(int playerIndex, int status);
//All the getters to get the string info of the game
string getAllFactories();
string getAllMosaic();
string getTileBagBoxLid();
string getPlayer();
};
#endif // !GAME_ENGINE_H