Work on 6/12 (getting close!)
This commit is contained in:
parent
287e6fa0f5
commit
e808c8602c
48
hammurabi.c
48
hammurabi.c
@ -4,6 +4,27 @@
|
|||||||
* Copyright 2020 David Meyer <papa@sdf.org> +JMJ
|
* Copyright 2020 David Meyer <papa@sdf.org> +JMJ
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
|
Hammurabi To-Dos
|
||||||
|
|
||||||
|
6/21
|
||||||
|
|
||||||
|
v Complete splash message: version, author, one-liner
|
||||||
|
- Write man page (for TWENEX release?)
|
||||||
|
- Complete/format help text: add introduction, credit to Ahl, separate intro and help
|
||||||
|
- Add help choice to annual plan menu
|
||||||
|
v Divider line is off-center
|
||||||
|
- Reformat menu to stand out -- plan summary should include grain and land balances
|
||||||
|
v BUG: buying land resulted in REDUCTION of land held
|
||||||
|
- Refactor and document main loop
|
||||||
|
|
||||||
|
/}_ _
|
||||||
|
\/\/
|
||||||
|
|\
|
||||||
|
|\
|
||||||
|
|_\_
|
||||||
|
|
||||||
|
*/
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -20,7 +41,7 @@ typedef enum {BUY, SELL, FEED, PLANT, RESET, EXEC, CALC, QUIT} Plancmd;
|
|||||||
|
|
||||||
/* Message texts */
|
/* Message texts */
|
||||||
char MSGDIV[] =
|
char MSGDIV[] =
|
||||||
"------------------------------<<<<>>>>-----------------------------------\n";
|
" ----------------- <<<<>>>> --------------------\n";
|
||||||
|
|
||||||
char MSGHELP[] =
|
char MSGHELP[] =
|
||||||
"Help text here\n\
|
"Help text here\n\
|
||||||
@ -50,10 +71,10 @@ char MSGSPLASH[] =
|
|||||||
\\ Y // __ \\| Y Y \\ Y Y \\ | /| | \\// __ \\| \\_\\ \\ |\n\
|
\\ Y // __ \\| Y Y \\ Y Y \\ | /| | \\// __ \\| \\_\\ \\ |\n\
|
||||||
\\___|_ /(____ /__|_| /__|_| /____/ |__| (____ /___ /__|\n\
|
\\___|_ /(____ /__|_| /__|_| /____/ |__| (____ /___ /__|\n\
|
||||||
\\/ \\/ \\/ \\/ \\/ \\/ \n\
|
\\/ \\/ \\/ \\/ \\/ \\/ \n\
|
||||||
,.__.,\n\
|
The ancient game of ,.__., resource management\n\
|
||||||
/,',.`.\\\n\
|
/,',.`.\\\n\
|
||||||
____|:|db|:|____\n\
|
Version 1.0 ____|:|db|:|____ by David Meyer\n\
|
||||||
___//\"\"\"|:|88|:|\"\"\"\\\\___\n\
|
for Plan 9 ___//\"\"\"|:|88|:|\"\"\"\\\\___ <papa@sdf.org>\n\
|
||||||
_____//\":=_=_=_=|--|=_=_=_=:\"\\\\_____\n\
|
_____//\":=_=_=_=|--|=_=_=_=:\"\\\\_____\n\
|
||||||
__/.-._//__|L_L_L_L|--|L_L_L_L|__\\\\_.-.\\__\n\
|
__/.-._//__|L_L_L_L|--|L_L_L_L|__\\\\_.-.\\__\n\
|
||||||
//\"||m|:.-. .-. .-.,.__.,.-. .-. .-.:|m||\"\\\\\n\
|
//\"||m|:.-. .-. .-.,.__.,.-. .-. .-.:|m||\"\\\\\n\
|
||||||
@ -172,8 +193,14 @@ main(void)
|
|||||||
|
|
||||||
printgreeting();
|
printgreeting();
|
||||||
printyearrept();
|
printyearrept();
|
||||||
|
printstatus();
|
||||||
|
|
||||||
if(Year == MAXYEARS) completedterm();
|
if(Year == MAXYEARS) completedterm();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setlandprice();
|
||||||
|
printlandprice();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while(Year < MAXYEARS && terminated == FALSE);
|
} while(Year < MAXYEARS && terminated == FALSE);
|
||||||
@ -191,13 +218,13 @@ completedterm(void)
|
|||||||
print("In your %d-year reign, %d people died of starvation, an average of %d people per year.\n", MAXYEARS, StarvedTot, avgstarvepct);
|
print("In your %d-year reign, %d people died of starvation, an average of %d people per year.\n", MAXYEARS, StarvedTot, avgstarvepct);
|
||||||
print("You started with %d acres per person and ended with %d acres per person.\n", INITLAND / INITPOP, landperperson);
|
print("You started with %d acres per person and ended with %d acres per person.\n", INITLAND / INITPOP, landperperson);
|
||||||
if(avgstarvepct > 33 || landperperson < 7) printdeposed();
|
if(avgstarvepct > 33 || landperperson < 7) printdeposed();
|
||||||
else if(avgstarvepct > 10 || landperperson < 9) print("Your heavy-handed performance smacks of Nero and Ivan IV. Your (surviving) people find you an unpleasant ruler, and, frankly, hate your guts!");
|
else if(avgstarvepct > 10 || landperperson < 9) print("Your heavy-handed performance smacks of Nero and Ivan IV. Your (surviving) people find you an unpleasant ruler, and, frankly, hate your guts!\n");
|
||||||
else if(avgstarvepct > 3 || landperperson < 10)
|
else if(avgstarvepct > 3 || landperperson < 10)
|
||||||
{
|
{
|
||||||
print("Your performance could have been better, but wasn't too bad. ");
|
print("Your performance could have been better, but wasn't too bad. ");
|
||||||
if(likeassassination > 0) print("%d %s would like to see you assassinated, but we all have our trivial problems.\n", likeassassination, (likeassassination == 1 ? "person" : "people"));
|
if(likeassassination > 0) print("%d %s would like to see you assassinated, but we all have our trivial problems.\n", likeassassination, (likeassassination == 1 ? "person" : "people"));
|
||||||
}
|
}
|
||||||
else print("A fantastic performance! Charlemagne, Disraeli, and Jefferson combined could not have done better!");
|
else print("A fantastic performance! Charlemagne, Disraeli, and Jefferson combined could not have done better!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -304,7 +331,7 @@ inputplant(void)
|
|||||||
Boolean valid = FALSE;
|
Boolean valid = FALSE;
|
||||||
|
|
||||||
grainbal = Grain - foodgrain + (landsale * landprice);
|
grainbal = Grain - foodgrain + (landsale * landprice);
|
||||||
landbal = Land + landsale;
|
landbal = Land - landsale;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
print("How many acres do you wish to plant? ");
|
print("How many acres do you wish to plant? ");
|
||||||
@ -434,10 +461,10 @@ 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");
|
||||||
break;
|
break;
|
||||||
case CALC:
|
case CALC:
|
||||||
microcalc();
|
// microcalc();
|
||||||
break;
|
break;
|
||||||
case QUIT:
|
case QUIT:
|
||||||
play = FALSE;
|
play = FALSE;
|
||||||
@ -482,7 +509,8 @@ printyearrept(void)
|
|||||||
harvyield, plantland * harvyield);
|
harvyield, plantland * harvyield);
|
||||||
if(ratgrain > 0) print("Rats ate %d bushels of grain.\n", ratgrain);
|
if(ratgrain > 0) print("Rats ate %d bushels of grain.\n", ratgrain);
|
||||||
if(newpop > 0) print("The population increased by %d.\n", newpop);
|
if(newpop > 0) print("The population increased by %d.\n", newpop);
|
||||||
|
if(starvedeath > 0) print("%d people starved!\n", starvedeath);
|
||||||
|
if(plaguedeath > 0) print("A horrible plague struck! %d people have died!\n", plaguedeath);
|
||||||
}
|
}
|
||||||
|
|
||||||
Boolean
|
Boolean
|
||||||
|
Loading…
Reference in New Issue
Block a user