diff --git a/CMakeLists.txt b/CMakeLists.txt index acf1a3c47f70892e12a61b564c69fe7ea416938e..5fada455fa83e64d528891127065614eb9f0a321 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,6 @@ set(CLIENT_SOURCE_FILES src/common/game_state/cards/deck.cpp src/common/game_state/cards/deck.h # client requests src/common/network/requests/client_request.cpp src/common/network/requests/client_request.h - src/common/network/requests/decide_trump_color_request.cpp src/common/network/requests/decide_trump_color_request.h src/common/network/requests/estimate_tricks_request.cpp src/common/network/requests/estimate_tricks_request.h src/common/network/requests/join_game_request.cpp src/common/network/requests/join_game_request.h src/common/network/requests/leave_game_request.cpp src/common/network/requests/leave_game_request.h @@ -50,8 +49,6 @@ set(CLIENT_SOURCE_FILES src/common/serialization/json_utils.h src/common/serialization/uuid_generator.h src/common/serialization/unique_serializable.cpp src/common/serialization/unique_serializable.h - src/common/network/requests/decide_trump_color_request.cpp - src/common/network/requests/decide_trump_color_request.h src/common/network/requests/leave_game_request.cpp src/common/network/requests/leave_game_request.h src/common/network/requests/estimate_tricks_request.cpp @@ -84,7 +81,6 @@ set(SERVER_SOURCE_FILES src/common/game_state/cards/deck.cpp src/common/game_state/cards/deck.h # client requests src/common/network/requests/client_request.cpp src/common/network/requests/client_request.h - src/common/network/requests/decide_trump_color_request.cpp src/common/network/requests/decide_trump_color_request.h src/common/network/requests/estimate_tricks_request.cpp src/common/network/requests/estimate_tricks_request.h src/common/network/requests/join_game_request.cpp src/common/network/requests/join_game_request.h src/common/network/requests/leave_game_request.cpp src/common/network/requests/leave_game_request.h diff --git a/src/client/GameController.cpp b/src/client/GameController.cpp index 5cbe6edc78089d6d4f9da8935f7a6c0bdb9f225d..5e48993983c88e7a6eb5bdfd7044ef2b1c771c8f 100644 --- a/src/client/GameController.cpp +++ b/src/client/GameController.cpp @@ -308,4 +308,9 @@ void GameController::showGameOverMessage() { if(buttonClicked == wxID_OK) { GameController::_gameWindow->Close(); } +} + +void GameController::closeGameWindow() +{ + GameController::_gameWindow->Close(); } \ No newline at end of file diff --git a/src/client/GameController.h b/src/client/GameController.h index 26413bbde5c8cf1303d79696f8ba4768a0f1be7a..116b46c88d12a14ba5bff70289ed9e5ca68c08ad 100644 --- a/src/client/GameController.h +++ b/src/client/GameController.h @@ -91,6 +91,11 @@ public: */ static void showGameOverMessage(); + /** + * @brief Closes Game Window. + */ + static void closeGameWindow(); + private: static GameWindow* _gameWindow; ///< The window which contains all panels shown to the user. static ConnectionPanel* _connectionPanel; ///< The pannel used to connect to the game. diff --git a/src/client/panels/MainGamePanelWizard.cpp b/src/client/panels/MainGamePanelWizard.cpp index 327acee15cf7e0178e075bac8ba74d247dafdab6..85fd8516c307de57c7611e6146c91423dedcc1da 100644 --- a/src/client/panels/MainGamePanelWizard.cpp +++ b/src/client/panels/MainGamePanelWizard.cpp @@ -71,7 +71,7 @@ void MainGamePanelWizard::buildGameState(game_state* gameState, player* me) } else if (me->has_left_game() == true) { - GameController::showGameOverMessage(); + GameController::closeGameWindow(); return; } else { diff --git a/src/common/game_state/game_state.cpp b/src/common/game_state/game_state.cpp index b7f33508c901288b0da60e3ae73e89eaeb5cafdf..e3b4a24b6e75c9c1990078a0c4ba9af8149f79a1 100644 --- a/src/common/game_state/game_state.cpp +++ b/src/common/game_state/game_state.cpp @@ -249,7 +249,6 @@ void game_state::determine_trump_color() const std::uniform_int_distribution<> distrib(1, 4); _trump_color->set_value(distrib(gen)); _trump_card_value->set_value(15); - // TODO: include get trump_color_request() } } } diff --git a/src/common/network/requests/client_request.cpp b/src/common/network/requests/client_request.cpp index bbf4c2d311f758a6bb882200ac55db20cd4fb7e2..8077e965dc0eacc3c0e69c5301aca7e17168d576 100644 --- a/src/common/network/requests/client_request.cpp +++ b/src/common/network/requests/client_request.cpp @@ -5,7 +5,6 @@ #include "client_request.h" #include "play_card_request.h" #include "estimate_tricks_request.h" -#include "decide_trump_color_request.h" #include "join_game_request.h" #include "start_game_request.h" #include "leave_game_request.h" @@ -18,7 +17,6 @@ const std::unordered_map<std::string, RequestType> client_request::_string_to_re {"start_game", RequestType::start_game}, {"play_card", RequestType::play_card}, {"estimate_tricks", RequestType::estimate_tricks}, - {"decide_trump_color", RequestType::decide_trump_color}, {"leave_game", RequestType::leave_game} }; // for serialization @@ -27,7 +25,6 @@ const std::unordered_map<RequestType, std::string> client_request::_request_type { RequestType::start_game, "start_game"}, { RequestType::play_card, "play_card"}, {RequestType::estimate_tricks, "estimate_tricks"}, - {RequestType::decide_trump_color, "decide_trump_color"}, {RequestType::leave_game, "leave_game"} }; @@ -108,9 +105,6 @@ client_request* client_request::from_json(const rapidjson::Value &json) { else if (request_type == RequestType::estimate_tricks) { return estimate_tricks_request::from_json(json); } - else if (request_type == RequestType::decide_trump_color) { - return decide_trump_color_request::from_json(json); - } else if (request_type == RequestType::leave_game) { return leave_game_request::from_json(json); } diff --git a/src/common/network/requests/client_request.h b/src/common/network/requests/client_request.h index 1182d14cac4a367850967e55de6b4dfc3b6947dd..4b4de0f2f6b3c35f33dc226d42b932d3678c7f30 100644 --- a/src/common/network/requests/client_request.h +++ b/src/common/network/requests/client_request.h @@ -22,7 +22,6 @@ enum RequestType { join_game, start_game, play_card, - decide_trump_color, estimate_tricks, leave_game }; diff --git a/src/common/network/requests/decide_trump_color_request.cpp b/src/common/network/requests/decide_trump_color_request.cpp deleted file mode 100644 index 94ac5ee7810a0889f0438695c8a13a8896e334ce..0000000000000000000000000000000000000000 --- a/src/common/network/requests/decide_trump_color_request.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// -// Created by martinalavanya on 09.11.24. -// - -#include "decide_trump_color_request.h" - -#ifdef WIZARD_SERVER -#include "../../../server/game_instance_manager.h" -#include "../../../server/game_instance.h" -#endif - -// Public constructor -decide_trump_color_request::decide_trump_color_request(std::string game_id, std::string player_id, int trump_color) - : client_request( client_request::create_base_class_properties(RequestType::decide_trump_color, uuid_generator::generate_uuid_v4(), player_id, game_id) ) -{ - _trump_color = trump_color; -} - -// private constructor for deserialization -decide_trump_color_request::decide_trump_color_request(client_request::base_class_properties props, int trump_color) : - client_request(props), - _trump_color(trump_color) -{ } - -decide_trump_color_request* decide_trump_color_request::from_json(const rapidjson::Value &json) { - base_class_properties props = client_request::extract_base_class_properties(json); - if (json.HasMember("trump_color") ) { - return new decide_trump_color_request(props, json["trump_color"].GetInt()); - } else { - throw WizardException("Could not find 'trump_color' in decide_trump_color_request"); - } -} - -void decide_trump_color_request::write_into_json(rapidjson::Value &json, - rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator> &allocator) const { - client_request::write_into_json(json, allocator); - json.AddMember("trump_color", rapidjson::Value(this->_trump_color),allocator); -} diff --git a/src/common/network/requests/decide_trump_color_request.h b/src/common/network/requests/decide_trump_color_request.h deleted file mode 100644 index f8f478c4ca7737dd8c3003a56d9e2f89a1b2c204..0000000000000000000000000000000000000000 --- a/src/common/network/requests/decide_trump_color_request.h +++ /dev/null @@ -1,32 +0,0 @@ -// -// Created by Manuel on 29.01.2021. -// - -#ifndef WIZARD_DECIDE_TRUMP_COLOR_REQUEST_H -#define WIZARD_DECIDE_TRUMP_COLOR_REQUEST_H - -#include <string> -#include "client_request.h" -#include "../../../../rapidjson/include/rapidjson/document.h" - -class decide_trump_color_request : public client_request { - -private: - int _trump_color; - - /* - * Private constructor for deserialization - */ - decide_trump_color_request(base_class_properties, int val); - -public: - - [[nodiscard]] int get_trump_color() const { return this->_trump_color; } - - decide_trump_color_request(std::string game_id, std::string player_id, int trump_color = 1); // why default value of 1?? - virtual void write_into_json(rapidjson::Value& json, rapidjson::Document::AllocatorType& allocator) const override; - static decide_trump_color_request* from_json(const rapidjson::Value& json); -}; - - -#endif //WIZARD_DECIDE_TRUMP_COLOR_REQUEST_H \ No newline at end of file diff --git a/src/server/request_handler.cpp b/src/server/request_handler.cpp index 081e78c901f0926ed53a945a12ec252b12fe8e3c..30a67a9db8953f2b2659919dd0f2bd2be2506eaf 100644 --- a/src/server/request_handler.cpp +++ b/src/server/request_handler.cpp @@ -13,7 +13,6 @@ #include "../common/network/requests/join_game_request.h" #include "../common/network/requests/estimate_tricks_request.h" -#include "../common/network/requests/decide_trump_color_request.h" #include "../common/network/requests/play_card_request.h" #include "../common/network/requests/leave_game_request.h" @@ -111,22 +110,6 @@ request_response* request_handler::handle_request(const client_request* const re } return new request_response("", req_id, false, nullptr, err); } - // ##################### DECIDE TRUMP COLOR ##################### // - /* - case RequestType:: decide_trump_color: { - //TODO: figure out where to get trick estimate from and how to handle request - if (game_instance_manager::try_get_player_and_game_instance(player_id, player, game_instance_ptr, err)) { - int trump_color = ((decide_trump_color_request* )req)->get_trump_color(); //call getter function in decide trump color request - if (game_instance_ptr->decide_trump_color(player, trump_color, err)) { // randomly selects number between 1 and 4 - return new request_response(game_instance_ptr->get_id(), req_id, true, - game_instance_ptr->get_game_state()->to_json(), err); - } - } - return new request_response("", req_id, false, nullptr, err); - - } - */ - // ##################### LEAVE GAME ##################### // case RequestType::leave_game: { // Case 1: player is in a game