1
0
mirror of https://git.zap.org.au/git/trader.git synced 2024-10-27 18:20:13 -04:00

Allow localisation of company letters and map moves (choices)

This commit is contained in:
John Zaitseff 2011-08-18 12:10:33 +10:00
parent a024ad83e7
commit 6ef7c7b6da
8 changed files with 251 additions and 89 deletions

View File

@ -196,15 +196,29 @@ void exchange_stock (void)
// Get the actual selection made by the player // Get the actual selection made by the player
while (selection == SEL_NONE) { while (selection == SEL_NONE) {
int key = toupper(gettxchar(curwin)); bool found;
if (IS_COMPANY_KEY(key)) { int key = gettxchar(curwin);
if (company[KEY_TO_COMPANY(key)].on_map) {
selection = KEY_TO_COMPANY(key); if (isupper(*keycode_company)) {
} else { key = toupper(key);
beep(); } else if (islower(*keycode_company)) {
key = tolower(key);
}
for (i = 0, found = false; keycode_company[i] != '\0'; i++) {
if (keycode_company[i] == key) {
found = true;
if (company[i].on_map) {
selection = i;
} else {
beep();
}
break;
} }
} else { }
if (! found) {
switch (key) { switch (key) {
case '1': case '1':
curs_set(CURS_OFF); curs_set(CURS_OFF);

View File

@ -108,6 +108,48 @@ static int cmp_player (const void *a, const void *b);
void init_game (void) void init_game (void)
{ {
/* Initialise strings used for keycode input and map representations.
Each string must have an ASCII vertical line (U+007C) in the
correct position, followed by context information (such as
"input|Company" and "output|MapVals"). This is done to overcome a
limitation of gettext_noop() and N_() that does NOT allow context
IDs. This vertical line is replaced by a NUL character to
terminate the resulting string. The vertical line MAY appear in
other positions; if so, it is handled correctly. */
keycode_company = xstrdup(gettext(default_keycode_company));
if (strlen(keycode_company) < MAX_COMPANIES + 1
|| keycode_company[MAX_COMPANIES] != '|') {
err_exit(_("keycode string for companies has incorrect format: `%s'"),
keycode_company);
}
keycode_company[MAX_COMPANIES] = '\0';
keycode_game_move = xstrdup(gettext(default_keycode_game_move));
if (strlen(keycode_game_move) < NUMBER_MOVES + 1
|| keycode_game_move[NUMBER_MOVES] != '|') {
err_exit(_("keycode string for game moves has incorrect format: `%s'"),
keycode_game_move);
}
keycode_game_move[NUMBER_MOVES] = '\0';
printable_map_val = xstrdup(gettext(default_printable_map_val));
if (strlen(printable_map_val) < MAX_COMPANIES + 4
|| printable_map_val[MAX_COMPANIES + 3] != '|') {
err_exit(_("output string for companies has incorrect format: `%s'"),
printable_map_val);
}
printable_map_val[MAX_COMPANIES + 3] = '\0';
printable_game_move = xstrdup(gettext(default_printable_game_move));
if (strlen(printable_game_move) < NUMBER_MOVES + 1
|| printable_game_move[NUMBER_MOVES] != '|') {
err_exit(_("output string for game moves has incorrect format: `%s'"),
printable_game_move);
}
printable_game_move[NUMBER_MOVES] = '\0';
// Try to load an old game, if possible // Try to load an old game, if possible
if (game_num != 0) { if (game_num != 0) {
chtype *chbuf = xmalloc(BUFSIZE * sizeof(chtype)); chtype *chbuf = xmalloc(BUFSIZE * sizeof(chtype));
@ -238,7 +280,7 @@ void init_game (void)
static int ask_number_players (void) static int ask_number_players (void)
{ {
char *keys_contgame; char *keycode_contgame;
chtype *chbuf; chtype *chbuf;
int lines, maxwidth; int lines, maxwidth;
int widthbuf[2]; int widthbuf[2];
@ -269,7 +311,7 @@ static int ask_number_players (void)
first character (keyboard input code) is used to print the user's first character (keyboard input code) is used to print the user's
response if one of those keys is pressed. Both upper and response if one of those keys is pressed. Both upper and
lower-case versions should be present. */ lower-case versions should be present. */
keys_contgame = xstrdup(pgettext("input|ContinueGame", "Cc")); keycode_contgame = xstrdup(pgettext("input|ContinueGame", "Cc"));
done = false; done = false;
while (! done) { while (! done) {
@ -279,8 +321,8 @@ static int ask_number_players (void)
wechochar(curwin, key | A_BOLD); wechochar(curwin, key | A_BOLD);
ret = key - '0'; ret = key - '0';
done = true; done = true;
} else if (strchr(keys_contgame, key) != NULL) { } else if (strchr(keycode_contgame, key) != NULL) {
wechochar(curwin, ((unsigned char) *keys_contgame) | A_BOLD); wechochar(curwin, ((unsigned char) *keycode_contgame) | A_BOLD);
ret = 0; ret = 0;
done = true; done = true;
} else { } else {
@ -302,7 +344,7 @@ static int ask_number_players (void)
} }
curs_set(CURS_OFF); curs_set(CURS_OFF);
free(keys_contgame); free(keycode_contgame);
return ret; return ret;
} }
@ -687,6 +729,8 @@ void show_status (int num)
val = total_value(num); val = total_value(num);
if (val == 0.0) { if (val == 0.0) {
center(curwin, 11, 0, attr_normal, attr_highlight, attr_blink, 1, center(curwin, 11, 0, attr_normal, attr_highlight, attr_blink, 1,
/* TRANSLATORS: The current player is bankrupt (has no
shares or cash, ie, whose total value is zero) */
_("^[* * * B A N K R U P T * * *^]")); _("^[* * * B A N K R U P T * * *^]"));
} else { } else {
w = getmaxx(curwin); w = getmaxx(curwin);

View File

@ -54,6 +54,52 @@ const char *company_name[MAX_COMPANIES] = {
}; };
// Default keycodes (keyboard input characters) for each company
const char *default_keycode_company =
/* TRANSLATORS: This string specifies the keycodes (keyboard input
codes) used to enter the Stock Transaction window for each
company. There must be exactly eight characters, one for each
company in order, before the ASCII vertical line "|"; these must
be EITHER all in upper-case or all in lower-case. If at all
possible, these should be successive letters in your alphabet (in
English, "A" to "H"). Do NOT use digits or control characters.
Do not change or translate anything after the vertical line. */
N_("ABCDEFGH|input|Companies");
// Default keycodes (keyboard input characters) for each move
const char *default_keycode_game_move =
/* TRANSLATORS: This string specifies the keycodes used to select a
game move. There must be exactly 20 characters, one for each
move, before the ASCII vertical line "|"; these must be EITHER all
in upper-case or all in lower-case. If at all possible, these
should be successive letters in your alphabet. Do NOT use digits
or control characters. Do not change or translate anything after
the vertical line. */
N_("ABCDEFGHIJKLMNOPQRST|input|GameMoves");
// Default printable output representations for each map element
const char *default_printable_map_val =
/* TRANSLATORS: This string is used to display the galaxy map to
screen. There must be exactly 11 characters before the ASCII
vertical line. The first ("." in English) is used for empty
space, the second ("+") for outposts, the third ("*") for stars,
the remaining for the eight companies. Do not change or translate
anything after the vertical line. */
N_(".+*ABCDEFGH|output|MapVals");
// Default printable output representations for each move
const char *default_printable_game_move =
/* TRANSLATORS: This string is used to display the game moves
(choices). There must be exactly 20 characters before the ASCII
vertical line. The first character corresponds to the first
character in the "input|GameMoves" string, and so on. Do not
change or translate anything after the vertical line. */
N_("abcdefghijklmnopqrst|output|GameMoves");
// Ordinal strings // Ordinal strings
const char *ordinal[MAX_PLAYERS + 1] = { const char *ordinal[MAX_PLAYERS + 1] = {
"", "",
@ -82,6 +128,11 @@ 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
char *keycode_company; // Keycodes for each company
char *keycode_game_move; // Keycodes for each game move
char *printable_map_val; // Printable output for each map value
char *printable_game_move; // Printable output for each game move
int max_turn; // Max. number of turns in game int max_turn; // Max. number of turns in game
int turn_number; // Current turn (1 to max_turn) int turn_number; // Current turn (1 to max_turn)
int number_players; // Number of players int number_players; // Number of players

View File

@ -130,11 +130,11 @@ typedef enum map_val {
#define MAP_TO_COMPANY(m) ((m) - MAP_A) #define MAP_TO_COMPANY(m) ((m) - MAP_A)
#define IS_MAP_COMPANY(m) ((m) >= MAP_A && (m) <= MAP_LAST) #define IS_MAP_COMPANY(m) ((m) >= MAP_A && (m) <= MAP_LAST)
#define PRINTABLE_MAP_VAL(m) ((char) (m)) #define PRINTABLE_MAP_VAL(m) \
(((m) == MAP_EMPTY) ? printable_map_val[0] : \
#define COMPANY_TO_KEY(i) ((i) + 'A') (((m) == MAP_OUTPOST) ? printable_map_val[1] : \
#define KEY_TO_COMPANY(k) ((k) - 'A') (((m) == MAP_STAR) ? printable_map_val[2] : \
#define IS_COMPANY_KEY(k) ((k) >= 'A' && (k) < COMPANY_TO_KEY(MAX_COMPANIES)) printable_map_val[(m) - MAP_A + 3])))
// Information about a move // Information about a move
@ -143,9 +143,7 @@ typedef struct move_rec {
int y; int y;
} move_rec_t; } move_rec_t;
#define MOVE_TO_KEY(m) ((m) + 'a') #define PRINTABLE_GAME_MOVE(m) (printable_game_move[m])
#define KEY_TO_MOVE(k) ((k) - 'a')
#define IS_MOVE_KEY(k) ((k) >= 'a' && (k) < MOVE_TO_KEY(NUMBER_MOVES))
// Player moves / selection values // Player moves / selection values
@ -170,6 +168,18 @@ typedef enum selection {
// Company names // Company names
extern const char *company_name[MAX_COMPANIES]; extern const char *company_name[MAX_COMPANIES];
// Default keycodes (keyboard input characters) for each company
extern const char *default_keycode_company;
// Default keycodes (keyboard input characters) for each move
extern const char *default_keycode_game_move;
// Default printable output representations for each map element
extern const char *default_printable_map_val;
// Default printable output representations for each move
extern const char *default_printable_game_move;
// Ordinal strings // Ordinal strings
extern const char *ordinal[MAX_PLAYERS + 1]; extern const char *ordinal[MAX_PLAYERS + 1];
@ -183,6 +193,11 @@ 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 char *keycode_company; // Keycodes for each company
extern char *keycode_game_move; // Keycodes for each game move
extern char *printable_map_val; // Printable output for each map value
extern char *printable_game_move; // Printable output for each game move
extern int max_turn; // Max. number of turns in game extern int max_turn; // Max. number of turns in game
extern int turn_number; // Current turn (1 to max_turn) extern int turn_number; // Current turn (1 to max_turn)
extern int number_players; // Number of players extern int number_players; // Number of players

View File

@ -44,9 +44,10 @@ static const char *help_text[] = {
Each string is a single page of text that is displayed in an area 76 Each string is a single page of text that is displayed in an area 76
columns wide by 16 lines high. Ideally, each line within the string columns wide by 16 lines high. Ideally, each line within the string
should be (manually) space-justified or centred; each line is should be (manually) space-justified or centred; each line is
separated by "\n". If a string starts with "@" as the very first separated by "\n". TAB characters and other control codes must NOT
character, that string (and all strings following) are ignored: this be used. If a string starts with "@" as the very first character,
allows a variable number of help text pages (from one to twelve). that string (and all strings following) are ignored: this allows a
variable number of help text pages (from one to twelve).
The ASCII circumflex accent character "^" switches to a different The ASCII circumflex accent character "^" switches to a different
character rendition (also called attributes), depending on the character rendition (also called attributes), depending on the
@ -73,18 +74,23 @@ static const char *help_text[] = {
~m - Print the number of moves available (NUMBER_MOVES) [**] ~m - Print the number of moves available (NUMBER_MOVES) [**]
~c - Print the maximum number of companies that can be formed (MAX_COMPANIES) [*] ~c - Print the maximum number of companies that can be formed (MAX_COMPANIES) [*]
~t - Prints the default number of turns in the game (DEFAULT_MAX_TURN) [**] ~t - Prints the default number of turns in the game (DEFAULT_MAX_TURN) [**]
~1 to ~9 - Print the keycode for the N-th choice of move, appropriately localised [*] ~1 to ~9 - Print the keycode for the N-th choice of move [*]
~M - Print the keycode for the last choice of move [*] ~M - Print the keycode for the last choice of move [*]
~A to ~H - Print the character used to represent the company on the galaxy map, appropriately localised [*] ~A to ~H - Print the character used to represent the company on the galaxy map [*]
~. - Print the character used to represent empty space on the map [*]
~+ - Print the character used to represent outposts on the map [*]
~* - Print the character used to represent stars on the map [*]
[*] Takes one character space in the output [*] Takes one character space in the output
[**] Takes two character spaces in the output [**] Takes two character spaces in the output
Note that the tilde value escapes do NOT change the current character Note that all keycodes and map representation characters use locale-
rendition: a circumflex accent escape is needed for that. For specific characters. Note also that the tilde value escapes do NOT
example, to display the first choice of move as it would be shown on change the current character rendition: a circumflex accent escape is
the galaxy map, use something like "^k~1^N" (a six-character sequence needed for that. For example, to display the first choice of move as
that would translate to just one character in the output text). it would be shown on the galaxy map, use something like "^k~1^N" (a
six-character sequence that would translate to just one character in
the output text).
*/ */
N_("" N_(""
"^BStar Traders^N is a simple game of interstellar trading. The object of the\n" "^BStar Traders^N is a simple game of interstellar trading. The object of the\n"
@ -98,47 +104,47 @@ static const char *help_text[] = {
"The map of the galaxy is represented by a ^B~x^N x ^B~y^N grid. A typical section\n" "The map of the galaxy is represented by a ^B~x^N x ^B~y^N grid. A typical section\n"
"of it may be:\n" "of it may be:\n"
"\n" "\n"
" ^e . . ^s*^e . . . ^s*^e ^s*^e . ^N\n" " ^e ~. ~. ^s~*^e ~. ~. ~. ^s~*^e ^s~*^e ~. ^N\n"
" ^e . . . . . . . . . ^N ^e . ^N represents ^Bempty space^N,\n" " ^e ~. ~. ~. ~. ~. ~. ~. ~. ~. ^N ^e ~. ^N represents ^Bempty space^N,\n"
" ^e . ^s*^e . . . . . . . ^N ^s * ^N represents a ^Bstar^N.\n" " ^e ~. ^s~*^e ~. ~. ~. ~. ~. ~. ~. ^N ^s ~* ^N represents a ^Bstar^N.\n"
" ^e . . . . . . . ^s*^e . ^N\n" " ^e ~. ~. ~. ~. ~. ~. ~. ^s~*^e ~. ^N\n"
" ^e . . . . ^s*^e . . . . ^N\n" " ^e ~. ~. ~. ~. ^s~*^e ~. ~. ~. ~. ^N\n"
""), ""),
N_("" N_(""
"The computer selects ^B~m^N moves (labeled ^k~1^N to ^k~M^N) at random, and places these\n" "The computer selects ^B~m^N moves (labeled ^k~1^N to ^k~M^N) at random, and places these\n"
"on the map. To select any of the highlighted positions, press that letter.\n" "on the map. To select any of the highlighted positions, press that letter.\n"
"As an example, some of the moves on the map may be:\n" "For example, some of the moves on the map may be:\n"
"\n" "\n"
"\n" "\n"
" ^e ^k~1^e . ^s*^e . . . ^s*^e ^s*^e . ^N\n" " ^e ^k~1^e ~. ^s~*^e ~. ~. ~. ^s~*^e ^s~*^e ~. ^N\n"
" ^e . . . ^k~3^e . . . . . ^N\n" " ^e ~. ~. ~. ^k~3^e ~. ~. ~. ~. ~. ^N\n"
" ^e . ^s*^e . . . . ^k~5^e . . ^N Moves ^k~1^N to ^k~5^N shown.\n" " ^e ~. ^s~*^e ~. ~. ~. ~. ^k~5^e ~. ~. ^N Moves ^k~1^N to ^k~5^N shown.\n"
" ^e . ^k~2^e . . ^k~4^e . . ^s*^e . ^N\n" " ^e ~. ^k~2^e ~. ~. ^k~4^e ~. ~. ^s~*^e ~. ^N\n"
" ^e . . . . ^s*^e . . . . ^N\n" " ^e ~. ~. ~. ~. ^s~*^e ~. ~. ~. ~. ^N\n"
"\n" "\n"
"\n" "\n"
"Selecting a position that is ^Bnot^N next to a star (such as moves ^k~1^N, ^k~3^N or ^k~5^N)\n" "Selecting a position that is ^Bnot^N next to a star (such as moves ^k~1^N, ^k~3^N or ^k~5^N)\n"
"will set up an ^Boutpost^N, not belonging to any company. Thus, if move ^k~3^N was\n" "will set up an ^Boutpost^N, not belonging to any company. Thus, if move ^k~3^N is\n"
"selected on the above map, a ^o + ^N would be placed at that position.\n" "selected on the above map, a ^o ~+ ^N would be placed at that position.\n"
""), ""),
N_("" N_(""
"If, on the other hand, a position next to a star (or another outpost) is\n" "If, on the other hand, a position next to a star (or another outpost) is\n"
"selected, a ^Bcompany^N would be formed and its first letter would appear on the\n" "selected, a ^Bcompany^N would be formed and its letter would appear on the map.\n"
"map. As a reward for creating the company, you are granted the first five\n" "As a reward for creating the company, you are granted the first five shares.\n"
"shares. Up to ^B~c^N companies can be created in this way.\n" "Up to ^B~c^N companies can be created in this way.\n"
"\n" "\n"
"If a position next to an existing company is selected, the company would\n" "If a position next to an existing company is selected, the company would\n"
"expand its operations by one square. This increases the cost of its shares\n" "expand its operations by one square. This increases the cost of its shares\n"
"and hence your return. Thus, if the map was as shown below, selecting ^k~6^N\n" "and hence your return. Thus, if the map was as shown below, selecting ^k~6^N\n"
"or ^k~8^N increases Company ^B~B^N's shipping lane:\n" "or ^k~8^N increases Company ^B~B^N's shipping lane:\n"
"\n" "\n"
" ^e ^k~1^e . ^s*^e . . . ^s*^e ^s*^e . ^N\n" " ^e ^k~1^e ~. ^s~*^e ~. ~. ~. ^s~*^e ^s~*^e ~. ^N\n"
" ^e . . . ^o+^e . . ^k~6^e . . ^N\n" " ^e ~. ~. ~. ^o~+^e ~. ~. ^k~6^e ~. ~. ^N\n"
" ^e . ^s*^e . . . . ^c~B^e ^c~B^e ^c~B^e ^N Move ^k~6^N or ^k~8^N increases Company ^B~B^N.\n" " ^e ~. ^s~*^e ~. ~. ~. ~. ^c~B^e ^c~B^e ^c~B^e ^N Move ^k~6^N or ^k~8^N increases Company ^B~B^N.\n"
" ^e . ^k~2^e . . ^k~4^e . . ^s*^e ^c~B^e ^N\n" " ^e ~. ^k~2^e ~. ~. ^k~4^e ~. ~. ^s~*^e ^c~B^e ^N\n"
" ^e . . . . ^s*^e . . . ^k~8^e ^N\n" " ^e ~. ~. ~. ~. ^s~*^e ~. ~. ~. ^k~8^e ^N\n"
""), ""),
N_("" N_(""
@ -146,13 +152,13 @@ static const char *help_text[] = {
"five times as much as an extension not next to a star. Thus move ^k~6^N should\n" "five times as much as an extension not next to a star. Thus move ^k~6^N should\n"
"be preferred to move ^k~8^N.\n" "be preferred to move ^k~8^N.\n"
"\n" "\n"
" ^e ^c~C^e . ^s*^e . . . ^s*^e ^s*^e . ^N\n" " ^e ^c~C^e ~. ^s~*^e ~. ~. ~. ^s~*^e ^s~*^e ~. ^N\n"
" ^e ^k~1^e ^o+^e . ^o+^e . . ^k~6^e . . ^N\n" " ^e ^k~1^e ^o~+^e ~. ^o~+^e ~. ~. ^k~6^e ~. ~. ^N\n"
" ^e . ^s*^e . . . . ^c~B^e ^c~B^e ^c~B^e ^N Move ^k~6^N is preferred to ^k~8^N.\n" " ^e ~. ^s~*^e ~. ~. ~. ~. ^c~B^e ^c~B^e ^c~B^e ^N Move ^k~6^N is preferred to ^k~8^N.\n"
" ^e . ^k~2^e . . ^k~4^e . . ^s*^e ^c~B^e ^N\n" " ^e ~. ^k~2^e ~. ~. ^k~4^e ~. ~. ^s~*^e ^c~B^e ^N\n"
" ^e . . . . ^s*^e . . . ^k~8^e ^N\n" " ^e ~. ~. ~. ~. ^s~*^e ~. ~. ~. ^k~8^e ^N\n"
"\n" "\n"
"You can also expand any company by selecting positions next to outposts.\n" "You may also expand any company by selecting positions next to outposts.\n"
"Such outposts will be swallowed up by that company. Thus, move ^k~1^N will\n" "Such outposts will be swallowed up by that company. Thus, move ^k~1^N will\n"
"extend Company ^B~C^N by ^Btwo^N squares. As a bonus, outposts next to stars are\n" "extend Company ^B~C^N by ^Btwo^N squares. As a bonus, outposts next to stars are\n"
"more valuable: the company's share price will increase by a greater amount\n" "more valuable: the company's share price will increase by a greater amount\n"
@ -167,11 +173,11 @@ static const char *help_text[] = {
"other one. Here, Company ^B~B^N might take over Company ^B~A^N. Company ^B~A^N ceases to\n" "other one. Here, Company ^B~B^N might take over Company ^B~A^N. Company ^B~A^N ceases to\n"
"exist, although it may reappear as an entirely new company at a later stage.\n" "exist, although it may reappear as an entirely new company at a later stage.\n"
"\n" "\n"
" ^e ^k~1^e . ^s*^e . . . ^s*^e ^s*^e . ^N\n" " ^e ^k~1^e ~. ^s~*^e ~. ~. ~. ^s~*^e ^s~*^e ~. ^N\n"
" ^e . . . ^c~A^e ^c~A^e ^k~5^e ^c~B^e . . ^N\n" " ^e ~. ~. ~. ^c~A^e ^c~A^e ^k~5^e ^c~B^e ~. ~. ^N\n"
" ^e . ^s*^e . . ^c~A^e . ^c~B^e ^c~B^e ^c~B^e ^N Move ^k~5^N merges companies ^B~A^N and ^B~B^N.\n" " ^e ~. ^s~*^e ~. ~. ^c~A^e ~. ^c~B^e ^c~B^e ^c~B^e ^N Move ^k~5^N merges companies ^B~A^N and ^B~B^N.\n"
" ^e . ^k~2^e . . . . . ^s*^e ^c~B^e ^N\n" " ^e ~. ^k~2^e ~. ~. ~. ~. ~. ^s~*^e ^c~B^e ^N\n"
" ^e . . . . ^s*^e . ^o+^e . . ^N\n" " ^e ~. ~. ~. ~. ^s~*^e ~. ^o~+^e ~. ~. ^N\n"
"\n" "\n"
"When companies merge, players are granted shares in the dominant company\n" "When companies merge, players are granted shares in the dominant company\n"
"proportional to the amount owned in the old company. As well, a cash bonus\n" "proportional to the amount owned in the old company. As well, a cash bonus\n"
@ -180,13 +186,13 @@ static const char *help_text[] = {
N_("" N_(""
"Once you select your move, you enter the ^BInterstellar Stock Exchange^N. Here\n" "Once you select your move, you enter the ^BInterstellar Stock Exchange^N. Here\n"
"you can purchase shares, sell them, borrow from the Trading Bank or repay\n" "you may purchase shares, sell them, borrow from the Trading Bank or repay\n"
"some of your debt (if applicable). Note that each company issues a limited\n" "some of your debt (if applicable). Note that each company issues a limited\n"
"number of shares --- you cannot go on buying for ever! You can, however,\n" "number of shares --- you cannot go on buying for ever! You may, however,\n"
"bid for more shares to be issued. You have a better chance of succeeding if\n" "bid for more shares to be issued. You have a better chance of succeeding if\n"
"you own a larger proportion of the company.\n" "you own a larger proportion of the company.\n"
"\n" "\n"
"The game usually ends after ^B~t^N turns. However, you can end the game sooner\n" "The game usually ends after ^B~t^N turns. However, you may end the game sooner\n"
"by pressing ^K<CTRL><C>^N when asked to select a move. As well, individual\n" "by pressing ^K<CTRL><C>^N when asked to select a move. As well, individual\n"
"players can declare themselves bankrupt at any time. If your debt is large\n" "players can declare themselves bankrupt at any time. If your debt is large\n"
"enough, the Bank may do this for you! If you do not complete your game in\n" "enough, the Bank may do this for you! If you do not complete your game in\n"
@ -359,12 +365,27 @@ void show_help (void)
case '8': case '8':
case '9': case '9':
// N-th choice of move, as a key press // N-th choice of move, as a key press
wprintw(curwin, "%c", MOVE_TO_KEY(*s - '1')); wprintw(curwin, "%c", PRINTABLE_GAME_MOVE(*s - '1'));
break; break;
case 'M': case 'M':
// Last choice of move, as a key press // Last choice of move, as a key press
wprintw(curwin, "%c", MOVE_TO_KEY(NUMBER_MOVES - 1)); wprintw(curwin, "%c", PRINTABLE_GAME_MOVE(NUMBER_MOVES - 1));
break;
case '.':
// Map representation of empty space
wprintw(curwin, "%c", PRINTABLE_MAP_VAL(MAP_EMPTY));
break;
case '+':
// Map representation of an outpost
wprintw(curwin, "%c", PRINTABLE_MAP_VAL(MAP_OUTPOST));
break;
case '*':
// Map representation of a star
wprintw(curwin, "%c", PRINTABLE_MAP_VAL(MAP_STAR));
break; break;
case 'A': case 'A':

View File

@ -42,8 +42,9 @@
Returns: (nothing) Returns: (nothing)
This function displays instructions on how to play Star Traders in a This function displays instructions on how to play Star Traders in a
Curses window. It does not depend on any global game variable. On Curses window. It does not depend on any global game variables other
exit, the previous screen is restored and refreshed. than printable_map_val[] and printable_game_move[]. On exit, the
previous screen is restored and refreshed.
*/ */
extern void show_help (void); extern void show_help (void);

View File

@ -2327,8 +2327,8 @@ int gettxlong (WINDOW *win, long int *restrict result, long int min,
bool answer_yesno (WINDOW *win) bool answer_yesno (WINDOW *win)
{ {
static char *keys_yes; static char *keycode_yes;
static char *keys_no; static char *keycode_no;
bool ret; bool ret;
@ -2336,13 +2336,13 @@ bool answer_yesno (WINDOW *win)
chtype oldbkgd = getbkgd(win); chtype oldbkgd = getbkgd(win);
if (keys_yes == NULL) { if (keycode_yes == NULL) {
/* TRANSLATORS: The strings with msgctxt "input|Yes" and /* TRANSLATORS: The strings with msgctxt "input|Yes" and
"input|No" contain the keycodes used to determine whether a "input|No" contain the keycodes used to determine whether a
user is answering "Yes" or "No" in response to some question. user is answering "Yes" or "No" in response to some question.
Both upper and lower-case versions should be present. */ Both upper and lower-case versions should be present. */
keys_yes = xstrdup(pgettext("input|Yes", "Yy")); keycode_yes = xstrdup(pgettext("input|Yes", "Yy"));
keys_no = xstrdup(pgettext("input|No", "Nn")); keycode_no = xstrdup(pgettext("input|No", "Nn"));
} }
@ -2355,10 +2355,10 @@ bool answer_yesno (WINDOW *win)
while (true) { while (true) {
int key = wgetch(win); int key = wgetch(win);
if (strchr(keys_yes, key) != NULL) { if (strchr(keycode_yes, key) != NULL) {
ret = true; ret = true;
break; break;
} else if (strchr(keys_no, key) != NULL) { } else if (strchr(keycode_no, key) != NULL) {
ret = false; ret = false;
break; break;
} else } else

View File

@ -220,7 +220,7 @@ selection_t get_move (void)
// Display current move choices on the galaxy map // Display current move choices on the galaxy map
for (int i = 0; i < NUMBER_MOVES; i++) { for (int i = 0; i < NUMBER_MOVES; i++) {
mvwaddch(curwin, game_move[i].y + 3, game_move[i].x * 2 + 2, mvwaddch(curwin, game_move[i].y + 3, game_move[i].x * 2 + 2,
MOVE_TO_KEY(i) | attr_map_choice); PRINTABLE_GAME_MOVE(i) | attr_map_choice);
} }
wrefresh(curwin); wrefresh(curwin);
@ -243,26 +243,42 @@ selection_t get_move (void)
right(curwin, 1, getmaxx(curwin) / 2, attr_normal, attr_keycode, right(curwin, 1, getmaxx(curwin) / 2, attr_normal, attr_keycode,
attr_choice, 1, attr_choice, 1,
_("Select move [^[%c^]-^[%c^]/^{1^}-^{3^}/^{<CTRL><C>^}]: "), _("Select move [^[%c^]-^[%c^]/^{1^}-^{3^}/^{<CTRL><C>^}]: "),
MOVE_TO_KEY(0), MOVE_TO_KEY(NUMBER_MOVES - 1)); PRINTABLE_GAME_MOVE(0), PRINTABLE_GAME_MOVE(NUMBER_MOVES - 1));
curs_set(CURS_ON); curs_set(CURS_ON);
wrefresh(curwin); wrefresh(curwin);
// Get the actual selection made by the player // Get the actual selection made by the player
while (selection == SEL_NONE) { while (selection == SEL_NONE) {
int key = tolower(gettxchar(curwin)); int i;
bool found;
if (IS_MOVE_KEY(key)) { int key = gettxchar(curwin);
selection = KEY_TO_MOVE(key);
curs_set(CURS_OFF); if (isupper(*keycode_game_move)) {
left(curwin, 1, getmaxx(curwin) / 2, attr_normal, attr_choice, key = toupper(key);
0, 1, } else if (islower(*keycode_game_move)) {
/* TRANSLATORS: "Move" refers to the choice of moves key = tolower(key);
made by the current player (out of a selection of }
20 moves). */
_("Move ^{%c^}"), key); for (i = 0, found = false; keycode_game_move[i] != '\0'; i++) {
} else { if (keycode_game_move[i] == key) {
found = true;
selection = i;
curs_set(CURS_OFF);
left(curwin, 1, getmaxx(curwin) / 2, attr_normal,
attr_choice, 0, 1,
/* TRANSLATORS: "Move" refers to the choice of
moves made by the current player (out of a
selection of 20 moves). */
_("Move ^{%c^}"), PRINTABLE_GAME_MOVE(i));
break;
}
}
if (! found) {
switch (key) { switch (key) {
case '1': case '1':
curs_set(CURS_OFF); curs_set(CURS_OFF);