diff options
Diffstat (limited to 'taipan.c')
-rw-r--r-- | taipan.c | 61 |
1 files changed, 52 insertions, 9 deletions
@@ -22,7 +22,7 @@ /* define this for testing sea_battle(). it causes a pirate attack every time you leave port. */ -#define COMBAT_TEST +// #define COMBAT_TEST /* define this to show internals of damage calculation */ // #define DAMAGE_TEST @@ -33,7 +33,7 @@ /* define this to start the game in the year 1869, with 1000 capacity, 20 guns, and 1 billion cash and bank. */ -// #define TIMEWARP +#define TIMEWARP /* define this to start the game in a 99% damaged ship */ // #define ALMOST_DEAD @@ -262,6 +262,8 @@ char *st[] = { "Critical", " Poor", " Fair", #ifdef BIGNUM bignum(bank) = BIG_0; +bignum(interest_rate) = BIG_1_005; +bignum(big_max_ulong) = BIG_MAX_ULONG; #else unsigned long bank = 0; #endif @@ -1284,7 +1286,12 @@ void cash_or_guns(void) year = 1869; cash = 1000000000L; // cash = 3500000L; +#ifdef BIGNUM + memcpy(bank, big1M, 6); // FIXME: big_copy + big_mul(bank, bank, big1M); +#else bank = 1000000000L; +#endif debt = 0; capacity = 1000; hold = 800; @@ -2062,7 +2069,7 @@ void quit(void) if(debt >= DEBT_MAX) wu_assassin = 1; #ifdef BIGNUM - big_bank_interest(); + big_mul(bank, bank, interest_rate); #else /* bank calculation original formula was: bank = bank + (bank * .005); @@ -2236,7 +2243,7 @@ void elder_brother_wu(void) } else if (choice == 'y') { if (((int)cash == 0) && #ifdef BIGNUM - (big_cmp(bank, B_0) == 0) + (bank[0] == '\0') #else ((int)bank == 0) #endif @@ -2458,13 +2465,13 @@ int port_choices(void) { if(port == 1) { if(cash > 1000000L) { retire_ok = 1; - } else if(big_cmp(bank, BIG_1M) >= 0) { + } else if(big_cmp(bank, big1M) >= 0) { retire_ok = 1; } else { bignum(tmp); ulong_to_big(cash, tmp); big_add(tmp, tmp, bank); - if(big_cmp(tmp, BIG_1M) >= 0) + if(big_cmp(tmp, big1M) >= 0) retire_ok = 1; } } @@ -2716,6 +2723,11 @@ void sell(void) { void visit_bank(void) { long amount = 0; +#ifdef BIGNUM + bignum(bigamt); + bignum(biglimit); + bignum(bigcash); +#endif for (;;) { @@ -2729,12 +2741,14 @@ void visit_bank(void) } if (amount <= cash) { + cash -= amount; #ifdef BIGNUM + ulong_to_big(amount, bigamt); + big_add(bank, bank, bigamt); #else - cash -= amount; bank += amount; - break; #endif + break; } else { you_only_have(0); } @@ -2748,6 +2762,35 @@ void visit_bank(void) amount = get_num(); #ifdef BIGNUM + if(amount == -1) { + memcpy(bigamt, bank, 6); // FIXME: big_copy + } else { + ulong_to_big(amount, bigamt); + } + + ulong_to_big(cash, bigcash); + big_sub(biglimit, big_max_ulong, bigcash); + cputs("\rcash "); + cprintfancy_big(bigcash); + agetc(); + cputs("\ramt "); + cprintfancy_big(bigamt); + agetc(); + cputs("\rlimit "); + cprintfancy_big(biglimit); + agetc(); + if(big_cmp(bigamt, biglimit) >= 0) { +// hangx: goto hangx; + cputs("\r\nYou cannot carry so much cash, Taipan!"); + bad_joss_sound(); + timed_getch(TMOUT_1S); + continue; + } + + big_sub(bank, bank, bigamt); + big_add(bigcash, bigcash, bigamt); + big_to_ulong(bigcash, &cash); + break; #else if (amount == -1) { @@ -2758,10 +2801,10 @@ void visit_bank(void) cash += amount; bank -= amount; break; -#endif } else { you_only_have(1); } +#endif } port_stats(); |