mirror of
https://git.zap.org.au/git/trader.git
synced 2024-12-04 14:46:45 -05:00
Rename sel_val_t to selection_t; add values useful for exchange_stock()
This commit is contained in:
parent
84b4972f93
commit
c686d2f548
@ -122,6 +122,10 @@ typedef enum map_val {
|
||||
#define IS_MAP_COMPANY(m) ((m) >= MAP_A && (m) <= MAP_LAST)
|
||||
#define PRINTABLE_MAP_VAL(m) ((char) (m))
|
||||
|
||||
#define COMPANY_TO_KEY(i) ((i) + 'A')
|
||||
#define KEY_TO_COMPANY(k) ((k) - 'A')
|
||||
#define IS_COMPANY_KEY(k) ((k) >= 'A' && (k) < COMPANY_TO_KEY(MAX_COMPANIES))
|
||||
|
||||
|
||||
// Information about a move
|
||||
typedef struct move_rec {
|
||||
@ -135,16 +139,22 @@ typedef struct move_rec {
|
||||
|
||||
|
||||
// Player moves / selection values
|
||||
typedef enum sel_val {
|
||||
typedef enum selection {
|
||||
SEL_COMPANY_FIRST = 0,
|
||||
SEL_COMPANY_LAST = MAX_COMPANIES - 1,
|
||||
|
||||
SEL_MOVE_FIRST = 0,
|
||||
SEL_MOVE_LAST = NUMBER_MOVES - 1,
|
||||
SEL_MOVE_NUMBER_MOVES = NUMBER_MOVES,
|
||||
|
||||
SEL_BANKRUPT, // Player wishes to give up
|
||||
SEL_SAVE, // Save and end the game
|
||||
SEL_QUIT, // Just end the game
|
||||
|
||||
SEL_BANK, // Visit the Trading Bank
|
||||
SEL_EXIT, // Exit the Stock Exchange
|
||||
|
||||
SEL_NONE = -1 // Nothing yet selected
|
||||
} sel_val_t;
|
||||
} selection_t;
|
||||
|
||||
|
||||
// Company names
|
||||
|
13
src/move.c
13
src/move.c
@ -130,9 +130,9 @@ 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)
|
||||
Returns: sel_val_t - Choice selected by player
|
||||
Returns: selection_t - Choice selected by player
|
||||
|
||||
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
|
||||
@ -144,10 +144,10 @@ void select_moves (void)
|
||||
window) are left on the screen: they are closed in process_move().
|
||||
*/
|
||||
|
||||
sel_val_t get_move (void)
|
||||
selection_t get_move (void)
|
||||
{
|
||||
int i, x, y;
|
||||
sel_val_t selection = SEL_NONE;
|
||||
selection_t selection = SEL_NONE;
|
||||
|
||||
|
||||
if (quit_selected || abort_game) {
|
||||
@ -257,6 +257,7 @@ sel_val_t get_move (void)
|
||||
|
||||
default:
|
||||
beep();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -399,7 +400,7 @@ sel_val_t get_move (void)
|
||||
move" and galaxy map windows are still open.
|
||||
*/
|
||||
|
||||
void process_move (sel_val_t selection)
|
||||
void process_move (selection_t selection)
|
||||
{
|
||||
if (! quit_selected && ! abort_game) {
|
||||
switch(selection) {
|
||||
@ -936,7 +937,7 @@ void adjust_values (void)
|
||||
int which;
|
||||
|
||||
// Declare a company bankrupt!
|
||||
if (randf() < COMPANY_BANKRUPTCY) {
|
||||
if (randf() > (1.0 - COMPANY_BANKRUPTCY)) {
|
||||
which = randi(MAX_COMPANIES);
|
||||
|
||||
if (company[which].on_map) {
|
||||
|
@ -37,8 +37,8 @@
|
||||
************************************************************************/
|
||||
|
||||
extern void select_moves (void);
|
||||
extern sel_val_t get_move (void);
|
||||
extern void process_move (sel_val_t selection);
|
||||
extern selection_t get_move (void);
|
||||
extern void process_move (selection_t selection);
|
||||
|
||||
extern void next_player (void);
|
||||
|
||||
|
@ -70,7 +70,7 @@ int main (int argc, char *argv[])
|
||||
// Play the actual game
|
||||
init_game();
|
||||
while (! quit_selected && ! abort_game && turn_number <= max_turn) {
|
||||
sel_val_t selection;
|
||||
selection_t selection;
|
||||
|
||||
select_moves();
|
||||
selection = get_move();
|
||||
|
Loading…
Reference in New Issue
Block a user