diff --git a/source/client/panels/BetPanel.cpp b/source/client/panels/BetPanel.cpp index 037059f4112985fafeca6183a6b9caf2bba49edd..7f4bb99f6b4cd25d19526258117866abdb493dd0 100644 --- a/source/client/panels/BetPanel.cpp +++ b/source/client/panels/BetPanel.cpp @@ -16,8 +16,8 @@ BetPanel::BetPanel(wxWindow* parent, game_state* gameState, player* me) : wxPane } // color of background - wxColor lightGreen = wxColor(210, 210, 210); - this->SetBackgroundColour(lightGreen); + wxColor lightGray = wxColor(210, 210, 210); + this->SetBackgroundColour(lightGray); wxBoxSizer* verticalLayout = new wxBoxSizer(wxVERTICAL); diff --git a/source/general/game_state/game_state.cpp b/source/general/game_state/game_state.cpp index d44cf5bbcf3d08ecb4c35eda5f76c1c57dd2fa0f..3fa48331a10e89692613c361072dfd7ddad9c01e 100644 --- a/source/general/game_state/game_state.cpp +++ b/source/general/game_state/game_state.cpp @@ -125,11 +125,9 @@ bool game_state::everyone_finished() const { unsigned int s = _players.size(); for(unsigned int i = 0; i < s; ++i) { if(!(_players[i]->has_finished_turn()) && !(_players[i]->is_broke())){ - std::cout << "Player " << i << " not finished!" << std::endl << std::flush; return false; } } - std::cout << "Everyone finished" << std::endl << std::flush; return true; } @@ -288,8 +286,6 @@ bool game_state::stand(player* player, std::string& err) { } } -//TODO: makes bets for everyone before the people actually start the round -//TODO: other cases to take into account? bool game_state::make_bet(player* player, int bet_size, std::string& err) { if(!player->is_broke()) { player->make_bet(bet_size, err); @@ -316,8 +312,6 @@ void game_state::update_current_player(std::string& err) { // end of round functions void game_state::wrap_up_round(std::string& err) { - //hardcoded dealer action - int dealer_points = _dealers_hand->get_points(err); for(auto player : _players) { @@ -347,13 +341,6 @@ void game_state::wrap_up_round(std::string& err) { //Flag that setup is required, so game_instance can perform it needs_setup = true; } -// void game_state::compute_dealers_hand() { -// std::string err = "Problems drawing cards for dealer in the end"; -// while(this->get_dealers_hand()->get_points(err)<= 16){ -// this->get_shoe()->draw_card(this->get_dealers_hand(), err); -// } -// } - } #endif diff --git a/source/general/game_state/hand.cpp b/source/general/game_state/hand.cpp index 2ba001b91da5edf5b23d1bb490a2640eb2b42f9f..b4dddf7775d0d01607d1097760159c4eb0fa6016 100644 --- a/source/general/game_state/hand.cpp +++ b/source/general/game_state/hand.cpp @@ -46,10 +46,12 @@ bool hand::add_card(card* new_card, std::string &err) { return true; } +// return how many points a hand is worth int hand::get_points(std::string &err) { int point_sum = 0; int ace_counter = 0; + // find sum of cards + number of aces for (auto card : _cards) { int value = card->get_value(); if (value == 1) { @@ -64,12 +66,15 @@ int hand::get_points(std::string &err) { } int result = 0; - //This assumes either all aces count 11 or all aces count 1 - if (point_sum + 11*ace_counter <= 21){ - result = point_sum + 11*ace_counter; - } - else{ - result = point_sum + ace_counter; + // deal with the aces + if(ace_counter != 0) { + if (point_sum + 11 + ace_counter - 1 <= 21){ + result = point_sum + 11 + ace_counter - 1; + } else { + result = point_sum + ace_counter; + } + } else { + result = point_sum; } return result; diff --git a/source/general/game_state/player.cpp b/source/general/game_state/player.cpp index e821e932cba99db46a68752e509636fc3fa7c472..54e5a6d17947d25f44087c449b3258ca7e79b9de 100644 --- a/source/general/game_state/player.cpp +++ b/source/general/game_state/player.cpp @@ -77,7 +77,6 @@ std::string player::get_player_name() const noexcept { return this->_player_name->get_value(); } -//are we sure we need those void player::set_finished_turn() { this->_finished_turn->set_value(true); } @@ -115,7 +114,6 @@ void player::wrap_up_round(int dealer_points, std::string& err) { } -// TODO: add check if player already has a bet to throw error? 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/shoe.cpp b/source/general/game_state/shoe.cpp index 1ca57ebdb0254fc68be0c75aa5476a9ceabd1ad3..c43a6c6d6c14373973424c78e03a89d3c0528e9b 100644 --- a/source/general/game_state/shoe.cpp +++ b/source/general/game_state/shoe.cpp @@ -27,7 +27,7 @@ shoe::~shoe() { _cards.clear(); } -// implement this correctly +// shuffle the shoe void shoe::shuffle() { std::shuffle(_cards.begin(), _cards.end(), std::mt19937(std::random_device()())); } @@ -43,7 +43,7 @@ void shoe::setup_round(std::string &err) { } _cards.clear(); - // add a fresh set of cards + // add a fresh set of cards (4 decks) for(int deck = 0; deck < 4; ++deck) { for(int suit = 0; suit < 4; ++suit) { for(int value = 1; value <= 13; ++value) { @@ -56,6 +56,7 @@ void shoe::setup_round(std::string &err) { this->shuffle(); } +// draw a card from shoe to given hand card* shoe::draw_card(hand* h, std::string& err) { if (!_cards.empty()) { card* drawn_card = _cards.back();