diff options
Diffstat (limited to 'taipan.c')
-rw-r--r-- | taipan.c | 56 |
1 files changed, 25 insertions, 31 deletions
@@ -253,6 +253,7 @@ void cprint_taipan_prompt(void); void cprint_elder_brother_wu(void); void cprint_li_yuen(void); void cprint_firm_colon(void); +int get_ship_status(void); /* local replacement for strtoul, see strtonum.c */ unsigned long __fastcall__ strtonum(const char* nptr); @@ -463,6 +464,11 @@ void cprint_firm_colon(void) { cputs("Firm:"); } +/* making this a function saved 52 bytes */ +int get_ship_status(void) { + return 100 - ((damage * 100L) / capacity); +} + #ifdef BIGNUM bignum(big1T) = BIG_1T; bignum(big1B) = BIG_1B; @@ -589,14 +595,14 @@ void overload(void) { return; } +unsigned int gunamt(void) { + return randi()%(1000 * (get_time() + 5) / 6); +} + void new_ship(void) { - int choice = 0, - time; unsigned long amount; - // time = ((year - 1860) * 12) + month; - time = get_time(); - amount = randi()%(1000 * (time + 5) / 6) * (capacity / 50) + 1000; + amount = gunamt() * (capacity / 50) + 1000; if(cash < amount) { return; @@ -613,50 +619,37 @@ void new_ship(void) { cprintfancy(amount); cprint_taipan_prompt(); - choice = yngetc(0); - if(choice == 'y') { + if(yngetc(0) == 'y') { cash -= amount; hold += 50; capacity += 50; damage = 0; } - if (one_chance_in(2) && (guns < 1000)) - { - port_stats(); + port_stats(); + if(one_chance_in(2)) new_gun(); - } - - port_stats(); return; } -void new_gun(void) -{ - int choice = 0, - time; +void new_gun(void) { + unsigned int amount; - unsigned long amount; + if(guns >= 1000) return; - // time = ((year - 1860) * 12) + month; - time = get_time(); - amount = randi()%(1000 * (time + 5) / 6) + 500; + amount = gunamt() + 500; if((cash < amount) || (hold < 10)) { return; } - // fancy_numbers(amount, fancy_num); - compradores_report(); cputs("Do you wish to buy a ship's gun\r\nfor "); - // cputs(fancy_num); cprintfancy(amount); cprint_taipan_prompt(); - choice = yngetc(0); - if(choice == 'y') { + if(yngetc(0) == 'y') { cash -= amount; hold -= 10; guns += 1; @@ -876,7 +869,8 @@ int sea_battle(int id, int num_ships) { while(num_ships > 0) { if(damage >= capacity) return 4; - status = 100L - ((damage * 100L / capacity)); + // status = 100L - ((damage * 100L / capacity)); + status = get_ship_status(); /* // I think this is a problem: if(status <= 0) { return 4; @@ -1466,8 +1460,8 @@ unsigned int warehouse_in_use() { void port_stats(void) { - int i, in_use, - status = 100 - ((damage * 100L) / capacity); + int i, in_use, status = get_ship_status(); + // status = 100 - ((damage * 100L) / capacity); /* all the static text that used to be in port_stats() has been moved to mkportstats.c, which creates a .xex file which @@ -2401,7 +2395,7 @@ void li_yuen_extortion(void) { unsigned int i = 2, j = 0; if(time > 12) { - j = randi() % (1000 * time) + (1000 * time); + j = randi() % (2 * (1000 * time)); i = 1; } @@ -3176,7 +3170,7 @@ int main(void) { if(one_chance_in(4)) { if(one_chance_in(2)) new_ship(); - else if (guns < 1000) + else new_gun(); } |