Civilization
ClientGameEngine.hpp
1 // Generated by dia2code
2 #ifndef CLIENT__CLIENTGAMEENGINE__H
3 #define CLIENT__CLIENTGAMEENGINE__H
4 
5 #include <memory>
6 #include <SFML/Graphics.hpp>
7 #include <vector>
8 #include <string>
9 #include <boost/asio.hpp>
10 
11 namespace client {
12  class GameWindow;
13  class MenuWindow;
14 };
15 namespace shared {
16  class Player;
17  class RuleArgsStruct;
18  class Binary;
19  class Map;
20  class Hexagon;
21 }
22 
23 #include "GameWindow.hpp"
24 #include "MenuWindow.hpp"
25 #include "shared/Player.hpp"
26 #include "shared/RuleArgsStruct.hpp"
27 #include "shared/Binary.hpp"
28 #include "shared/Map.hpp"
29 #include "shared/Hexagon.hpp"
30 
31 namespace client {
32 
35  // Associations
36  // Attributes
37  public:
38  std::shared_ptr<sf::RenderWindow> clientWindow;
39  std::atomic<int> runningWindow = 1;
40  std::atomic<bool> areTextureLoaded = false;
41  std::unique_ptr<GameWindow> clientGame = nullptr;
42  std::unique_ptr<MenuWindow> clientMenu = nullptr;
43  std::vector<int> map;
44  int turn = 0;
45  std::shared_ptr<shared::Player> myself;
46  std::string gameId = "new";
47  std::atomic<bool> clientConnectedAndReady;
48  std::string serverGameId;
49  shared::RuleArgsStruct ruleArgsStruct;
50  std::atomic<bool> endOfTurn;
51  std::vector<std::shared_ptr<shared::Player>> otherPlayers;
52  std::atomic<bool> IATurn;
53  private:
54  boost::asio::io_context io_context;
55  shared::Binary binary;
56  std::shared_ptr<shared::Map> clientMap;
57  std::atomic<bool> playerTurn;
58  // Operations
59  public:
61  void handleInformation (int x, int y);
62  void handleQuitMenu (bool quitDef = false);
63  void renderGame ();
64  void startMenuWindow ();
65  void startGameWindow ();
66  void playGame ();
67  void playMenu ();
68  bool connect (const std::string& serverAddress, int serverPort);
69  void startReceiving ();
70  void registerServerAnswer (const std::string & response);
71  void processServerRequest (std::string request);
72  void askServer ();
73  bool tryConnection (std::string id, std::string username, std::string server, std::string port);
74  bool intersectPointRect (sf::Vector2i point, sf::FloatRect rectangle);
75  void handlePriorityCardPlay (std::string typePlayed, int difficulty, int boxes);
76  void printChat (const std::string& message);
77  void processMessage (boost::asio::streambuf& receiveBuffer);
78  void generateMap (const unsigned height, const unsigned width, const int seed);
79  void loadMap ();
80  void playTurn ();
81  void waitToBeReady ();
82  void runRule (shared::RuleArgsStruct ruleArgs);
83  void handleEndTurnButton ();
84  void randomIA ();
85  // Setters and Getters
86  };
87 
88 };
89 
90 #endif
class ClientGameEngine -
Definition: ClientGameEngine.hpp:34
void startMenuWindow()
Start the loop that manage the MenuWindow.
Definition: ClientGameEngine.cpp:482
void handleQuitMenu(bool quitDef=false)
Change the Window for nothing, Menu or Game.
Definition: ClientGameEngine.cpp:408
ClientGameEngine()
Constructor.
Definition: ClientGameEngine.cpp:26
void playGame()
Loop that is used when the client is in GameMode.
Definition: ClientGameEngine.cpp:522
void startGameWindow()
Start the loop that manage the GameWindow.
Definition: ClientGameEngine.cpp:455
void playMenu()
Loop that is used when the client is in MenuMode.
Definition: ClientGameEngine.cpp:569
bool intersectPointRect(sf::Vector2i point, sf::FloatRect rectangle)
Detect an intersection between a point and a rect.
Definition: ClientGameEngine.cpp:580
void handlePriorityCardPlay(std::string typePlayed, int difficulty, int boxes)
Print which priority card the user wants to play and its difficulty.
Definition: ClientGameEngine.cpp:369
void renderGame()
Loop that manage the entire Engine.
Definition: ClientGameEngine.cpp:490
void handleInformation(int x, int y)
Print where the user click on the GameWindow.
Definition: ClientGameEngine.cpp:333
bool tryConnection(std::string id, std::string username, std::string server, std::string port)
A player is connecting to a Game.
Definition: ClientGameEngine.cpp:428
class Binary -
Definition: Binary.hpp:18
class RuleArgsStruct -
Definition: RuleArgsStruct.hpp:25