Work for 7/2
This commit is contained in:
parent
5e8093e845
commit
5519fadc1c
64
hammurabi.c
64
hammurabi.c
|
@ -32,6 +32,14 @@ v BUG: buying land resulted in REDUCTION of land held
|
||||||
|___________________|
|
|___________________|
|
||||||
(___________________@
|
(___________________@
|
||||||
|
|
||||||
|
.______________________________________________________________________________.
|
||||||
|
| _ _ _ _ _ _ _ _ _ _ |
|
||||||
|
| /} \/}/ /} \/}/ /} \/}/ /} \/}/ /} \/}/ /} |
|
||||||
|
|_/|\_ |_ _/|\_ |_ _/|\_ |_ _/|\_ |_ _/|\_ |_ _/|\_|
|
||||||
|
| / \ | \ / \ | \ / \ | \ / \ | \ / \ | \ / \ |
|
||||||
|
|vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv|
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
|
@ -61,13 +69,13 @@ One person needs to eat 20 bushels of grain per year to stay healthy.\n\
|
||||||
|
|
||||||
char MSGMENU[]=
|
char MSGMENU[]=
|
||||||
"\n\
|
"\n\
|
||||||
[F]eed your people with grain | [E]xecute your current plan\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\
|
[P]lant crops on your land | [R]eset your current plan and start over\n\
|
||||||
[B]uy more land | [Q]uit the game\n\
|
[B]uy more land | [Q]uit the game\n\
|
||||||
";
|
";
|
||||||
|
|
||||||
char MSGPLTOT[] =
|
char MSGPLTOT[] =
|
||||||
" ------------------------------ | ------------------------------\n";
|
" ------------------------------- | -------------------------------\n";
|
||||||
|
|
||||||
char MSGSPLASH[] =
|
char MSGSPLASH[] =
|
||||||
" ___ ___ ___. .__ \n\
|
" ___ ___ ___. .__ \n\
|
||||||
|
@ -241,7 +249,7 @@ inputbuy(void)
|
||||||
grainbal = Grain - foodgrain - (plantland / 2);
|
grainbal = Grain - foodgrain - (plantland / 2);
|
||||||
do
|
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? ");
|
print("How many acres do you wish to buy? ");
|
||||||
buy = inputiexpr();
|
buy = inputiexpr();
|
||||||
price = buy * landprice;
|
price = buy * landprice;
|
||||||
|
@ -264,7 +272,7 @@ inputfood(void)
|
||||||
grainbal = Grain + (landsale * landprice) - (plantland / 2);
|
grainbal = Grain + (landsale * landprice) - (plantland / 2);
|
||||||
do
|
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();
|
food = inputiexpr();
|
||||||
if(food < 0)
|
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");
|
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;
|
landbal = Land - landsale;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
print("How many acres do you wish to plant? ");
|
print("\nHow many acres do you wish to plant? ");
|
||||||
plant = inputiexpr();
|
plant = inputiexpr();
|
||||||
if(plant < 0)
|
if(plant < 0)
|
||||||
print("Sire, it is impossible to plant a negative amount of land.\nEnter \"0\" to return to the menu.\n");
|
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;
|
landbal = Land - plantland;
|
||||||
do
|
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? ");
|
print("How many acres do you wish to sell? ");
|
||||||
sell = inputiexpr();
|
sell = inputiexpr();
|
||||||
if(sell < 0)
|
if(sell < 0)
|
||||||
|
@ -385,27 +393,27 @@ planmenu(void)
|
||||||
Plancmd cmd;
|
Plancmd cmd;
|
||||||
|
|
||||||
print("\n Plan for Year %d\n", Year);
|
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)
|
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)
|
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)
|
if(landsale != 0)
|
||||||
print("%s Net %7d | Net %7d\n", MSGPLTOT, Grain + (landsale * landprice), Land - landsale);
|
print("%s Net %7d | Net %7d\n", MSGPLTOT, Grain + (landsale * landprice), Land - landsale);
|
||||||
if(foodgrain > 0) print(" Provide for food%7d |\n", foodgrain);
|
if(foodgrain > 0) print(" Provide for food %7d |\n", foodgrain);
|
||||||
if(plantland > 0)
|
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)
|
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),
|
Grain + (landsale * landprice) - foodgrain - (plantland / 2),
|
||||||
Land - landsale - plantland);
|
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);
|
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)
|
||||||
{
|
{
|
||||||
print("What is your choice? [fpbserq] ");
|
print(" What is your choice? [fpbserq] ");
|
||||||
cmdch = getchar();
|
cmdch = getchar();
|
||||||
if(cmdch == EOF) exits("\nerror reading terminal input\n");
|
if(cmdch == EOF) exits("\nerror reading terminal input\n");
|
||||||
print("%c\n", cmdch);
|
print("%c\n", cmdch);
|
||||||
|
@ -468,7 +476,7 @@ planyear(void)
|
||||||
foodgrain = landsale = plantland = 0;
|
foodgrain = landsale = plantland = 0;
|
||||||
break;
|
break;
|
||||||
case EXEC:
|
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;
|
break;
|
||||||
case CALC:
|
case CALC:
|
||||||
// microcalc();
|
// microcalc();
|
||||||
|
@ -490,8 +498,8 @@ printdeposed(void)
|
||||||
void
|
void
|
||||||
printgreeting(void)
|
printgreeting(void)
|
||||||
{
|
{
|
||||||
print(MSGDIV);
|
// print(MSGDIV);
|
||||||
print("O %s One, I beg to report,\n", HONORIFIC[nrand(MAXHONOR + 1)]);
|
print("\nO %s One, I beg to report,\n", HONORIFIC[nrand(MAXHONOR + 1)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -511,6 +519,22 @@ printstatus(void)
|
||||||
void
|
void
|
||||||
printyearrept(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("In Year %d,\n", Year);
|
||||||
print("%d bushels were harvested per acre, for a total harvest of %d bushels.\n",
|
print("%d bushels were harvested per acre, for a total harvest of %d bushels.\n",
|
||||||
harvyield, plantland * harvyield);
|
harvyield, plantland * harvyield);
|
||||||
|
|
Loading…
Reference in New Issue