diff --git a/hammurabi.c b/hammurabi.c index 6a39f71..42ee713 100644 --- a/hammurabi.c +++ b/hammurabi.c @@ -32,6 +32,14 @@ v BUG: buying land resulted in REDUCTION of land held |___________________| (___________________@ +.______________________________________________________________________________. +| _ _ _ _ _ _ _ _ _ _ | +| /} \/}/ /} \/}/ /} \/}/ /} \/}/ /} \/}/ /} | +|_/|\_ |_ _/|\_ |_ _/|\_ |_ _/|\_ |_ _/|\_ |_ _/|\_| +| / \ | \ / \ | \ / \ | \ / \ | \ / \ | \ / \ | +|vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv| + + */ #include #include @@ -61,13 +69,13 @@ One person needs to eat 20 bushels of grain per year to stay healthy.\n\ char MSGMENU[]= "\n\ - [F]eed your people with grain | [E]xecute your current plan\n\ - [P]lant crops on your land | [R]eset your current plan and start over\n\ - [B]uy more land | [Q]uit the game\n\ + [F]eed your people with grain | [E]xecute your current plan\n\ + [P]lant crops on your land | [R]eset your current plan and start over\n\ + [B]uy more land | [Q]uit the game\n\ "; char MSGPLTOT[] = -" ------------------------------ | ------------------------------\n"; +" ------------------------------- | -------------------------------\n"; char MSGSPLASH[] = " ___ ___ ___. .__ \n\ @@ -241,7 +249,7 @@ inputbuy(void) grainbal = Grain - foodgrain - (plantland / 2); do { - print("The price of land is %d bushels per acre.\n", landprice); + print("\nThe price of land is %d bushels per acre.\n", landprice); print("How many acres do you wish to buy? "); buy = inputiexpr(); price = buy * landprice; @@ -264,7 +272,7 @@ inputfood(void) grainbal = Grain + (landsale * landprice) - (plantland / 2); do { - print("How much grain do you wish to give your people for food? "); + print("\nHow much grain do you wish to give your people for food? "); food = inputiexpr(); if(food < 0) print("Sire, it is impossible to give the people a negative amount of grain.\nEnter \"0\" to return to the menu.\n"); @@ -339,7 +347,7 @@ inputplant(void) landbal = Land - landsale; do { - print("How many acres do you wish to plant? "); + print("\nHow many acres do you wish to plant? "); plant = inputiexpr(); if(plant < 0) print("Sire, it is impossible to plant a negative amount of land.\nEnter \"0\" to return to the menu.\n"); @@ -361,7 +369,7 @@ inputsell(void) landbal = Land - plantland; do { - print("The price of land is %d bushels per acre.\n", landprice); + print("\nThe price of land is %d bushels per acre.\n", landprice); print("How many acres do you wish to sell? "); sell = inputiexpr(); if(sell < 0) @@ -385,27 +393,27 @@ planmenu(void) Plancmd cmd; print("\n Plan for Year %d\n", Year); - print(" Grain in storage %7d | Land (price %2d) %7d\n", Grain, landprice, Land); + print(" Grain in storage %7d | Land (price %2d) %7d\n", Grain, landprice, Land); if(landsale > 0) - print(" From land sale %7d | Sell %7d\n", landsale * landprice, landsale); + print(" From land sale %7d | Sell %7d\n", landsale * landprice, landsale); if(landsale < 0) - print(" For land purchase%7d | Purchase %7d\n", landsale * landprice * -1, landsale * -1); + print(" For land purchase%7d | Purchase %7d\n", landsale * landprice * -1, landsale * -1); if(landsale != 0) - print("%s Net %7d | Net %7d\n", MSGPLTOT, Grain + (landsale * landprice), Land - landsale); - if(foodgrain > 0) print(" Provide for food%7d |\n", foodgrain); + print("%s Net %7d | Net %7d\n", MSGPLTOT, Grain + (landsale * landprice), Land - landsale); + if(foodgrain > 0) print(" Provide for food %7d |\n", foodgrain); if(plantland > 0) - print(" Provide for seed%7d | Plant %7d\n", plantland / 2, plantland); + print(" Provide for seed %7d | Plant %7d\n", plantland / 2, plantland); if(foodgrain > 0 || plantland > 0) - print("%s Balance %7d | Fallow acres %7d\n", MSGPLTOT, + print("%s Balance %7d | Fallow acres %7d\n", MSGPLTOT, Grain + (landsale * landprice) - foodgrain - (plantland / 2), Land - landsale - plantland); - print("\n Population: %6d (need food: %6d; can farm: %6d)\n", Pop, Pop * 20, Pop * 10); + print("\n Population: %d (need food: %d; can farm: %d)\n", Pop, Pop * 20, Pop * 10); print(MSGMENU); if(write(CONSCTL, "rawon", 5) != 5) exits("\ncan't turn off echo\n"); while(cmdch == 0) { - print("What is your choice? [fpbserq] "); + print(" What is your choice? [fpbserq] "); cmdch = getchar(); if(cmdch == EOF) exits("\nerror reading terminal input\n"); print("%c\n", cmdch); @@ -468,7 +476,7 @@ planyear(void) foodgrain = landsale = plantland = 0; break; case EXEC: - print("So it shall be written, so it shall be done.\n"); + print("\nSo it shall be written, so it shall be done.\n"); break; case CALC: // microcalc(); @@ -490,8 +498,8 @@ printdeposed(void) void printgreeting(void) { - print(MSGDIV); - print("O %s One, I beg to report,\n", HONORIFIC[nrand(MAXHONOR + 1)]); +// print(MSGDIV); + print("\nO %s One, I beg to report,\n", HONORIFIC[nrand(MAXHONOR + 1)]); } void @@ -511,6 +519,22 @@ printstatus(void) void printyearrept(void) { + print(" ____________________________________________________________________\n"); + print(" ( YEAR %2d @\n", Year); + print(" | Harvest yield %1d bushels per acre | (Land price %2d bushels per acre) |\n", harvyield, landprice); + print(" /}_ _ | In Year %d\n", Year); + print(" \\/\\/ | %d bushels were harvested per acre, for a total harvest of %d bushels\n", + harvyield, plantland * harvyield); + print(" |\\ |"); + if(ratgrain > 0) print(" Rats ate %d bushels of grain.", ratgrain); + print("\n |\\ |"); + if(newpop > 0) print(" The population increased by %d.", newpop); + print("\n |_\\_ |"); + if(starvedeath > 0) print(" %d people starved!", starvedeath); + print("\n |"); + if(plaguedeath > 0) print(" A horrible plague struck! %d people have died!", plaguedeath); + print("\n |________________________________________________50\n"); + print(" (________________________________________________50\n"); print("In Year %d,\n", Year); print("%d bushels were harvested per acre, for a total harvest of %d bushels.\n", harvyield, plantland * harvyield);