diff options
author | B. Watson <yalhcru@gmail.com> | 2021-04-16 03:39:17 -0400 |
---|---|---|
committer | B. Watson <yalhcru@gmail.com> | 2021-04-16 03:39:17 -0400 |
commit | 0a3d31082851621d9e42ff429314a34c80a6f892 (patch) | |
tree | 357ea4fff38dfe734b25722eef63c39def841433 | |
parent | c1822ffdb129af99ea85d24a5016237312786966 (diff) | |
download | taipan-0a3d31082851621d9e42ff429314a34c80a6f892.tar.gz |
combat: add "you have no cargo" message, costs 21 bytes
-rw-r--r-- | taipan.c | 168 |
1 files changed, 90 insertions, 78 deletions
@@ -1037,6 +1037,8 @@ int ships_on_screen[10]; extern char have_ships_on_screen(void); extern void clear_ships_on_screen(void); +char have_no_cargo(void); + char sea_battle(char id, int num_ships) { /* These locals seem to eat too much stack and cause weird behaviour, so they're static now. */ @@ -1099,7 +1101,7 @@ char sea_battle(char id, int num_ships) { */ // flushinp(); - gotox0y(5); + gotox0y(6); clrtoeol(); // cputs("Current seaworthiness: "); @@ -1180,8 +1182,8 @@ char sea_battle(char id, int num_ships) { plus_or_space(num_ships > num_on_screen); - gotox0y(16); - crlf(); + // gotox0y(16); + // crlf(); do { targeted = randi()%10; @@ -1266,7 +1268,7 @@ char sea_battle(char id, int num_ships) { } } - gotox0y(16); + // gotox0y(16); set_orders(); } @@ -1274,7 +1276,9 @@ char sea_battle(char id, int num_ships) { // cputs("We have no guns"); print_combat_msg(M_we_have_no_guns); cprint_taipan_bangbang(); + bad_joss_sound(); turbo = 0; + orders = 0; set_orders(); } else if (orders == 3) { choice = 0; @@ -1282,90 +1286,98 @@ char sea_battle(char id, int num_ships) { total = 0; turbo = 0; - // cputs("You have the following on board"); - print_combat_msg(M_you_have_on_board); - cprint_colon_space(); - gotoxy(4, 4); - // cputs(item[0]); - print_msg(M_opium); - // cputs(": "); - cprint_colon_space(); - cprintulong(hold_[0]); - gotoxy(24, 4); - // cputs(item[1]); - print_msg(M_silk); - // cputs(": "); - cprint_colon_space(); - cprintulong(hold_[1]); - gotox0y(5); - clrtoeol(); - gotox(5); - // cputs(item[2]); - print_msg(M_arms); - // cputs(": "); - cprint_colon_space(); - cprintulong(hold_[2]); - gotoxy(21, 5); - // cputs(item[3]); - print_msg(M_gen_cargo); - // cputs(": "); - cprint_colon_space(); - cprintulong(hold_[3]); - - gotox0y(6); - clrtoeol(); - // cputs("What shall I throw overboard"); - print_msg(M_what_shall_i_throw); - cprint_taipan_prompt(); - - choice = get_item(1); + if(have_no_cargo()) { + print_combat_msg(M_you_have_no_cargo); + cprint_taipan_bangbang(); + bad_joss_sound(); + orders = 0; + set_orders(); + } else { + // cputs("You have the following on board"); + print_combat_msg(M_you_have_on_board); + cprint_colon_space(); + gotoxy(4, 4); + // cputs(item[0]); + print_msg(M_opium); + // cputs(": "); + cprint_colon_space(); + cprintulong(hold_[0]); + gotoxy(24, 4); + // cputs(item[1]); + print_msg(M_silk); + // cputs(": "); + cprint_colon_space(); + cprintulong(hold_[1]); + gotox0y(5); + clrtoeol(); + gotox(5); + // cputs(item[2]); + print_msg(M_arms); + // cputs(": "); + cprint_colon_space(); + cprintulong(hold_[2]); + gotoxy(21, 5); + // cputs(item[3]); + print_msg(M_gen_cargo); + // cputs(": "); + cprint_colon_space(); + cprintulong(hold_[3]); - if(choice < 4) { gotox0y(6); clrtoeol(); - // cputs("How much"); - print_msg(M_how_much); + // cputs("What shall I throw overboard"); + print_msg(M_what_shall_i_throw); cprint_taipan_prompt(); - amount = get_num(); - if((hold_[choice] > 0) && ((amount == UINT32_MAX) || (amount > hold_[choice]))) - { - amount = hold_[choice]; - } - total = hold_[choice]; - } else { - total = hold_[0] + hold_[1] + hold_[2] + hold_[3]; - } + choice = get_item(1); - gotox0y(4); - cblank(120); + if(choice < 4) { + gotox0y(6); + clrtoeol(); + // cputs("How much"); + print_msg(M_how_much); + cprint_taipan_prompt(); - if(total > 0) { - // cputs("Let's hope we lose 'em"); - print_combat_msg(M_hope_we_lose_em); - cprint_taipan_bang(); - bad_joss_sound(); - if (choice < 4) { - hold_[choice] -= amount; - hold += amount; - ok += (amount / 10); + amount = get_num(); + if((hold_[choice] > 0) && ((amount == UINT32_MAX) || (amount > hold_[choice]))) + { + amount = hold_[choice]; + } + total = hold_[choice]; } else { - hold_[0] = 0; - hold_[1] = 0; - hold_[2] = 0; - hold_[3] = 0; - hold += total; - ok += (total / 10); + total = hold_[0] + hold_[1] + hold_[2] + hold_[3]; } - set_orders(); - } else { - // cputs("There's nothing there"); - print_combat_msg(M_nothing_there); - cprint_taipan_bang(); - good_joss_sound(); + gotox0y(4); + cblank(120); + + if(total > 0) { + // cputs("Let's hope we lose 'em"); + print_combat_msg(M_hope_we_lose_em); + cprint_taipan_bang(); + bad_joss_sound(); + if (choice < 4) { + hold_[choice] -= amount; + hold += amount; + ok += (amount / 10); + } else { + hold_[0] = 0; + hold_[1] = 0; + hold_[2] = 0; + hold_[3] = 0; + hold += total; + ok += (total / 10); + } - set_orders(); + set_orders(); + } else { + // cputs("There's nothing there"); + print_combat_msg(M_nothing_there); + cprint_taipan_bang(); + good_joss_sound(); + + set_orders(); + } } } @@ -1418,7 +1430,7 @@ char sea_battle(char id, int num_ships) { plus_or_space(num_ships > num_on_screen); } - gotox0y(16); + // gotox0y(16); set_orders(); } |