From 5e8093e8459489a3e0ed3b24fe3cbc245b24f5fa Mon Sep 17 00:00:00 2001 From: David Meyer Date: Wed, 1 Jul 2020 23:56:44 +0900 Subject: [PATCH] Work for 7/1 --- hammurabi.c | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/hammurabi.c b/hammurabi.c index 5bd922d..6a39f71 100644 --- a/hammurabi.c +++ b/hammurabi.c @@ -60,18 +60,15 @@ One person needs to eat 20 bushels of grain per year to stay healthy.\n\ "; char MSGMENU[]= -"You may use your grain to ...\n\ -(F)eed your people,\n\ -(P)lant crops on your land, or\n\ -(B)uy more land. \n\ -Or ...\n\ -(S)ell land to increase your grain.\n\ -You may also ...\n\ -(E)xecute your current plan,\n\ -(R)eset your current plan and start over, or\n\ -(Q)uit the game.\n\ +"\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"; + char MSGSPLASH[] = " ___ ___ ___. .__ \n\ / | \\_____ _____ _____ __ ______________ \\_ |__ |__|\n\ @@ -387,21 +384,23 @@ planmenu(void) int cmdch = 0; Plancmd cmd; - if(foodgrain > 0 || landsale != 0 || plantland > 0) - { - print("You are currently planning ...\n"); - if(foodgrain > 0) - print("to provide %d bushels of grain to feed the people\n", foodgrain); - if(plantland > 0) - print("to plant %d acres of land using %d bushels of grain for seed\n", - plantland, plantland / 2); - if(landsale > 0) - print("to sell %d acres of land for %d bushels of grain\n", landsale, - landsale * landprice); - if(landsale < 0) - print("to buy %d acres of land for %d bushels of grain\n", landsale * -1, - landsale * landprice * -1); - } + print("\n Plan for Year %d\n", Year); + 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); + if(landsale < 0) + 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); + if(plantland > 0) + 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, + 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(MSGMENU); if(write(CONSCTL, "rawon", 5) != 5) exits("\ncan't turn off echo\n"); while(cmdch == 0) @@ -529,7 +528,7 @@ scanyes(char *prompt) if(write(CONSCTL, "rawon", 5) != 5) exits("\ncan't turn off echo\n"); while(in != 'y' && in != 'n') { - print("%s [y/n] ", prompt); + print("%s [yn] ", prompt); in = getchar(); if(in == EOF) exits("\nerror reading terminal input\n"); print("%c\n", in); @@ -544,3 +543,4 @@ setlandprice(void) { landprice = nrand(10) + 17; } +