Work on 6/12 (getting close!)

This commit is contained in:
David Meyer 2020-06-21 23:52:06 +09:00
parent 287e6fa0f5
commit e808c8602c
1 changed files with 38 additions and 10 deletions

View File

@ -4,6 +4,27 @@
* 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 <libc.h>
#include <stdio.h>
@ -20,7 +41,7 @@ typedef enum {BUY, SELL, FEED, PLANT, RESET, EXEC, CALC, QUIT} Plancmd;
/* Message texts */
char MSGDIV[] =
"------------------------------<<<<>>>>-----------------------------------\n";
" ----------------- <<<<>>>> --------------------\n";
char MSGHELP[] =
"Help text here\n\
@ -50,10 +71,10 @@ char MSGSPLASH[] =
\\ Y // __ \\| Y Y \\ Y Y \\ | /| | \\// __ \\| \\_\\ \\ |\n\
\\___|_ /(____ /__|_| /__|_| /____/ |__| (____ /___ /__|\n\
\\/ \\/ \\/ \\/ \\/ \\/ \n\
,.__.,\n\
The ancient game of ,.__., resource management\n\
/,',.`.\\\n\
____|:|db|:|____\n\
___//\"\"\"|:|88|:|\"\"\"\\\\___\n\
Version 1.0 ____|:|db|:|____ by David Meyer\n\
for Plan 9 ___//\"\"\"|:|88|:|\"\"\"\\\\___ <papa@sdf.org>\n\
_____//\":=_=_=_=|--|=_=_=_=:\"\\\\_____\n\
__/.-._//__|L_L_L_L|--|L_L_L_L|__\\\\_.-.\\__\n\
//\"||m|:.-. .-. .-.,.__.,.-. .-. .-.:|m||\"\\\\\n\
@ -172,8 +193,14 @@ main(void)
printgreeting();
printyearrept();
printstatus();
if(Year == MAXYEARS) completedterm();
else
{
setlandprice();
printlandprice();
}
}
}
} 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("You started with %d acres per person and ended with %d acres per person.\n", INITLAND / INITPOP, landperperson);
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)
{
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"));
}
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
@ -304,7 +331,7 @@ inputplant(void)
Boolean valid = FALSE;
grainbal = Grain - foodgrain + (landsale * landprice);
landbal = Land + landsale;
landbal = Land - landsale;
do
{
print("How many acres do you wish to plant? ");
@ -434,10 +461,10 @@ planyear(void)
foodgrain = landsale = plantland = 0;
break;
case EXEC:
print("So it shall be written, so it shall be done.\n");
break;
case CALC:
microcalc();
// microcalc();
break;
case QUIT:
play = FALSE;
@ -482,7 +509,8 @@ printyearrept(void)
harvyield, plantland * harvyield);
if(ratgrain > 0) print("Rats ate %d bushels of grain.\n", ratgrain);
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