Civilization
GameEngine.hpp
1 // Generated by dia2code
2 #ifndef SERVER__GAMEENGINE__H
3 #define SERVER__GAMEENGINE__H
4 
5 #include <memory>
6 #include <string>
7 #include <vector>
8 
9 namespace shared {
10  class Map;
11  class Binary;
12 };
13 namespace server {
14  class GameEngine;
15 };
16 namespace shared {
17  class Player;
18  class RuleArgsStruct;
19  class questionAndAnswer;
20  class Rules;
21 }
22 
23 #include "GameState.hpp"
24 #include "shared/Map.hpp"
25 #include "shared/Binary.hpp"
26 #include "shared/Player.hpp"
27 #include "shared/RuleArgsStruct.hpp"
28 #include "shared/questionAndAnswer.hpp"
29 #include "shared/Rules.hpp"
30 
31 namespace server {
32 
34  class GameEngine {
35  // Associations
36  // Attributes
37  public:
38  bool isPublic = true;
39  GameState state;
40  std::shared_ptr<shared::Map> gameMap;
41  private:
42  std::string gameId;
43  std::vector<std::shared_ptr<shared::Player>> players;
44  shared::Binary binary;
45  // Operations
46  public:
47  GameEngine (std::vector<std::shared_ptr<GameEngine>> & games, std::shared_ptr<shared::Player> player);
48  void* handleConnect ();
50  void runGame ();
52  void playTurn ();
55  static std::string generateRandomId (const std::vector<std::shared_ptr<GameEngine>> & games);
56  std::string getId ();
57  std::vector<std::shared_ptr<shared::Player>>& getPlayers ();
58  bool addPlayer (std::shared_ptr<shared::Player> player);
59  void processClientRequest (std::string requestString, std::shared_ptr<shared::Player> player);
60  static std::vector<std::string> splitString (std::string str, char delimiter);
61  std::string askClient (int playerId);
62  void askClient (std::shared_ptr<shared::Player> player);
63  void sendToEveryone (std::string message, bool isBinary = false);
64  std::string getTime ();
65  bool setMapParam (std::string& param, std::string& value);
66  void askClientToPlayARule (std::shared_ptr<shared::Player> player, shared::RuleArgsStruct & RuleArgs);
67  // Setters and Getters
68  };
69 
70 };
71 
72 #endif
class GameEngine -
Definition: GameEngine.hpp:34
void runGame()
This function help to load the map and start the game.
Definition: GameEngine.cpp:60
std::string getTime()
This function return the time under a string format For example, if the time is 1:34pm,...
Definition: GameEngine.cpp:242
void playTurn()
Function allowing a player to play his turn, composed of several action.
void * endOfRoundActions()
Function handling all the actions at the end of a round (ex: check for end of game,...
class Binary -
Definition: Binary.hpp:18
class RuleArgsStruct -
Definition: RuleArgsStruct.hpp:25