Work for 7/1

This commit is contained in:
David Meyer 2020-07-01 23:56:44 +09:00
parent bd525cc54a
commit 5e8093e845
1 changed files with 26 additions and 26 deletions

View File

@ -60,18 +60,15 @@ One person needs to eat 20 bushels of grain per year to stay healthy.\n\
"; ";
char MSGMENU[]= char MSGMENU[]=
"You may use your grain to ...\n\ "\n\
(F)eed your people,\n\ [F]eed your people with grain | [E]xecute your current plan\n\
(P)lant crops on your land, or\n\ [P]lant crops on your land | [R]eset your current plan and start over\n\
(B)uy more land. \n\ [B]uy more land | [Q]uit the game\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\
"; ";
char MSGPLTOT[] =
" ------------------------------ | ------------------------------\n";
char MSGSPLASH[] = char MSGSPLASH[] =
" ___ ___ ___. .__ \n\ " ___ ___ ___. .__ \n\
/ | \\_____ _____ _____ __ ______________ \\_ |__ |__|\n\ / | \\_____ _____ _____ __ ______________ \\_ |__ |__|\n\
@ -387,21 +384,23 @@ planmenu(void)
int cmdch = 0; int cmdch = 0;
Plancmd cmd; Plancmd cmd;
if(foodgrain > 0 || landsale != 0 || plantland > 0) print("\n Plan for Year %d\n", Year);
{ print(" Grain in storage %7d | Land (price %2d) %7d\n", Grain, landprice, Land);
print("You are currently planning ...\n"); if(landsale > 0)
if(foodgrain > 0) print(" From land sale %7d | Sell %7d\n", landsale * landprice, landsale);
print("to provide %d bushels of grain to feed the people\n", foodgrain); if(landsale < 0)
if(plantland > 0) print(" For land purchase%7d | Purchase %7d\n", landsale * landprice * -1, landsale * -1);
print("to plant %d acres of land using %d bushels of grain for seed\n", if(landsale != 0)
plantland, plantland / 2); print("%s Net %7d | Net %7d\n", MSGPLTOT, Grain + (landsale * landprice), Land - landsale);
if(landsale > 0) if(foodgrain > 0) print(" Provide for food%7d |\n", foodgrain);
print("to sell %d acres of land for %d bushels of grain\n", landsale, if(plantland > 0)
landsale * landprice); print(" Provide for seed%7d | Plant %7d\n", plantland / 2, plantland);
if(landsale < 0) if(foodgrain > 0 || plantland > 0)
print("to buy %d acres of land for %d bushels of grain\n", landsale * -1, print("%s Balance %7d | Fallow acres %7d\n", MSGPLTOT,
landsale * landprice * -1); 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); print(MSGMENU);
if(write(CONSCTL, "rawon", 5) != 5) exits("\ncan't turn off echo\n"); if(write(CONSCTL, "rawon", 5) != 5) exits("\ncan't turn off echo\n");
while(cmdch == 0) while(cmdch == 0)
@ -529,7 +528,7 @@ scanyes(char *prompt)
if(write(CONSCTL, "rawon", 5) != 5) exits("\ncan't turn off echo\n"); if(write(CONSCTL, "rawon", 5) != 5) exits("\ncan't turn off echo\n");
while(in != 'y' && in != 'n') while(in != 'y' && in != 'n')
{ {
print("%s [y/n] ", prompt); print("%s [yn] ", prompt);
in = getchar(); in = getchar();
if(in == EOF) exits("\nerror reading terminal input\n"); if(in == EOF) exits("\nerror reading terminal input\n");
print("%c\n", in); print("%c\n", in);
@ -544,3 +543,4 @@ setlandprice(void)
{ {
landprice = nrand(10) + 17; landprice = nrand(10) + 17;
} }