1
0
mirror of https://git.zap.org.au/git/trader.git synced 2024-12-04 14:46:45 -05:00

Continue to rewrite the interface code to use the new interfaces

This commit is contained in:
John Zaitseff 2011-08-16 18:48:56 +10:00
parent 135842b87d
commit cf30933614
5 changed files with 318 additions and 246 deletions

View File

@ -76,7 +76,7 @@ void exchange_stock (void)
selection_t selection = SEL_NONE; selection_t selection = SEL_NONE;
bool bid_used = false; bool bid_used = false;
bool all_off_map; bool all_off_map;
int i, line; int w, i, line;
if (quit_selected || abort_game || ! player[current_player].in_game) { if (quit_selected || abort_game || ! player[current_player].in_game) {
@ -84,18 +84,20 @@ void exchange_stock (void)
} }
newtxwin(17, WIN_COLS, 1, WCENTER, false, 0); newtxwin(17, WIN_COLS, 1, WCENTER, false, 0);
w = getmaxx(curwin);
while (selection != SEL_EXIT) { while (selection != SEL_EXIT) {
selection = SEL_NONE; selection = SEL_NONE;
// Display (or refresh) the Stock Exchange window // Display (or refresh) the Stock Exchange window
wbkgd(curwin, attr_normal_window); wbkgdset(curwin, attr_normal_window);
werase(curwin); werase(curwin);
box(curwin, 0, 0); box(curwin, 0, 0);
old_center(curwin, 1, attr_title, " Interstellar Stock Exchange "); center(curwin, 1, 0, attr_title, 0, 0, 1,
old_center2(curwin, 2, attr_normal, attr_highlight, "Player: ", "%s", " Interstellar Stock Exchange ");
player[current_player].name); center(curwin, 2, 0, attr_normal, attr_highlight, 0, 1,
"Player: ^{%s^}", player[current_player].name);
all_off_map = true; all_off_map = true;
for (i = 0; i < MAX_COMPANIES; i++) { for (i = 0; i < MAX_COMPANIES; i++) {
@ -106,34 +108,44 @@ void exchange_stock (void)
} }
if (all_off_map) { if (all_off_map) {
old_center(curwin, 8, attr_normal, "No companies on the map"); center(curwin, 8, 0, attr_normal, attr_highlight, 0, 1,
"No companies on the map");
} else { } else {
char *buf = xmalloc(BUFSIZE); mvwhline(curwin, 4, 2, ' ' | attr_subtitle, w - 4);
mvwhline(curwin, 5, 2, ' ' | attr_subtitle, w - 4);
// Handle the locale's currency symbol left(curwin, 4, 4, attr_subtitle, 0, 0, 2, "\nCompany");
snprintf(buf, BUFSIZE, "share (%s)", lconvinfo.currency_symbol); right(curwin, 4, w - 4, attr_subtitle, 0, 0, 2, "Shares\nleft");
right(curwin, 4, w - 6 - STOCK_LEFT_COLS, attr_subtitle, 0, 0,
wattrset(curwin, attr_subtitle); 2, "Shares\nissued");
mvwprintw(curwin, 4, 2, " %-22s %12s %10s %10s %10s ", right(curwin, 4, w - 8 - STOCK_LEFT_COLS - STOCK_ISSUED_COLS,
"", "Price per", "", "Shares", "Shares"); attr_subtitle, 0, 0, 2, "Return\n(%%)");
mvwprintw(curwin, 5, 2, " %-22s %12s %10s %10s %10s ", right(curwin, 4, w - 10 - STOCK_LEFT_COLS - STOCK_ISSUED_COLS
"Company", buf, "Return (%)", "issued", "left"); - SHARE_RETURN_COLS, attr_subtitle, 0, 0, 2,
wattrset(curwin, attr_normal); "Price per\nshare (%s)", lconvinfo.currency_symbol);
for (line = 6, i = 0; i < MAX_COMPANIES; i++) { for (line = 6, i = 0; i < MAX_COMPANIES; i++) {
if (company[i].on_map) { if (company[i].on_map) {
mvwaddch(curwin, line, 2, PRINTABLE_MAP_VAL(COMPANY_TO_MAP(i)) mvwaddch(curwin, line, 2, PRINTABLE_MAP_VAL(COMPANY_TO_MAP(i))
| attr_choice); | attr_choice);
l_strfmon(buf, BUFSIZE, "%!12n", company[i].share_price);
mvwprintw(curwin, line, 4, "%-22s %12s %10.2f %'10ld %'10ld ", left(curwin, line, 4, attr_normal, 0, 0, 1, "%s",
company[i].name, buf, company[i].share_return company[i].name);
* 100.0, company[i].stock_issued,
company[i].max_stock - company[i].stock_issued); right(curwin, line, w - 2, attr_normal, 0, 0, 1, "%'ld ",
company[i].max_stock - company[i].stock_issued);
right(curwin, line, w - 4 - STOCK_LEFT_COLS, attr_normal,
0, 0, 1, "%'ld ", company[i].stock_issued);
right(curwin, line, w - 6 - STOCK_LEFT_COLS
- STOCK_ISSUED_COLS, attr_normal, 0, 0, 1, "%.2f ",
company[i].share_return * 100.0);
right(curwin, line, w - 8 - STOCK_LEFT_COLS
- STOCK_ISSUED_COLS - SHARE_RETURN_COLS, attr_normal,
0, 0, 1, " %!N ", company[i].share_price);
line++; line++;
} }
} }
free(buf);
} }
wrefresh(curwin); wrefresh(curwin);
@ -141,30 +153,17 @@ void exchange_stock (void)
// Show menu of choices for the player // Show menu of choices for the player
newtxwin(6, WIN_COLS, 18, WCENTER, true, attr_normal_window); newtxwin(6, WIN_COLS, 18, WCENTER, true, attr_normal_window);
wmove(curwin, 3, 2); left(curwin, 3, 2, attr_normal, attr_keycode, 0, 1,
old_attrpr(curwin, attr_keycode, "<1>"); "^{<1>^} Display stock portfolio");
waddstr(curwin, " Display stock portfolio"); left(curwin, 4, 2, attr_normal, attr_keycode, 0, 1,
"^{<2>^} Display galaxy map");
left(curwin, 3, getmaxx(curwin) / 2, attr_normal, attr_keycode, 0, 1,
"^{<3>^} Visit the Trading Bank");
left(curwin, 4, getmaxx(curwin) / 2, attr_normal, attr_keycode, 0, 1,
"^{<4>^} Exit the Stock Exchange");
wmove(curwin, 4, 2); center(curwin, 1, -1, attr_normal, attr_keycode, attr_highlight, 1,
old_attrpr(curwin, attr_keycode, "<2>"); "Enter selection [^[Company letter^]/^{1^}-^{4^}]: ");
waddstr(curwin, " Display galaxy map");
wmove(curwin, 3, 40);
old_attrpr(curwin, attr_keycode, "<3>");
waddstr(curwin, " Visit the Trading Bank");
wmove(curwin, 4, 40);
old_attrpr(curwin, attr_keycode, "<4>");
waddstr(curwin, " Exit the Stock Exchange");
mvwaddstr(curwin, 1, 18, "Enter selection ");
waddstr(curwin, "[");
old_attrpr(curwin, attr_highlight, "Company letter");
waddstr(curwin, "/");
old_attrpr(curwin, attr_keycode, "1");
waddstr(curwin, "-");
old_attrpr(curwin, attr_keycode, "4");
waddstr(curwin, "]: ");
curs_set(CURS_ON); curs_set(CURS_ON);
wrefresh(curwin); wrefresh(curwin);
@ -250,10 +249,10 @@ void visit_bank (void)
double val, max; double val, max;
int key; int key;
bool done; bool done;
char *buf;
chtype *chbuf = xmalloc(BUFSIZE * sizeof(chtype));
int x, width;
buf = xmalloc(BUFSIZE);
credit_limit = (total_value(current_player) - player[current_player].debt) credit_limit = (total_value(current_player) - player[current_player].debt)
* CREDIT_LIMIT_RATE; * CREDIT_LIMIT_RATE;
@ -264,38 +263,43 @@ void visit_bank (void)
// Show the informational part of the Bank // Show the informational part of the Bank
newtxwin(10, WIN_COLS - 4, 5, WCENTER, true, attr_normal_window); newtxwin(10, WIN_COLS - 4, 5, WCENTER, true, attr_normal_window);
old_center(curwin, 1, attr_title, " Interstellar Trading Bank "); center(curwin, 1, 0, attr_title, 0, 0, 1, " Interstellar Trading Bank ");
l_strfmon(buf, BUFSIZE, "%18n", player[current_player].cash); mkchstr(chbuf, BUFSIZE, attr_normal, 0, 0, 1, getmaxx(curwin) - 4, &width,
old_center2(curwin, 3, attr_normal, attr_highlight, "Current cash: ", 1, "Current cash: ");
" %s ", buf); x = (getmaxx(curwin) + width - (BANK_VALUE_COLS + 2)) / 2;
l_strfmon(buf, BUFSIZE, "%18n", player[current_player].debt); rightch(curwin, 3, x, chbuf, 1, &width);
old_center2(curwin, 4, attr_normal, attr_highlight, "Current debt: ", right(curwin, 3, x + BANK_VALUE_COLS + 2, attr_normal, attr_highlight, 0,
" %s ", buf); 1, " ^{%N^} ", player[current_player].cash);
old_center2(curwin, 5, attr_normal, attr_highlight, "Interest rate: ", right(curwin, 4, x, attr_normal, 0, 0, 1, "Current debt: ");
" %17.2f%% ", interest_rate * 100.0); right(curwin, 4, x + BANK_VALUE_COLS + 2, attr_normal, attr_highlight, 0,
1, " ^{%N^} ", player[current_player].debt);
l_strfmon(buf, BUFSIZE, "%18n", credit_limit); right(curwin, 5, x, attr_normal, 0, 0, 1, "Interest rate: ");
old_center2(curwin, 7, attr_highlight, attr_title, "Credit limit: ", right(curwin, 5, x + BANK_VALUE_COLS + 2, attr_normal, attr_highlight, 0,
" %s ", buf); 1, " ^{%.2f%%^} ", interest_rate * 100.0);
right(curwin, 7, x, attr_highlight, 0, 0, 1, "Credit limit: ");
whline(curwin, ' ' | attr_title, BANK_VALUE_COLS + 2);
right(curwin, 7, x + BANK_VALUE_COLS + 2, attr_title, 0, 0, 1,
" %N ", credit_limit);
wrefresh(curwin); wrefresh(curwin);
// Show menu of choices for the player // Show menu of choices for the player
newtxwin(7, WIN_COLS - 4, 15, WCENTER, true, attr_normal_window); newtxwin(7, WIN_COLS - 4, 15, WCENTER, true, attr_normal_window);
old_center2(curwin, 3, attr_keycode, attr_normal, "<1>", " Borrow money "); center(curwin, 3, 0, attr_normal, attr_keycode, 0, 1,
old_center2(curwin, 4, attr_keycode, attr_normal, "<2>", " Repay debt "); "^{<1>^} Borrow money ");
old_center2(curwin, 5, attr_keycode, attr_normal, "<3>", " Exit from the Bank"); center(curwin, 4, 0, attr_normal, attr_keycode, 0, 1,
"^{<2>^} Repay debt ");
center(curwin, 5, 0, attr_normal, attr_keycode, 0, 1,
"^{<3>^} Exit from the Bank");
mvwaddstr(curwin, 1, 24, "Enter selection "); center(curwin, 1, 0, attr_normal, attr_keycode, 0, 1,
waddstr(curwin, "["); "Enter selection [^{1^}-^{3^}]: ");
old_attrpr(curwin, attr_keycode, "1");
waddstr(curwin, "-");
old_attrpr(curwin, attr_keycode, "3");
waddstr(curwin, "]: ");
curs_set(CURS_ON); curs_set(CURS_ON);
wrefresh(curwin); wrefresh(curwin);
@ -337,42 +341,48 @@ void visit_bank (void)
attr_error_waitforkey, " Insufficient Credit Limit ", attr_error_waitforkey, " Insufficient Credit Limit ",
"The Bank will not lend you any more money."); "The Bank will not lend you any more money.");
} else { } else {
int x, y, n; chtype *chbuf_cursym;
int ret; int width_cursym;
int n, ret;
wbkgd(curwin, attr_normal_window); wbkgdset(curwin, attr_normal_window);
werase(curwin); werase(curwin);
box(curwin, 0, 0); box(curwin, 0, 0);
mvwprintw(curwin, 3, 10, "How much do you wish to borrow? "); n = (lconvinfo.p_sep_by_space == 1) ? 1 : 0;
mkchstr(chbuf, BUFSIZE, attr_normal, attr_normal | A_BOLD, 0, 1,
getmaxx(curwin) / 2, &width_cursym, 1, "^{%s^}",
lconvinfo.currency_symbol);
chbuf_cursym = chstrdup(chbuf, BUFSIZE);
mkchstr(chbuf, BUFSIZE, attr_normal, 0, 0, 1, getmaxx(curwin)
- BANK_INPUT_COLS - width_cursym - 6, &width, 1,
"How much do you wish to borrow? ");
x = (getmaxx(curwin) + width - BANK_INPUT_COLS - width_cursym
- n) / 2;
rightch(curwin, 3, x, chbuf, 1, &width);
// Show the currency symbol before or after the input field // Show the currency symbol before or after the input field
wattron(curwin, A_BOLD);
if (lconvinfo.p_cs_precedes == 1) { if (lconvinfo.p_cs_precedes == 1) {
wprintw(curwin, "%s%s", lconvinfo.currency_symbol, leftch(curwin, 3, x, chbuf_cursym, 1, &width_cursym);
(lconvinfo.p_sep_by_space == 1) ? " " : ""); x += width_cursym + n;
n = 10;
} else { } else {
getyx(curwin, y, x); leftch(curwin, 3, x + BANK_INPUT_COLS + n, chbuf_cursym, 1,
n = strlen(lconvinfo.currency_symbol) + 10 &width_cursym);
+ (lconvinfo.p_sep_by_space == 1);
mvwprintw(curwin, y, getmaxx(curwin) - n, "%s%s",
(lconvinfo.p_sep_by_space == 1) ? " " : "",
lconvinfo.currency_symbol);
wmove(curwin, y, x);
} }
wattroff(curwin, A_BOLD);
x = getcurx(curwin);
ret = gettxdouble(curwin, &val, 0.0, credit_limit + ROUNDING_AMOUNT, ret = gettxdouble(curwin, &val, 0.0, credit_limit + ROUNDING_AMOUNT,
0.0, credit_limit, 3, x, getmaxx(curwin) - x - n, 0.0, credit_limit, 3, x, BANK_INPUT_COLS,
attr_input_field); attr_input_field);
if (ret == OK && val > ROUNDING_AMOUNT) { if (ret == OK && val > ROUNDING_AMOUNT) {
player[current_player].cash += val; player[current_player].cash += val;
player[current_player].debt += val * (interest_rate + 1.0); player[current_player].debt += val * (interest_rate + 1.0);
} }
free(chbuf_cursym);
} }
break; break;
@ -389,39 +399,42 @@ void visit_bank (void)
attr_error_waitforkey, " No Cash ", attr_error_waitforkey, " No Cash ",
"You have no cash with which to repay the debt!"); "You have no cash with which to repay the debt!");
} else { } else {
int x, y, n; chtype *chbuf_cursym;
int ret; int width_cursym;
int n, ret;
wbkgd(curwin, attr_normal_window); wbkgdset(curwin, attr_normal_window);
werase(curwin); werase(curwin);
box(curwin, 0, 0); box(curwin, 0, 0);
mvwprintw(curwin, 3, 10, "How much do you wish to repay? "); n = (lconvinfo.p_sep_by_space == 1) ? 1 : 0;
mkchstr(chbuf, BUFSIZE, attr_normal, attr_normal | A_BOLD, 0, 1,
getmaxx(curwin) / 2, &width_cursym, 1, "^{%s^}",
lconvinfo.currency_symbol);
chbuf_cursym = chstrdup(chbuf, BUFSIZE);
mkchstr(chbuf, BUFSIZE, attr_normal, 0, 0, 1, getmaxx(curwin)
- BANK_INPUT_COLS - width_cursym - 6, &width, 1,
"How much do you wish to repay? ");
x = (getmaxx(curwin) + width - BANK_INPUT_COLS - width_cursym
- n) / 2;
rightch(curwin, 3, x, chbuf, 1, &width);
// Show the currency symbol before or after the input field // Show the currency symbol before or after the input field
wattron(curwin, A_BOLD);
if (lconvinfo.p_cs_precedes == 1) { if (lconvinfo.p_cs_precedes == 1) {
wprintw(curwin, "%s%s", lconvinfo.currency_symbol, leftch(curwin, 3, x, chbuf_cursym, 1, &width_cursym);
(lconvinfo.p_sep_by_space == 1) ? " " : ""); x += width_cursym + n;
n = 10;
} else { } else {
getyx(curwin, y, x); leftch(curwin, 3, x + BANK_INPUT_COLS + n, chbuf_cursym, 1,
n = strlen(lconvinfo.currency_symbol) + 10 &width_cursym);
+ (lconvinfo.p_sep_by_space == 1);
mvwprintw(curwin, y, getmaxx(curwin) - n, "%s%s",
(lconvinfo.p_sep_by_space == 1) ? " " : "",
lconvinfo.currency_symbol);
wmove(curwin, y, x);
} }
wattroff(curwin, A_BOLD);
x = getcurx(curwin);
max = MIN(player[current_player].cash, player[current_player].debt); max = MIN(player[current_player].cash, player[current_player].debt);
ret = gettxdouble(curwin, &val, 0.0, max + ROUNDING_AMOUNT, 0.0, ret = gettxdouble(curwin, &val, 0.0, max + ROUNDING_AMOUNT, 0.0,
max, 3, x, getmaxx(curwin) - x - n, max, 3, x, BANK_INPUT_COLS, attr_input_field);
attr_input_field);
if (ret == OK) { if (ret == OK) {
player[current_player].cash -= val; player[current_player].cash -= val;
@ -434,6 +447,8 @@ void visit_bank (void)
player[current_player].debt = 0.0; player[current_player].debt = 0.0;
} }
} }
free(chbuf_cursym);
} }
break; break;
@ -445,7 +460,7 @@ void visit_bank (void)
deltxwin(); // Trading Bank window deltxwin(); // Trading Bank window
txrefresh(); txrefresh();
free(buf); free(chbuf);
} }
@ -455,16 +470,17 @@ void visit_bank (void)
void trade_shares (int num, bool *bid_used) void trade_shares (int num, bool *bid_used)
{ {
bool done; bool done;
int key, ret, x; int key, ret, w, x;
long int maxshares, val; long int maxshares, val;
double ownership; double ownership;
char *buf; chtype *chbuf;
int width;
assert(num >= 0 && num < MAX_COMPANIES); assert(num >= 0 && num < MAX_COMPANIES);
assert(company[num].on_map); assert(company[num].on_map);
buf = xmalloc(BUFSIZE); chbuf = xmalloc(BUFSIZE * sizeof(chtype));
ownership = (company[num].stock_issued == 0) ? 0.0 : ownership = (company[num].stock_issued == 0) ? 0.0 :
((double) player[current_player].stock_owned[num] ((double) player[current_player].stock_owned[num]
@ -472,64 +488,58 @@ void trade_shares (int num, bool *bid_used)
// Show the informational part of the trade window // Show the informational part of the trade window
newtxwin(9, WIN_COLS - 4, 5, WCENTER, true, attr_normal_window); newtxwin(9, WIN_COLS - 4, 5, WCENTER, true, attr_normal_window);
w = getmaxx(curwin);
old_center(curwin, 1, attr_title, " Stock Transaction in %s ", center(curwin, 1, 0, attr_title, 0, 0, 1, " Stock Transaction in %s ",
company[num].name); company[num].name);
mvwaddstr(curwin, 3, 2, "Shares issued: "); mkchstr(chbuf, BUFSIZE, attr_normal, 0, 0, 1, w / 2, &width, 1,
old_attrpr(curwin, attr_highlight, "%'12ld", company[num].stock_issued); "Shares issued: ");
leftch(curwin, 3, 2, chbuf, 1, &width);
right(curwin, 3, width + SHARE_PRICE_COLS + 2, attr_normal, attr_highlight,
0, 1, "^{%'ld^}", company[num].stock_issued);
mvwaddstr(curwin, 4, 2, "Shares left: "); left(curwin, 4, 2, attr_normal, 0, 0, 1, "Shares left: ");
old_attrpr(curwin, attr_highlight, "%'12ld", right(curwin, 4, width + SHARE_PRICE_COLS + 2, attr_normal, attr_highlight,
company[num].max_stock - company[num].stock_issued); 0, 1, "^{%'ld^}", company[num].max_stock - company[num].stock_issued);
mvwaddstr(curwin, 5, 2, "Price per share: "); left(curwin, 5, 2, attr_normal, 0, 0, 1, "Price per share: ");
l_strfmon(buf, BUFSIZE, "%12n", company[num].share_price); right(curwin, 5, width + SHARE_PRICE_COLS + 2, attr_normal, attr_highlight,
old_attrpr(curwin, attr_highlight, "%12s", buf); 0, 1, "^{%N^}", company[num].share_price);
mvwaddstr(curwin, 6, 2, "Return: "); left(curwin, 6, 2, attr_normal, 0, 0, 1, "Return: ");
old_attrpr(curwin, attr_highlight, "%11.2f%%", right(curwin, 6, width + SHARE_PRICE_COLS + 2, attr_normal, attr_highlight,
company[num].share_return * 100.0); 0, 1, "^{%.2f%%^}", company[num].share_return * 100.0);
mvwaddstr(curwin, 3, 38, "Current holdings: "); left(curwin, 3, w / 2, attr_normal, 0, 0, 1, "Current holdings: ");
old_attrpr(curwin, attr_highlight, " %'16ld ", right(curwin, 3, w - 2, attr_normal, attr_highlight, 0, 1, " ^{%'ld^} ",
player[current_player].stock_owned[num]); player[current_player].stock_owned[num]);
mvwaddstr(curwin, 4, 38, "Percentage owned: "); left(curwin, 4, w / 2, attr_normal, 0, 0, 1, "Percentage owned: ");
old_attrpr(curwin, attr_highlight, " %'15.2f%% ", ownership * 100.0); right(curwin, 4, w - 2, attr_normal, attr_highlight, 0, 1, " ^{%.2f%%^} ",
ownership * 100.0);
wmove(curwin, 6, 38); left(curwin, 6, w / 2, attr_highlight, 0, 0, 1, "Current cash: ");
old_attrpr(curwin, attr_highlight, "Current cash: "); whline(curwin, ' ' | attr_title, TRADE_VALUE_COLS + 2);
l_strfmon(buf, BUFSIZE, "%16n", player[current_player].cash); right(curwin, 6, w - 2, attr_title, 0, 0, 1, " %N ",
old_attrpr(curwin, attr_title, " %16s ", buf); player[current_player].cash);
wrefresh(curwin); wrefresh(curwin);
// Show menu of choices for the player // Show menu of choices for the player
newtxwin(7, WIN_COLS - 4, 14, WCENTER, true, attr_normal_window); newtxwin(7, WIN_COLS - 4, 14, WCENTER, true, attr_normal_window);
wmove(curwin, 3, 2); left(curwin, 3, 2, attr_normal, attr_keycode, 0, 1,
old_attrpr(curwin, attr_keycode, "<1>"); "^{<1>^} Buy stock from company");
waddstr(curwin, " Buy stock from company"); left(curwin, 4, 2, attr_normal, attr_keycode, 0, 1,
"^{<2>^} Sell stock back to company");
left(curwin, 3, getmaxx(curwin) / 2, attr_normal, attr_keycode, 0, 1,
"^{<3>^} Bid company to issue more shares");
left(curwin, 4, getmaxx(curwin) / 2, attr_normal, attr_keycode, 0, 1,
"^{<4>^} Exit to the Stock Exchange");
wmove(curwin, 4, 2); center(curwin, 1, 0, attr_normal, attr_keycode, 0, 1,
old_attrpr(curwin, attr_keycode, "<2>"); "Enter selection [^{1^}-^{4^}]: ");
waddstr(curwin, " Sell stock back to company");
wmove(curwin, 3, 38);
old_attrpr(curwin, attr_keycode, "<3>");
waddstr(curwin, " Bid company to issue more shares");
wmove(curwin, 4, 38);
old_attrpr(curwin, attr_keycode, "<4>");
waddstr(curwin, " Exit to the Stock Exchange");
mvwaddstr(curwin, 1, 24, "Enter selection ");
waddstr(curwin, "[");
old_attrpr(curwin, attr_keycode, "1");
waddstr(curwin, "-");
old_attrpr(curwin, attr_keycode, "4");
waddstr(curwin, "]: ");
curs_set(CURS_ON); curs_set(CURS_ON);
wrefresh(curwin); wrefresh(curwin);
@ -577,23 +587,27 @@ void trade_shares (int num, bool *bid_used)
txdlgbox(MAX_DLG_LINES, 50, 8, WCENTER, attr_error_window, txdlgbox(MAX_DLG_LINES, 50, 8, WCENTER, attr_error_window,
attr_error_title, attr_error_highlight, 0, 0, attr_error_title, attr_error_highlight, 0, 0,
attr_error_waitforkey, " Insufficient Cash ", attr_error_waitforkey, " Insufficient Cash ",
"Not enough cash to purchase shares."); "You do not have enough cash\n"
"to purchase additional shares.");
} else { } else {
maxshares = MIN(maxshares, company[num].max_stock - maxshares = MIN(maxshares, company[num].max_stock -
company[num].stock_issued); company[num].stock_issued);
wbkgd(curwin, attr_normal_window); wbkgdset(curwin, attr_normal_window);
werase(curwin); werase(curwin);
box(curwin, 0, 0); box(curwin, 0, 0);
old_center3(curwin, 2, attr_normal, attr_normal, attr_highlight, center(curwin, 2, 0, attr_normal, attr_highlight, 0, 1,
"You can purchase up to ", " shares.", "%'ld", maxshares); "You can purchase up to ^{%'ld^} shares.", maxshares);
mvwprintw(curwin, 4, 10, "How many shares do you wish to purchase? "); mkchstr(chbuf, BUFSIZE, attr_normal, 0, 0, 1, getmaxx(curwin)
x = getcurx(curwin); - TRADE_INPUT_COLS - 4, &width, 1,
"How many shares do you wish to purchase? ");
x = (getmaxx(curwin) + width - TRADE_INPUT_COLS) / 2;
rightch(curwin, 4, x, chbuf, 1, &width);
ret = gettxlong(curwin, &val, 0, maxshares, 0, maxshares, 4, x, ret = gettxlong(curwin, &val, 0, maxshares, 0, maxshares, 4, x,
getmaxx(curwin) - x - 10, attr_input_field); TRADE_INPUT_COLS, attr_input_field);
if (ret == OK) { if (ret == OK) {
player[current_player].cash -= val * company[num].share_price; player[current_player].cash -= val * company[num].share_price;
@ -612,18 +626,21 @@ void trade_shares (int num, bool *bid_used)
attr_error_waitforkey, " No Shares ", attr_error_waitforkey, " No Shares ",
"You do not have any shares to sell."); "You do not have any shares to sell.");
} else { } else {
wbkgd(curwin, attr_normal_window); wbkgdset(curwin, attr_normal_window);
werase(curwin); werase(curwin);
box(curwin, 0, 0); box(curwin, 0, 0);
old_center3(curwin, 2, attr_normal, attr_normal, attr_highlight, center(curwin, 2, 0, attr_normal, attr_highlight, 0, 1,
"You can sell up to ", " shares.", "%'ld", maxshares); "You can sell up to ^{%'ld^} shares.", maxshares);
mvwprintw(curwin, 4, 10, "How many shares do you wish to sell? "); mkchstr(chbuf, BUFSIZE, attr_normal, 0, 0, 1, getmaxx(curwin)
x = getcurx(curwin); - TRADE_INPUT_COLS - 4, &width, 1,
"How many shares do you wish to sell? ");
x = (getmaxx(curwin) + width - TRADE_INPUT_COLS) / 2;
rightch(curwin, 4, x, chbuf, 1, &width);
ret = gettxlong(curwin, &val, 0, maxshares, 0, maxshares, 4, x, ret = gettxlong(curwin, &val, 0, maxshares, 0, maxshares, 4, x,
getmaxx(curwin) - x - 10, attr_input_field); TRADE_INPUT_COLS, attr_input_field);
if (ret == OK) { if (ret == OK) {
company[num].stock_issued -= val; company[num].stock_issued -= val;
@ -666,7 +683,7 @@ void trade_shares (int num, bool *bid_used)
deltxwin(); // Stock Transaction window deltxwin(); // Stock Transaction window
txrefresh(); txrefresh();
free(buf); free(chbuf);
} }

View File

@ -652,7 +652,7 @@ void show_map (bool closewin)
void show_status (int num) void show_status (int num)
{ {
double val; double val;
int i, line; int w, i, line;
assert(num >= 0 && num < number_players); assert(num >= 0 && num < number_players);
@ -668,6 +668,8 @@ void show_status (int num)
center(curwin, 11, 0, attr_normal, attr_highlight, attr_blink, 1, center(curwin, 11, 0, attr_normal, attr_highlight, attr_blink, 1,
"^[* * * B A N K R U P T * * *^]"); "^[* * * B A N K R U P T * * *^]");
} else { } else {
w = getmaxx(curwin);
// Check to see if any companies are on the map // Check to see if any companies are on the map
bool none = true; bool none = true;
for (i = 0; i < MAX_COMPANIES; i++) { for (i = 0; i < MAX_COMPANIES; i++) {
@ -681,37 +683,34 @@ void show_status (int num)
center(curwin, 8, 0, attr_normal, attr_highlight, 0, 1, center(curwin, 8, 0, attr_normal, attr_highlight, 0, 1,
"No companies on the map"); "No companies on the map");
} else { } else {
mvwhline(curwin, 4, 2, ' ' | attr_subtitle, getmaxx(curwin) - 4); mvwhline(curwin, 4, 2, ' ' | attr_subtitle, w - 4);
mvwhline(curwin, 5, 2, ' ' | attr_subtitle, getmaxx(curwin) - 4); mvwhline(curwin, 5, 2, ' ' | attr_subtitle, w - 4);
left(curwin, 4, 4, attr_subtitle, 0, 0, 2, "\nCompany"); left(curwin, 4, 4, attr_subtitle, 0, 0, 2, "\nCompany");
right(curwin, 4, getmaxx(curwin) - 4, attr_subtitle, 0, 0, 2, right(curwin, 4, w - 4, attr_subtitle, 0, 0, 2, "Ownership\n(%%)");
"Ownership\n(%%)"); right(curwin, 4, w - 6 - OWNERSHIP_COLS, attr_subtitle, 0, 0,
right(curwin, 4, getmaxx(curwin) - 6 - OWNERSHIP_COLS, 2, "Holdings\n(shares)");
attr_subtitle, 0, 0, 2, "Holdings\n(shares)"); right(curwin, 4, w - 8 - OWNERSHIP_COLS - STOCK_OWNED_COLS,
right(curwin, 4, getmaxx(curwin) - 8 - OWNERSHIP_COLS attr_subtitle, 0, 0, 2, "Return\n(%%)");
- STOCK_OWNED_COLS, attr_subtitle, 0, 0, 2, right(curwin, 4, w - 10 - OWNERSHIP_COLS - STOCK_OWNED_COLS
"\nReturn (%%)"); - SHARE_RETURN_COLS, attr_subtitle, 0, 0, 2,
right(curwin, 4, getmaxx(curwin) - 10 - OWNERSHIP_COLS "Price per\nshare (%s)", lconvinfo.currency_symbol);
- STOCK_OWNED_COLS - SHARE_RETURN_COLS, attr_subtitle, 0, 0,
2, "Price per\nshare (%s)", lconvinfo.currency_symbol);
for (line = 6, i = 0; i < MAX_COMPANIES; i++) { for (line = 6, i = 0; i < MAX_COMPANIES; i++) {
if (company[i].on_map) { if (company[i].on_map) {
left(curwin, line, 4, attr_normal, 0, 0, 1, "%s", left(curwin, line, 4, attr_normal, 0, 0, 1, "%s",
company[i].name); company[i].name);
right(curwin, line, getmaxx(curwin) - 2, attr_normal, 0, 0, right(curwin, line, w - 2, attr_normal, 0, 0, 1, "%.2f ",
1, "%.2f ", (company[i].stock_issued == 0) ? 0.0 : (company[i].stock_issued == 0) ? 0.0 :
((double) player[num].stock_owned[i] * 100.0) ((double) player[num].stock_owned[i] * 100.0)
/ company[i].stock_issued); / company[i].stock_issued);
right(curwin, line, getmaxx(curwin) - 4 - OWNERSHIP_COLS, right(curwin, line, w - 4 - OWNERSHIP_COLS, attr_normal,
attr_normal, 0, 0, 1, "%'ld ", 0, 0, 1, "%'ld ", player[num].stock_owned[i]);
player[num].stock_owned[i]); right(curwin, line, w - 6 - OWNERSHIP_COLS
right(curwin, line, getmaxx(curwin) - 6 - OWNERSHIP_COLS
- STOCK_OWNED_COLS, attr_normal, 0, 0, 1, "%.2f ", - STOCK_OWNED_COLS, attr_normal, 0, 0, 1, "%.2f ",
company[i].share_return * 100.0); company[i].share_return * 100.0);
right(curwin, line, getmaxx(curwin) - 8 - OWNERSHIP_COLS right(curwin, line, w - 8 - OWNERSHIP_COLS
- STOCK_OWNED_COLS - SHARE_RETURN_COLS, attr_normal, - STOCK_OWNED_COLS - SHARE_RETURN_COLS, attr_normal,
0, 0, 1, " %!N ", company[i].share_price); 0, 0, 1, " %!N ", company[i].share_price);
@ -725,9 +724,9 @@ void show_status (int num)
chtype *chbuf = xmalloc(BUFSIZE * sizeof(chtype)); chtype *chbuf = xmalloc(BUFSIZE * sizeof(chtype));
int width, x; int width, x;
mkchstr(chbuf, BUFSIZE, attr_highlight, 0, 0, 1, getmaxx(curwin) / 2, mkchstr(chbuf, BUFSIZE, attr_highlight, 0, 0, 1, w / 2, &width, 1,
&width, 1, "Total value: "); "Total value: ");
x = (getmaxx(curwin) + width - (TOTAL_VALUE_COLS + 2)) / 2; x = (w + width - (TOTAL_VALUE_COLS + 2)) / 2;
right(curwin, line, x, attr_normal, attr_highlight, 0, 1, right(curwin, line, x, attr_normal, attr_highlight, 0, 1,
"Current cash: "); "Current cash: ");

View File

@ -174,8 +174,8 @@ void show_help (void)
while (! done) { while (! done) {
// Display a page of instructions // Display a page of instructions
wbkgdset(curwin, attr_normal_window);
werase(curwin); werase(curwin);
wbkgd(curwin, attr_normal_window);
box(curwin, 0, 0); box(curwin, 0, 0);
center(curwin, 1, 0, attr_title, 0, 0, 1, " How to Play "); center(curwin, 1, 0, attr_title, 0, 0, 1, " How to Play ");

View File

@ -56,6 +56,7 @@
#define WCENTER -1 // Centre the new window #define WCENTER -1 // Centre the new window
#define MAX_DLG_LINES 10 // Default maximum lines of text in dialog box #define MAX_DLG_LINES 10 // Default maximum lines of text in dialog box
#define YESNO_COLS 4 // Space to allow for "Yes" or "No" response #define YESNO_COLS 4 // Space to allow for "Yes" or "No" response
#define ORDINAL_COLS 5 // Space for ordinals (1st, 2nd, etc) #define ORDINAL_COLS 5 // Space for ordinals (1st, 2nd, etc)
#define TOTAL_VALUE_COLS 18 // Space for total value (monetary) #define TOTAL_VALUE_COLS 18 // Space for total value (monetary)
@ -63,6 +64,16 @@
#define SHARE_RETURN_COLS 10 // Space for "Return per share" #define SHARE_RETURN_COLS 10 // Space for "Return per share"
#define STOCK_OWNED_COLS 10 // Space for "Holdings (shares)" #define STOCK_OWNED_COLS 10 // Space for "Holdings (shares)"
#define OWNERSHIP_COLS 10 // Space for "Company ownership (%)" #define OWNERSHIP_COLS 10 // Space for "Company ownership (%)"
#define STOCK_ISSUED_COLS 10 // Space for "Shares issued"
#define STOCK_LEFT_COLS 10 // Space for "Shares left"
#define BANK_VALUE_COLS 18 // Space for amounts in bank window
#define BANK_INPUT_COLS 16 // Space for input text box in bank
#define TRADE_VALUE_COLS 16 // Space for amounts in trade window
#define TRADE_INPUT_COLS 10 // Space for input text box in trade window
#define MERGE_BONUS_COLS 12 // Space for "Bonus" (company merger)
#define MERGE_OLD_STOCK_COLS 8 // Space for "Old stocks" (company merger)
#define MERGE_NEW_STOCK_COLS 8 // Space for "New stocks" (company merger)
#define MERGE_TOTAL_STOCK_COLS 8 // Space for "Total stocks" (company merger)
// Check if resizing events are supported // Check if resizing events are supported

View File

@ -227,7 +227,7 @@ selection_t get_move (void)
// Show menu of choices for the player // Show menu of choices for the player
newtxwin(5, WIN_COLS, 19, WCENTER, false, 0); newtxwin(5, WIN_COLS, 19, WCENTER, false, 0);
while (selection == SEL_NONE) { while (selection == SEL_NONE) {
wbkgd(curwin, attr_normal_window); wbkgdset(curwin, attr_normal_window);
werase(curwin); werase(curwin);
box(curwin, 0, 0); box(curwin, 0, 0);
@ -731,10 +731,13 @@ void merge_companies (map_val_t a, map_val_t b)
double val_bb = company[bb].share_price * company[bb].stock_issued * double val_bb = company[bb].share_price * company[bb].stock_issued *
company[bb].share_return; company[bb].share_return;
long int old_stock, new_stock, total_new;
int x, y, i, line;
double bonus; double bonus;
char *buf = xmalloc(BUFSIZE); long int old_stock, new_stock, total_new;
chtype *chbuf = xmalloc(BUFSIZE * sizeof(chtype));
int lines, width, widthbuf[4];
chtype *chbuf_aa, *chbuf_bb;
int width_aa, width_bb;
int x, y, w, i, ln;
if (val_aa < val_bb) { if (val_aa < val_bb) {
@ -748,31 +751,49 @@ void merge_companies (map_val_t a, map_val_t b)
// Display information about the merger // Display information about the merger
newtxwin(number_players + 14, WIN_COLS - 4, 9 - number_players, lines = mkchstr(chbuf, BUFSIZE, attr_normal, attr_highlight, 0, 4, WIN_COLS
WCENTER, true, attr_normal_window); - 8, widthbuf, 4, "^{%s^} has just merged into ^{%s^}.\n"
"Please note the following transactions:\n",
company[bb].name, company[aa].name);
old_center(curwin, 1, attr_title, " Company Merger "); newtxwin(number_players + lines + 10, WIN_COLS - 4, lines + 6
old_center3(curwin, 3, attr_highlight, attr_highlight, attr_normal, - number_players, WCENTER, true, attr_normal_window);
company[bb].name, company[aa].name, " has just merged into "); center(curwin, 1, 0, attr_title, 0, 0, 1, " Company Merger ");
centerch(curwin, 3, 0, chbuf, lines, widthbuf);
old_center(curwin, 5, attr_normal, "Please note the following transactions:"); mkchstr(chbuf, BUFSIZE, attr_highlight, 0, 0, 1, getmaxx(curwin) / 2,
&width_aa, 1, "%s", company[aa].name);
chbuf_aa = chstrdup(chbuf, BUFSIZE);
old_center2(curwin, 7, attr_normal, attr_highlight, " Old stock: ", mkchstr(chbuf, BUFSIZE, attr_highlight, 0, 0, 1, getmaxx(curwin) / 2,
"%-20s", company[bb].name); &width_bb, 1, "%s", company[bb].name);
old_center2(curwin, 8, attr_normal, attr_highlight, " New stock: ", chbuf_bb = chstrdup(chbuf, BUFSIZE);
"%-20s", company[aa].name);
// Handle the locale's currency symbol mkchstr(chbuf, BUFSIZE, attr_normal, 0, 0, 1, getmaxx(curwin) / 2, &width,
snprintf(buf, BUFSIZE, "Bonus (%s)", lconvinfo.currency_symbol); 1, "Old stock: ");
int w = getmaxx(curwin) - 52; w = getmaxx(curwin);
wattrset(curwin, attr_subtitle); x = (w + width - MAX(width_aa, width_bb)) / 2;
mvwprintw(curwin, 10, 2, " %-*.*s %8s %8s %8s %12s ", w, w,
"Player", "Old", "New", "Total", buf); rightch(curwin, lines + 3, x, chbuf, 1, &width);
wattrset(curwin, attr_normal); leftch(curwin, lines + 3, x, chbuf_bb, 1, &width_bb);
right(curwin, lines + 4, x, attr_normal, 0, 0, 1, "New Stock: ");
leftch(curwin, lines + 4, x, chbuf_aa, 1, &width_aa);
mvwhline(curwin, lines + 6, 2, ' ' | attr_subtitle, w - 4);
left(curwin, lines + 6, 4, attr_subtitle, 0, 0, 1, "Player");
right(curwin, lines + 6, w - 4, attr_subtitle, 0, 0, 1,
"Bonus (%s)", lconvinfo.currency_symbol);
right(curwin, lines + 6, w - 6 - MERGE_BONUS_COLS, attr_subtitle, 0, 0,
1, "Total");
right(curwin, lines + 6, w - 8 - MERGE_BONUS_COLS - MERGE_TOTAL_STOCK_COLS,
attr_subtitle, 0, 0, 1, "New");
right(curwin, lines + 6, w - 10 - MERGE_BONUS_COLS - MERGE_TOTAL_STOCK_COLS
- MERGE_NEW_STOCK_COLS, attr_subtitle, 0, 0, 1, "Old");
total_new = 0; total_new = 0;
for (line = 11, i = 0; i < number_players; i++) { for (ln = lines + 7, i = 0; i < number_players; i++) {
if (player[i].in_game) { if (player[i].in_game) {
// Calculate new stock and any bonus // Calculate new stock and any bonus
old_stock = player[i].stock_owned[bb]; old_stock = player[i].stock_owned[bb];
@ -787,11 +808,22 @@ void merge_companies (map_val_t a, map_val_t b)
player[i].stock_owned[bb] = 0; player[i].stock_owned[bb] = 0;
player[i].cash += bonus; player[i].cash += bonus;
l_strfmon(buf, BUFSIZE, "%!12n", bonus); mkchstr(chbuf, BUFSIZE, attr_normal, 0, 0, 1, w - 12
mvwprintw(curwin, line, 2, " %-*.*s %'8ld %'8ld %'8ld %12s ", - MERGE_BONUS_COLS - MERGE_TOTAL_STOCK_COLS
w, w, player[i].name, old_stock, new_stock, - MERGE_NEW_STOCK_COLS - MERGE_OLD_STOCK_COLS,
player[i].stock_owned[aa], buf); &width, 1, "%s", player[i].name);
line++; leftch(curwin, ln, 4, chbuf, 1, &width);
right(curwin, ln, w - 4, attr_normal, 0, 0, 1, "%!N", bonus);
right(curwin, ln, w - 6 - MERGE_BONUS_COLS, attr_normal, 0, 0, 1,
"%'ld", player[i].stock_owned[aa]);
right(curwin, ln, w - 8 - MERGE_BONUS_COLS - MERGE_TOTAL_STOCK_COLS,
attr_normal, 0, 0, 1, "%'ld", new_stock);
right(curwin, ln, w - 10 - MERGE_BONUS_COLS - MERGE_TOTAL_STOCK_COLS
- MERGE_NEW_STOCK_COLS, attr_normal, 0, 0, 1, "%'ld",
old_stock);
ln++;
} }
} }
@ -818,7 +850,9 @@ void merge_companies (map_val_t a, map_val_t b)
deltxwin(); // "Company merger" window deltxwin(); // "Company merger" window
txrefresh(); txrefresh();
free(buf); free(chbuf_bb);
free(chbuf_aa);
free(chbuf);
} }
@ -890,7 +924,6 @@ void inc_share_price (int num, double inc)
void adjust_values (void) void adjust_values (void)
{ {
int i, x, y;
int which; int which;
@ -913,45 +946,57 @@ void adjust_values (void)
} else { } else {
double rate = randf(); double rate = randf();
char *buf = xmalloc(BUFSIZE);
for (i = 0; i < number_players; i++) { chtype *chbuf = xmalloc(BUFSIZE * sizeof(chtype));
chtype *chbuf_amt;
int w, x, lines, width, width_amt, widthbuf[6];
for (int i = 0; i < number_players; i++) {
if (player[i].in_game) { if (player[i].in_game) {
player[i].cash += player[i].stock_owned[which] * rate; player[i].cash += player[i].stock_owned[which] * rate;
} }
} }
newtxwin(14, 60, 4, WCENTER, true, attr_error_window); lines = mkchstr(chbuf, BUFSIZE, attr_error_highlight,
attr_error_normal, 0, 6, 60 - 4, widthbuf, 6,
"%s has been declared bankrupt by the "
"Interstellar Trading Bank.\n\n"
"^{The Bank has agreed to pay stock holders ^}"
"%.2f%%^{ of the share value on each share "
"owned.^}", company[which].name, rate * 100.0);
old_center(curwin, 1, attr_error_title, " Bankruptcy Court "); newtxwin(9 + lines, 60, 4, WCENTER, true, attr_error_window);
old_center(curwin, 3, attr_error_highlight, "%s has been declared", w = getmaxx(curwin);
company[which].name);
old_center(curwin, 4, attr_error_highlight,
"bankrupt by the Interstellar Trading Bank.");
old_center2(curwin, 6, attr_error_normal, attr_error_highlight, center(curwin, 1, 0, attr_error_title, 0, 0, 1,
"The Bank has agreed to pay stock holders ", " Bankruptcy Court ");
"%4.2f%%", rate * 100.0); centerch(curwin, 3, 0, chbuf, lines, widthbuf);
old_center(curwin, 7, attr_error_normal,
"of the share value on each share owned.");
l_strfmon(buf, BUFSIZE, "%12n", company[which].share_price); mkchstr(chbuf, BUFSIZE, attr_error_highlight, 0, 0, 1, w / 2,
old_center2(curwin, 9, attr_error_normal, attr_error_highlight, &width_amt, 1, "%N", company[which].share_price);
"Old share value: ", "%s", buf); chbuf_amt = chstrdup(chbuf, BUFSIZE);
l_strfmon(buf, BUFSIZE, "%12n", company[which].share_price mkchstr(chbuf, BUFSIZE, attr_error_normal, 0, 0, 1, w / 2,
* rate); &width, 1, "Amount paid per share: ");
old_center2(curwin, 10, attr_error_normal, attr_error_highlight, x = (w + width - width_amt) / 2;
"Amount paid per share: ", "%s", buf);
wait_for_key(curwin, 12, attr_error_waitforkey); right(curwin, lines + 4, x, attr_error_normal, 0, 0, 1,
"Old share value: ");
leftch(curwin, lines + 4, x, chbuf_amt, 1, &width_amt);
rightch(curwin, lines + 5, x, chbuf, 1, &width);
left(curwin, lines + 5, x, attr_error_highlight, 0, 0, 1,
"%N", company[which].share_price * rate);
wait_for_key(curwin, getmaxy(curwin) - 2, attr_error_waitforkey);
deltxwin(); deltxwin();
txrefresh(); txrefresh();
free(buf); free(chbuf_amt);
free(chbuf);
} }
for (i = 0; i < number_players; i++) { for (int i = 0; i < number_players; i++) {
player[i].stock_owned[which] = 0; player[i].stock_owned[which] = 0;
} }
@ -961,8 +1006,8 @@ void adjust_values (void)
company[which].max_stock = 0; company[which].max_stock = 0;
company[which].on_map = false; company[which].on_map = false;
for (x = 0; x < MAX_X; x++) { for (int x = 0; x < MAX_X; x++) {
for (y = 0; y < MAX_Y; y++) { for (int y = 0; y < MAX_Y; y++) {
if (galaxy_map[x][y] == COMPANY_TO_MAP((unsigned int) which)) { if (galaxy_map[x][y] == COMPANY_TO_MAP((unsigned int) which)) {
galaxy_map[x][y] = MAP_EMPTY; galaxy_map[x][y] = MAP_EMPTY;
} }
@ -980,7 +1025,7 @@ void adjust_values (void)
} }
// Make sure that a company's return is not too large // Make sure that a company's return is not too large
for (i = 0; i < MAX_COMPANIES; i++) { for (int i = 0; i < MAX_COMPANIES; i++) {
if (company[i].on_map && company[i].share_return > MAX_COMPANY_RETURN) { if (company[i].on_map && company[i].share_return > MAX_COMPANY_RETURN) {
company[i].share_return /= randf() + RETURN_DIVIDER; company[i].share_return /= randf() + RETURN_DIVIDER;
} }
@ -1000,7 +1045,7 @@ void adjust_values (void)
} }
// Give the current player the companies' dividends // Give the current player the companies' dividends
for (i = 0; i < MAX_COMPANIES; i++) { for (int i = 0; i < MAX_COMPANIES; i++) {
if (company[i].on_map && company[i].stock_issued != 0) { if (company[i].on_map && company[i].stock_issued != 0) {
player[current_player].cash += player[current_player].stock_owned[i] player[current_player].cash += player[current_player].stock_owned[i]
* company[i].share_price * company[i].share_return * company[i].share_price * company[i].share_return