1
0
mirror of https://git.zap.org.au/git/trader.git synced 2024-07-21 16:14:14 -04:00

Remove the global variables selection, credit_limit and bid_used

This commit is contained in:
John Zaitseff 2011-07-18 16:22:24 +10:00
parent c123a87cc3
commit 1beb2003ef
5 changed files with 21 additions and 26 deletions

View File

@ -70,8 +70,6 @@ player_info_t player[MAX_PLAYERS]; // Array of players
map_val_t galaxy_map[MAX_X][MAX_Y]; // Map of the galaxy map_val_t galaxy_map[MAX_X][MAX_Y]; // Map of the galaxy
move_rec_t game_move[NUMBER_MOVES]; // Current moves move_rec_t game_move[NUMBER_MOVES]; // Current moves
sel_val_t selection; // Move selected by current player
int max_turn; // Max. number of turns in game int max_turn; // Max. number of turns in game
int turn_number; int turn_number;
int number_players; int number_players;
@ -79,8 +77,6 @@ int current_player;
int first_player; // Who WAS the first player to go? int first_player; // Who WAS the first player to go?
double interest_rate; // Current interest rate double interest_rate; // Current interest rate
double credit_limit; // Credit limit of current player
bool bid_used; // True if bid used for player
bool game_loaded = false; // True if game was loaded from disk bool game_loaded = false; // True if game was loaded from disk
int game_num = 0; // Game number (1-9) int game_num = 0; // Game number (1-9)

View File

@ -163,8 +163,6 @@ extern player_info_t player[MAX_PLAYERS]; // Array of players
extern map_val_t galaxy_map[MAX_X][MAX_Y]; // Map of the galaxy extern map_val_t galaxy_map[MAX_X][MAX_Y]; // Map of the galaxy
extern move_rec_t game_move[NUMBER_MOVES]; // Current moves extern move_rec_t game_move[NUMBER_MOVES]; // Current moves
extern sel_val_t selection; // Move selected by current player
extern int max_turn; // Max. number of turns in game extern int max_turn; // Max. number of turns in game
extern int turn_number; extern int turn_number;
extern int number_players; extern int number_players;
@ -172,8 +170,6 @@ extern int current_player;
extern int first_player; // Who WAS the first player to go? extern int first_player; // Who WAS the first player to go?
extern double interest_rate; // Current interest rate extern double interest_rate; // Current interest rate
extern double credit_limit; // Credit limit of current player
extern bool bid_used; // True if bid used for player
extern bool game_loaded; // True if game was loaded from disk extern bool game_loaded; // True if game was loaded from disk
extern int game_num; // Game number (1-9) extern int game_num; // Game number (1-9)

View File

@ -130,29 +130,28 @@ void select_moves (void)
/*----------------------------------------------------------------------- /*-----------------------------------------------------------------------
Function: get_move - Wait for the player to enter their move Function: get_move - Wait for the player to enter their move
Arguments: (none) Arguments: (none)
Returns: (nothing) Returns: sel_val_t - Choice selected by player
This function displays the galaxy map and the current moves, then waits This function displays the galaxy map and the current moves, then waits
for the player to select one of the moves. On entry, current_player for the player to select one of the moves. On entry, current_player
points to the current player; quit_selected and/or abort_game may be points to the current player; quit_selected and/or abort_game may be
true (if so, get_move() justs returns without waiting for the player to true (if so, get_move() justs returns without waiting for the player to
select a move). On exit, selection contains the choice made by the select a move). The return value is the choice made by the player.
player. Note that two windows (the "Select move" window and the galaxy
map window) are left on the screen: they are closed in process_move(). Note that two windows (the "Select move" window and the galaxy map
window) are left on the screen: they are closed in process_move().
*/ */
void get_move (void) sel_val_t get_move (void)
{ {
int i, x, y; int i, x, y;
sel_val_t selection = SEL_NONE;
if (quit_selected || abort_game) { if (quit_selected || abort_game) {
selection = SEL_QUIT; return SEL_QUIT;
return;
} else {
selection = SEL_NONE;
} }
// Display map without closing window // Display map without closing window
@ -386,19 +385,21 @@ void get_move (void)
} }
} }
} }
return selection;
} }
/*----------------------------------------------------------------------- /*-----------------------------------------------------------------------
Function: process_move - Process the move selected by the player Function: process_move - Process the move selected by the player
Arguments: (none) Arguments: selection - Selection made by current player
Returns: (nothing) Returns: (nothing)
This function processes the move in the global variable selection. It This function processes the move in selection. It assumes the "Select
assumes the "Select move" and galaxy map windows are still open. move" and galaxy map windows are still open.
*/ */
void process_move (void) void process_move (sel_val_t selection)
{ {
if (! quit_selected && ! abort_game) { if (! quit_selected && ! abort_game) {
switch(selection) { switch(selection) {

View File

@ -37,8 +37,8 @@
************************************************************************/ ************************************************************************/
extern void select_moves (void); extern void select_moves (void);
extern void get_move (void); extern sel_val_t get_move (void);
extern void process_move (void); extern void process_move (sel_val_t selection);
extern void next_player (void); extern void next_player (void);

View File

@ -70,9 +70,11 @@ int main (int argc, char *argv[])
// Play the actual game // Play the actual game
init_game(); init_game();
while (! quit_selected && ! abort_game && turn_number <= max_turn) { while (! quit_selected && ! abort_game && turn_number <= max_turn) {
sel_val_t selection;
select_moves(); select_moves();
get_move(); selection = get_move();
process_move(); process_move(selection);
exchange_stock(); exchange_stock();
next_player(); next_player();
} }