From 0a63e1ca1e98e060ddc9ab5ffec4e8c5fb740d10 Mon Sep 17 00:00:00 2001 From: John Zaitseff Date: Fri, 15 Jul 2011 21:13:32 +1000 Subject: [PATCH] Implement the next_player() function --- src/game.c | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/src/game.c b/src/game.c index ac45591..9c3f859 100644 --- a/src/game.c +++ b/src/game.c @@ -1036,6 +1036,9 @@ void get_move (void) void process_move (void) { // @@@ To be written + if (selection == SEL_QUIT) { + quit_selected = true; + } } void exchange_stock (void) @@ -1043,10 +1046,44 @@ void exchange_stock (void) // @@@ To be written } + +/*----------------------------------------------------------------------- + Function: next_player - Get the next player + Arguments: (none) + Returns: (nothing) + + This function sets the global variable current_player to the next + eligible player. If no player is still in the game, quit_selected is + set to true. The variable turn_number is also incremented if required. +*/ + void next_player (void) { - // @@@ To be written - quit_selected = true; + int i; + bool all_out; + + + all_out = true; + for (i = 0; i < number_players; i++) { + if (player[i].in_game) { + all_out = false; + break; + } + } + + if (all_out) { + quit_selected = true; + } else { + do { + current_player++; + if (current_player == number_players) { + current_player = 0; + } + if (current_player == first_player) { + turn_number++; + } + } while (! player[current_player].in_game); + } }