2 #ifndef CLIENT__CLIENTGAMEENGINE__H
3 #define CLIENT__CLIENTGAMEENGINE__H
6 #include <SFML/Graphics.hpp>
9 #include <boost/asio.hpp>
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"
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;
45 std::shared_ptr<shared::Player> myself;
46 std::string gameId =
"new";
47 std::atomic<bool> clientConnectedAndReady;
48 std::string serverGameId;
50 std::atomic<bool> endOfTurn;
51 std::vector<std::shared_ptr<shared::Player>> otherPlayers;
52 std::atomic<bool> IATurn;
54 boost::asio::io_context io_context;
56 std::shared_ptr<shared::Map> clientMap;
57 std::atomic<bool> playerTurn;
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);
73 bool tryConnection (std::string
id, std::string username, std::string server, std::string port);
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);
81 void waitToBeReady ();
83 void handleEndTurnButton ();
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