From c7181ee943069bde7f5d468d11ee63c3a535980d Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Tue, 25 Jan 2011 16:12:34 +0100 Subject: finished implementing play_cards function for client/server; added new message type next_action which indicates whether the game is finished or the server will deal new cards --- src/client_game_states.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src/client_game_states.c') diff --git a/src/client_game_states.c b/src/client_game_states.c index 142693e..4fa4266 100644 --- a/src/client_game_states.c +++ b/src/client_game_states.c @@ -60,7 +60,7 @@ game_state_t state_client_wait_for_open_cards(const int sock) return STATE_CLIENT_SELECT_OPEN_CARD;; // just for testing } -game_state_t state_client_play_cards(const int sock, const uint8_t round) +game_state_t state_client_play_cards(const int sock) { data_store_t *ds = data_store(); @@ -103,23 +103,20 @@ game_state_t state_client_play_cards(const int sock, const uint8_t round) } } } -#if 0 - if (we_have_hand_cards) + + if(hand_count_cards(&ds->hand) > 0) // still cards in hand? { return STATE_CLIENT_SELECT_OPEN_CARD; } else { - receive_next_server_action(); - if (server_action == DEAL_CARDS) - { - round++; - return STATE_CLIENT_WAIT_FOR_CARDS; - } - else if (server_action == GAME_FINISHED) + net_recv(sock, msg_type_next_action); + if(!ds->game_finished) // no more cards -> server will deal + return STATE_CLIENT_WAIT_FOR_HAND_CARDS; + else return STATE_CLIENT_GAME_FINISHED; } -#endif + assert(false); return 1337; } -- cgit v1.2.3