Further updates, finished soon...
This commit is contained in:
parent
7cb380a4a8
commit
4c7f0ce66a
53
xerbia.c
53
xerbia.c
@ -3,8 +3,13 @@
|
||||
enum { wheat, gold, wood, stone, resources };
|
||||
enum { granary, mine, storehouse, quarry, constructions };
|
||||
|
||||
static int resource [resources] = { 600, 300, 300, 300 };
|
||||
static int construction [constructions] = { 1, 1, 1, 1 };
|
||||
static int population = 0;
|
||||
static int reputation = 0;
|
||||
static int monthly_immigration = 0;
|
||||
static int monthly_emigration = 0;
|
||||
|
||||
static int resource [resources] = { 0 };
|
||||
static int construction [constructions] = { 0 };
|
||||
|
||||
static char * resource_name [] = { "wheat", "gold", "wood", "stone" };
|
||||
static char * construction_name [] = { "granary", "mine", "storehouse", "quarry" };
|
||||
@ -16,6 +21,10 @@ static int construction_price [constructions] [resources] = {
|
||||
{ 0, 60, 30, 10 }
|
||||
};
|
||||
|
||||
static void separate (void) {
|
||||
print ("/0------------------------------------------------------------------------------------------/-\n");
|
||||
}
|
||||
|
||||
static void build_construction (int index) {
|
||||
int price;
|
||||
|
||||
@ -23,6 +32,7 @@ static void build_construction (int index) {
|
||||
if (resource [price] < construction_price [index] [price]) {
|
||||
print ("You don't have enough /1%s/-, need /1%i/- more.\n", resource_name [price], construction_price [index] [price] - resource [price]);
|
||||
print ("Your architect humbly refused to build /1%s/-.\n", construction_name [index]);
|
||||
separate ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -34,6 +44,8 @@ static void build_construction (int index) {
|
||||
construction [index] += 1;
|
||||
|
||||
print ("Construction of /2%s/- was completed successfully.\n", construction_name [index]);
|
||||
|
||||
separate ();
|
||||
}
|
||||
|
||||
static void print_resources (void) {
|
||||
@ -48,6 +60,8 @@ static void print_resources (void) {
|
||||
print ("You have /3%i/- units of type /3%s/-.\n", resource [index], resource_name [index]);
|
||||
}
|
||||
}
|
||||
|
||||
separate ();
|
||||
}
|
||||
|
||||
static void print_constructions (void) {
|
||||
@ -62,9 +76,37 @@ static void print_constructions (void) {
|
||||
print ("You have /3%i/- constructions of type /3%s/-.\n", construction [index], construction_name [index]);
|
||||
}
|
||||
}
|
||||
|
||||
separate ();
|
||||
}
|
||||
|
||||
static void print_statistics (void) {
|
||||
print ("Reputation = %i\n", reputation);
|
||||
print ("Monthly immigration = %i\n", monthly_immigration);
|
||||
print ("Monthly emigration = %i\n", monthly_emigration);
|
||||
print ("Population = %i\n", population);
|
||||
|
||||
separate ();
|
||||
}
|
||||
|
||||
int main (void) {
|
||||
int index;
|
||||
|
||||
reputation = random (0, 10);
|
||||
monthly_immigration = random (0, 10);
|
||||
monthly_emigration = random (0, 10);
|
||||
population = random (6, 12) * 20 + monthly_immigration - monthly_emigration;
|
||||
|
||||
for (index = 0; index < resources; ++index) {
|
||||
resource [index] = random (6, 12) * 20;
|
||||
}
|
||||
|
||||
for (index = 0; index < constructions; ++index) {
|
||||
construction [index] = random (1, 2);
|
||||
}
|
||||
|
||||
separate ();
|
||||
|
||||
print_resources ();
|
||||
print_constructions ();
|
||||
|
||||
@ -73,8 +115,11 @@ int main (void) {
|
||||
build_construction (storehouse);
|
||||
build_construction (quarry);
|
||||
|
||||
print_resources ();
|
||||
print_constructions ();
|
||||
print_statistics ();
|
||||
|
||||
print ("The end!\n");
|
||||
|
||||
separate ();
|
||||
|
||||
return (log_success);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user