diff --git a/CMakeLists.txt b/CMakeLists.txt index 060e39e7cd3313512519ffad474a5040b51966c3..34b7ab75e675a8540dd849667435c77d93b01e98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -117,8 +117,8 @@ else() set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) - target_link_libraries(Blackjack-client ${CMAKE_SOURCE_DIR}/sockpp/cmake-build-debug/libsockpp.dylib Threads::Threads) - target_link_libraries(Blackjack-server ${CMAKE_SOURCE_DIR}/sockpp/cmake-build-debug/libsockpp.dylib Threads::Threads) + target_link_libraries(Blackjack-client ${CMAKE_SOURCE_DIR}/sockpp/cmake-build-debug/libsockpp.so Threads::Threads) + target_link_libraries(Blackjack-server ${CMAKE_SOURCE_DIR}/sockpp/cmake-build-debug/libsockpp.so Threads::Threads) endif() # copy assets (images) to binary directory diff --git a/source/general/game_state/game_state.cpp b/source/general/game_state/game_state.cpp index 91d26ff6d764926f43f59d6a7207b20f8b7dc7c8..d44cf5bbcf3d08ecb4c35eda5f76c1c57dd2fa0f 100644 --- a/source/general/game_state/game_state.cpp +++ b/source/general/game_state/game_state.cpp @@ -136,7 +136,7 @@ bool game_state::everyone_finished() const { bool game_state::round_begin() const { unsigned int s = _players.size(); for(unsigned int i = 0; i < s; ++i) { - if(!(_players[i]->get_bet_size() == 0) && !(_players[i]->is_broke())) + if(_players[i]->get_bet_size() != 0 && !(_players[i]->is_broke())) return false; } return true; diff --git a/source/general/game_state/hand.hpp b/source/general/game_state/hand.hpp index 793f3ecf96fca1012c594ac864dc1258a05b787f..4d76b9a68376cf4e28b6bae6c7c0aaca2395a96b 100644 --- a/source/general/game_state/hand.hpp +++ b/source/general/game_state/hand.hpp @@ -27,7 +27,7 @@ public: const std::vector<card*> get_cards() const; //checked // state update functions - void setup_round(std::string& err); //TODO + void setup_round(std::string& err); //checked bool add_card(card* card, std::string& err); //checked int get_points(std::string &err); //checked diff --git a/unit-tests/hand.cpp b/unit-tests/hand.cpp index 14a4caa0b92ac4edfb0957dc67472ba807faa647..43eb45975e2e6343977ece9704fa056b9103fa01 100644 --- a/unit-tests/hand.cpp +++ b/unit-tests/hand.cpp @@ -223,12 +223,40 @@ TEST_F(HandTest, CountManyCardsWithDuplicates) { EXPECT_EQ(6, player_hand.get_nof_cards()); } +// The setup function has to remove the card in a hand if here is only one +TEST_F(HandTest, SetupRoundOneCard) { + player_hand.add_card(cards[1][0], err); + player_hand.setup_round(err); + std::vector<card*> expected_hand = {}; + EXPECT_EQ(expected_hand, player_hand.get_cards()); +} + +// Adding no cards and calling the setup function should also result in an empty hand +TEST_F(HandTest, SetupRoundNoCards) { + player_hand.setup_round(err); + std::vector<card*> expected_hand = {}; + EXPECT_EQ(expected_hand, player_hand.get_cards()); +} + // The setup function has to remove all cards in a hand -TEST_F(HandTest, SetupRound) { +TEST_F(HandTest, SetupRoundManyCards) { player_hand.add_card(cards[1][0], err); player_hand.add_card(cards[7][0], err); player_hand.add_card(cards[9][0], err); player_hand.setup_round(err); std::vector<card*> expected_hand = {}; - EXPECT_EQ(expected_hand, player_hand); + EXPECT_EQ(expected_hand, player_hand.get_cards()); +} + +// Adding no cards and calling the setup function should also result in an empty hand +TEST_F(HandTest, SetupRoundManyCardsWithDuplicates) { + player_hand.add_card(cards[1][0], err); + player_hand.add_card(cards[1][1], err); + player_hand.add_card(cards[1][2], err); + player_hand.add_card(cards[7][0], err); + player_hand.add_card(cards[7][0], err); + player_hand.add_card(cards[9][0], err); + player_hand.setup_round(err); + std::vector<card*> expected_hand = {}; + EXPECT_EQ(expected_hand, player_hand.get_cards()); } \ No newline at end of file