From a9b2b83e852c6cf882edd6c3767e1541e25f44fc Mon Sep 17 00:00:00 2001 From: spiasecki <spiasecki@student.ethz.ch> Date: Fri, 27 May 2022 12:36:06 +0200 Subject: [PATCH] Removing old adnotations and comments --- source/general/game_state/card.cpp | 2 +- source/general/game_state/card.hpp | 2 +- source/general/game_state/game_state.hpp | 8 +------- source/general/game_state/player.cpp | 2 +- source/general/game_state/player.hpp | 8 +++----- source/general/game_state/shoe.hpp | 3 +-- source/general/network/requests/join_game_request.cpp | 1 - source/general/network/requests/start_game_request.cpp | 2 +- source/general/network/responses/answer_rqst_response.cpp | 2 +- source/general/network/responses/answer_rqst_response.hpp | 2 +- source/general/network/responses/change_gamestate_msg.cpp | 4 ++-- source/general/network/responses/server_response.cpp | 8 ++++---- 12 files changed, 17 insertions(+), 27 deletions(-) diff --git a/source/general/game_state/card.cpp b/source/general/game_state/card.cpp index 0015d98..edf1f37 100644 --- a/source/general/game_state/card.cpp +++ b/source/general/game_state/card.cpp @@ -36,7 +36,7 @@ card *card::from_json(const rapidjson::Value &json) { } } -// is this even correct ? + void card::write_into_json(rapidjson::Value &json, rapidjson::Document::AllocatorType& allocator) const { unique_serializable::write_into_json(json, allocator); diff --git a/source/general/game_state/card.hpp b/source/general/game_state/card.hpp index 05839b9..5f2340d 100644 --- a/source/general/game_state/card.hpp +++ b/source/general/game_state/card.hpp @@ -12,7 +12,7 @@ private: serializable_value<int>* _suit; // '0' for spades, '1' for clubs, '2' for diamonds, '3' for hearts // from_diff constructor - card(std::string id); // what is this exactly ? + card(std::string id); // deserialization constructor card(std::string id, serializable_value<int>* val, serializable_value<int>* suit); public: diff --git a/source/general/game_state/game_state.hpp b/source/general/game_state/game_state.hpp index 573a21b..8721869 100644 --- a/source/general/game_state/game_state.hpp +++ b/source/general/game_state/game_state.hpp @@ -10,9 +10,6 @@ #include "../serialization/serializable_value.h" #include "../serialization/unique_serializable.h" -//TODO: check if legal turn for standing and everything -//TODO: make bets before ppl play - class game_state : public unique_serializable { public: @@ -30,7 +27,7 @@ private: serializable_value<bool>* _is_finished; serializable_value<int>* _round_number; serializable_value<int>* _current_player_idx; - serializable_value<int>* _starting_player_idx; // very possible this variable is NOT needed + serializable_value<int>* _starting_player_idx; // from_diff constructor game_state(std::string id); @@ -85,9 +82,6 @@ public: // end of round functions void wrap_up_round(std::string& err); - // functions from our SDS - // void compute_dealers_hand(); // does hardcoded actions for dealer - //Flag that setup needs to be called bool needs_setup = false; #endif diff --git a/source/general/game_state/player.cpp b/source/general/game_state/player.cpp index 54e5a6d..30a6873 100644 --- a/source/general/game_state/player.cpp +++ b/source/general/game_state/player.cpp @@ -113,7 +113,7 @@ void player::wrap_up_round(int dealer_points, std::string& err) { } } - +// hit and stand are implemented directly in game_state bool player::make_bet(int bet_size, std::string &err) { if(bet_size > this->get_money()) { err = "bet_size is bigger than amount of money the player " + this->_player_name->get_value() + " has."; diff --git a/source/general/game_state/player.hpp b/source/general/game_state/player.hpp index 57e0047..fc29e76 100644 --- a/source/general/game_state/player.hpp +++ b/source/general/game_state/player.hpp @@ -10,7 +10,6 @@ #include "../serialization/unique_serializable.h" #include "../serialization/serializable_value.h" -//TODO: hit implemented in game_state, also set flag if over 21 class player : public unique_serializable { private: @@ -21,7 +20,7 @@ private: hand* _player_hand; -#ifdef BLACKJACK_SERVER // is this macro needed? +#ifdef BLACKJACK_SERVER std::string _game_id; #endif @@ -58,13 +57,12 @@ public: #ifdef BLACKJACK_SERVER // state update functions - void wrap_up_round(int dealer_points, std::string& err); //TODO + void wrap_up_round(int dealer_points, std::string& err); void setup_round(std::string& err); - // player actions (probably not needed) + // player action bool make_bet(int bet_size, std::string &err); - // helper functions for game_state // helper functions to calculate winnings void won_round(); void draw_round(); diff --git a/source/general/game_state/shoe.hpp b/source/general/game_state/shoe.hpp index bf154da..975589e 100644 --- a/source/general/game_state/shoe.hpp +++ b/source/general/game_state/shoe.hpp @@ -11,8 +11,7 @@ #include "../serialization/serializable_value.h" #include "../../../rapidjson/include/rapidjson/document.h" -//TODO: get rid of player in draw card, you just draw a card from the shoe, then you add it to a -//player's hand through fct like hit, stand etc + class shoe : public unique_serializable { private: std::vector<card*> _cards; diff --git a/source/general/network/requests/join_game_request.cpp b/source/general/network/requests/join_game_request.cpp index bd0ecc1..93914f3 100644 --- a/source/general/network/requests/join_game_request.cpp +++ b/source/general/network/requests/join_game_request.cpp @@ -15,7 +15,6 @@ join_game_request::join_game_request(std::string player_id, std::string name) _player_name(name) { } -// do we even want to request joining specific games? join_game_request::join_game_request(std::string game_id, std::string player_id, std::string name) : client_request( client_request::create_base_class_properties(RequestType::join_game, uuid_generator::generate_uuid_v4(), player_id, game_id) ), _player_name(name) diff --git a/source/general/network/requests/start_game_request.cpp b/source/general/network/requests/start_game_request.cpp index c779eee..ac5972a 100644 --- a/source/general/network/requests/start_game_request.cpp +++ b/source/general/network/requests/start_game_request.cpp @@ -1,7 +1,7 @@ #include "start_game_request.hpp" #ifdef BLACKJACK_SERVER -#include "../../../server/game_instance_manager.hpp" //not planned for now ? +#include "../../../server/game_instance_manager.hpp" #include "../../../server/game_instance.hpp" #endif diff --git a/source/general/network/responses/answer_rqst_response.cpp b/source/general/network/responses/answer_rqst_response.cpp index 369ad96..68bd9cd 100644 --- a/source/general/network/responses/answer_rqst_response.cpp +++ b/source/general/network/responses/answer_rqst_response.cpp @@ -4,7 +4,7 @@ #include "../../game_state/game_state.hpp" #ifdef BLACKJACK_CLIENT -#include "../../../client/GameController.hpp" //adapt this if needed! +#include "../../../client/GameController.hpp" #endif diff --git a/source/general/network/responses/answer_rqst_response.hpp b/source/general/network/responses/answer_rqst_response.hpp index fc1dd1d..4f45cb0 100644 --- a/source/general/network/responses/answer_rqst_response.hpp +++ b/source/general/network/responses/answer_rqst_response.hpp @@ -9,7 +9,7 @@ class answer_rqst_response : public server_response { private: bool _success; std::string _err; - std::string _req_id; //not mentioned in SDS! + std::string _req_id; rapidjson::Value* _state_json = nullptr; answer_rqst_response(base_class_properties props, std::string req_id, bool success, rapidjson::Value* state_json, std::string& err); diff --git a/source/general/network/responses/change_gamestate_msg.cpp b/source/general/network/responses/change_gamestate_msg.cpp index 825443b..4fd9937 100644 --- a/source/general/network/responses/change_gamestate_msg.cpp +++ b/source/general/network/responses/change_gamestate_msg.cpp @@ -4,7 +4,7 @@ #include "../../serialization/json_utils.h" #ifdef BLACKJACK_CLIENT -#include "../../../client/GameController.hpp" //adapt if necessary +#include "../../../client/GameController.hpp" #endif change_gamestate_msg::change_gamestate_msg(server_response::base_class_properties props, rapidjson::Value* state_json) : @@ -50,7 +50,7 @@ rapidjson::Value* change_gamestate_msg::get_state_json() const { void change_gamestate_msg::Process() const { try { game_state* state = game_state::from_json(*_state_json); - GameController::updateGameState(state); //do we have this function? + GameController::updateGameState(state); } catch(std::exception& e) { std::cerr << "Failed to extract game_state from change_gamestate_msg" << std::endl diff --git a/source/general/network/responses/server_response.cpp b/source/general/network/responses/server_response.cpp index be5517d..7e4bff1 100644 --- a/source/general/network/responses/server_response.cpp +++ b/source/general/network/responses/server_response.cpp @@ -7,7 +7,7 @@ // for deserialization const std::unordered_map<std::string, ResponseType> server_response::_string_to_response_type = { {"req_response", ResponseType::req_response}, - {"state_diff_msg", ResponseType::state_diff_msg}, //is this even needed ? not in SDS ! + {"state_diff_msg", ResponseType::state_diff_msg}, {"change_gamestate", ResponseType::change_gamestate} }; // for serialization @@ -61,12 +61,12 @@ server_response *server_response::from_json(const rapidjson::Value& json) { ResponseType response_type = server_response::_string_to_response_type.at(type); if (response_type == ResponseType::req_response) { - return answer_rqst_response::from_json(json); //not sure if correct + return answer_rqst_response::from_json(json); } else if (response_type == ResponseType::change_gamestate) { - return change_gamestate_msg::from_json(json); //not sure if correct + return change_gamestate_msg::from_json(json); } else { - throw BlackjackException("Encountered unknown ServerResponse type " + type); //should response_type not be string? + throw BlackjackException("Encountered unknown ServerResponse type " + type); } } throw BlackjackException("Could not determine type of ClientRequest"); -- GitLab