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/game.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/game.c') diff --git a/src/game.c b/src/game.c index e2d8f88..c6341a8 100644 --- a/src/game.c +++ b/src/game.c @@ -21,13 +21,14 @@ static void main_loop_client(int sock) { bool running = true; game_state_t state = STATE_CLIENT_WAIT_FOR_HAND_CARDS; - uint8_t round = 1; + uint8_t round = 0; while(running) { switch(state) { case STATE_CLIENT_WAIT_FOR_HAND_CARDS: + round++; state = state_client_wait_for_hand_cards(sock, round); break; @@ -38,11 +39,14 @@ static void main_loop_client(int sock) case STATE_CLIENT_WAIT_FOR_OPEN_CARDS: state = state_client_wait_for_open_cards(sock); break; -#if 0 + case STATE_CLIENT_PLAY_CARDS: state = state_client_play_cards(sock); break; -#endif + + case STATE_CLIENT_GAME_FINISHED: + running = false; + break; default: printf("main_loop_client: entered unknown state\n"); exit(EXIT_FAILURE); @@ -53,7 +57,7 @@ static void main_loop_client(int sock) static void main_loop_server(socket_list_t* client_socks) { bool running = true; - uint8_t round = 1; + uint8_t round = 0; game_state_t state = STATE_SERVER_DEAL_HAND_CARDS; main_stack_t m; @@ -64,17 +68,21 @@ static void main_loop_server(socket_list_t* client_socks) switch(state) { case STATE_SERVER_DEAL_HAND_CARDS: + round++; state = state_server_deal_hand_cards(client_socks, round, &m); break; case STATE_SERVER_WAIT_FOR_OPEN_CARDS: state = state_server_wait_for_open_cards(client_socks); break; -#if 0 + case STATE_SERVER_PLAY_CARDS: - state = state_server_play_cards(client_socks, round); + state = state_server_play_cards(client_socks, &m); + break; + + case STATE_SERVER_GAME_FINISHED: + running = false; break; -#endif default: printf("main_loop_server: entered unknown state\n"); exit(EXIT_FAILURE); -- cgit v1.2.3