diff --git a/source/client/panels/MainGamePanel.cpp b/source/client/panels/MainGamePanel.cpp index 47018c00cd9546f48d76ed53e0b31df90e5346d3..3e84d4aa689081460726532871f857af00430a53 100644 --- a/source/client/panels/MainGamePanel.cpp +++ b/source/client/panels/MainGamePanel.cpp @@ -47,8 +47,13 @@ void MainGamePanel::buildGameState(game_state* gameState, player* me) { // this->buildOtherPlayerLabels(gameState, otherPlayer, playerAngle, side); } - // show our own player - this->buildThisPlayer(gameState, me); + bool am_broke = me->get_money() + me->get_bet_size() < gameState->_min_bet; + if (!am_broke) { + // show our own player + this->buildThisPlayer(gameState, me); + } else { + this->buildThisPlayerBroke(); + } // show the number of rounds this->buildRoundCounter(gameState); @@ -176,8 +181,8 @@ void MainGamePanel::buildOthers(game_state* gameState, player* otherPlayer, doub int numberOfCards = otherPlayer->get_hand()->get_nof_cards(); std::string cardImage; - wxSize weirdSize(90, 90); - // weirdSize = boundsOfRotatedHand; + wxSize weirdSize(76, 90); + //weirdSize = boundsOfRotatedHand; double cAngle = playerAngle + MainGamePanel::twoPi/4; int cDist = MainGamePanel::otherPlayerHandSize; wxSize card_dist((int)(sin(cAngle)*cDist), (int)(cos(cAngle) * cDist)); @@ -395,6 +400,17 @@ void MainGamePanel::buildThisPlayer(game_state* gameState, player* me) { } } +void MainGamePanel::buildThisPlayerBroke(){ + wxBoxSizer* outerLayout = new wxBoxSizer(wxHORIZONTAL); + this->SetSizer(outerLayout); + //Display text to tell player he has lost + wxPoint Offset(-100, 200); + wxPoint textPosition = MainGamePanel::tableCenter + Offset; + wxStaticText *playerName = + buildStaticText("You are broke :(", textPosition, wxSize(400, 36), + wxALIGN_CENTER, true); +} + void MainGamePanel::buildRoundCounter(game_state* gameState){ if(gameState->is_started() && gameState->get_current_player() != nullptr) { diff --git a/source/client/panels/MainGamePanel.hpp b/source/client/panels/MainGamePanel.hpp index d3fc853a1f39e733defac834ab51d691f4e9042e..fecf1dc0e15e5a3091a1c03e60ea671a55ebe804 100644 --- a/source/client/panels/MainGamePanel.hpp +++ b/source/client/panels/MainGamePanel.hpp @@ -19,7 +19,8 @@ private: //void buildGameController(); //change this from sds void buildRoundCounter(game_state* gameState); void buildThisPlayer(game_state* gameState, player* me); //in sds this is build myself - void buildShoe(game_state* gameState); + void buildThisPlayerBroke(); + void buildShoe(game_state *gameState); void buildDealer(game_state*); void buildCardPiles(game_state* gameState, player *me); @@ -36,7 +37,7 @@ private: wxSize const cardSize = wxSize(80, 124); - double const otherPlayerHandSize = 140.0; // smaller? + double const otherPlayerHandSize = 130; // smaller? double const otherPlayerBetDistanceFromCenter = 80.0; double const otherPlayerHandDistanceFromCenter = 180.0; diff --git a/source/general/game_state/player.cpp b/source/general/game_state/player.cpp index 70132d07680230963c89203bf56eca30ead83aec..fd99c077613ff11bd5d55437d58b047c35e570c3 100644 --- a/source/general/game_state/player.cpp +++ b/source/general/game_state/player.cpp @@ -61,6 +61,10 @@ int player::get_bet_size() const noexcept { return this->_bet_size->get_value(); } +bool player::is_broke() { + return _money->get_value() <= 0; +} + int player::get_money() const noexcept { return this->_money->get_value(); } @@ -129,9 +133,6 @@ bool player::make_bet(int bet_size, std::string &err) { } -bool player::is_broke() { - return _money->get_value() <= 0; -} void player::won_round() { int winnings = this->get_bet_size(); diff --git a/source/general/game_state/player.hpp b/source/general/game_state/player.hpp index 079b6ffb751a6ca374f94b983ffd8d9713a05fff..85b16e13280968f8150a9a7d988fce92ddb48bea 100644 --- a/source/general/game_state/player.hpp +++ b/source/general/game_state/player.hpp @@ -55,6 +55,7 @@ public: hand* get_hand() const noexcept; std::string get_player_name() const noexcept; void set_finished_turn(); + bool is_broke(); #ifdef BLACKJACK_SERVER // state update functions @@ -65,7 +66,6 @@ public: bool make_bet(int bet_size, std::string &err); // helper functions for game_state - bool is_broke(); // helper functions to calculate winnings void won_round(); void lost_round();