End turn updates the state...
This commit is contained in:
parent
0d6e5b89d3
commit
6a19026c28
52
xerbia.c
52
xerbia.c
@ -5,6 +5,7 @@ enum { granary, mine, storehouse, quarry,
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
reply_quit, reply_help, reply_report, reply_status, reply_build, reply_train, reply_trade, reply_plant,
|
reply_quit, reply_help, reply_report, reply_status, reply_build, reply_train, reply_trade, reply_plant,
|
||||||
|
reply_turn,
|
||||||
replies
|
replies
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -20,7 +21,8 @@ static char * resource_name [] = { "wheat", "gold", "
|
|||||||
static char * construction_name [] = { "granary", "mine", "storehouse", "quarry" };
|
static char * construction_name [] = { "granary", "mine", "storehouse", "quarry" };
|
||||||
|
|
||||||
static char * reply_name [] = {
|
static char * reply_name [] = {
|
||||||
"quit", "help", "report", "status", "build", "train", "trade", "plant"
|
"quit", "help", "report", "status", "build", "train", "trade", "plant",
|
||||||
|
"turn"
|
||||||
};
|
};
|
||||||
|
|
||||||
static char * reply_text [] = {
|
static char * reply_text [] = {
|
||||||
@ -31,7 +33,8 @@ static char * reply_text [] = {
|
|||||||
"Propose what kind of construction should be built this month to your architect.",
|
"Propose what kind of construction should be built this month to your architect.",
|
||||||
"Spend more time training with your warriors this entire month.",
|
"Spend more time training with your warriors this entire month.",
|
||||||
"Discuss what goods should be sold or bought this month with merchant guild.",
|
"Discuss what goods should be sold or bought this month with merchant guild.",
|
||||||
"Order what kind of plants should your peasants harvest this month."
|
"Order what kind of plants should your peasants harvest this month.",
|
||||||
|
"Submit your monthly strategy to the council and wait until next month."
|
||||||
};
|
};
|
||||||
|
|
||||||
static int construction_price [constructions] [resources] = {
|
static int construction_price [constructions] [resources] = {
|
||||||
@ -65,7 +68,7 @@ static int query (char * names [], int count) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print ("Incorrect /1reply/-, type '/3help/-' to list replies or look at message above.\n");
|
print ("Incorrect /1reply/-, type '/4help/-' to list replies or look at message above.\n");
|
||||||
|
|
||||||
goto requery;
|
goto requery;
|
||||||
}
|
}
|
||||||
@ -74,7 +77,7 @@ static void print_help (void) {
|
|||||||
int index;
|
int index;
|
||||||
|
|
||||||
for (index = 0; index < replies; ++index) {
|
for (index = 0; index < replies; ++index) {
|
||||||
print ("/3%s/- /0<>/- %s\n", reply_name [index], reply_text [index]);
|
print ("/4%s/- /0<>/- %s\n", reply_name [index], reply_text [index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
separate ();
|
separate ();
|
||||||
@ -87,9 +90,9 @@ static void print_resources (void) {
|
|||||||
if (resource [index] == 0) {
|
if (resource [index] == 0) {
|
||||||
print ("You don't have any /1%s/-.\n", resource_name [index]);
|
print ("You don't have any /1%s/-.\n", resource_name [index]);
|
||||||
} else if (resource [index] == 1) {
|
} else if (resource [index] == 1) {
|
||||||
print ("You have /31/- unit of /3%s/-.\n", resource_name [index]);
|
print ("You have /41/- unit of /4%s/-.\n", resource_name [index]);
|
||||||
} else {
|
} else {
|
||||||
print ("You have /3%i/- units of type /3%s/-.\n", resource [index], resource_name [index]);
|
print ("You have /4%i/- units of type /4%s/-.\n", resource [index], resource_name [index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,9 +106,9 @@ static void print_constructions (void) {
|
|||||||
if (construction [index] == 0) {
|
if (construction [index] == 0) {
|
||||||
print ("You don't have any construction of type /1%s/-.\n", construction_name [index]);
|
print ("You don't have any construction of type /1%s/-.\n", construction_name [index]);
|
||||||
} else if (construction [index] == 1) {
|
} else if (construction [index] == 1) {
|
||||||
print ("You have /31/- construction of type /3%s/-.\n", construction_name [index]);
|
print ("You have /41/- construction of type /4%s/-.\n", construction_name [index]);
|
||||||
} else {
|
} else {
|
||||||
print ("You have /3%i/- constructions of type /3%s/-.\n", construction [index], construction_name [index]);
|
print ("You have /4%i/- constructions of type /4%s/-.\n", construction [index], construction_name [index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,12 +131,13 @@ static void build_construction (void) {
|
|||||||
for (index = 0; index < constructions; ++index) {
|
for (index = 0; index < constructions; ++index) {
|
||||||
int price;
|
int price;
|
||||||
|
|
||||||
print ("/0->/- build /3%s/- (", construction_name [index]);
|
print ("/0->/- build /4%s/- (", construction_name [index]);
|
||||||
|
|
||||||
for (price = 0; price < resources; ++price) {
|
for (price = 0; price < resources; ++price) {
|
||||||
if (construction_price [index] [price] > 0) {
|
if (construction_price [index] [price] > 0) {
|
||||||
|
print ("%s ", resource_name [price]);
|
||||||
print ((resource [price] < construction_price [index] [price]) ? "/1" : "/2");
|
print ((resource [price] < construction_price [index] [price]) ? "/1" : "/2");
|
||||||
print ("%s %i/-", resource_name [price], construction_price [index] [price]);
|
print ("%i/-", construction_price [index] [price]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((price > 0) && (price < resources - 1)) {
|
if ((price > 0) && (price < resources - 1)) {
|
||||||
@ -170,6 +174,25 @@ static void build_construction (void) {
|
|||||||
separate ();
|
separate ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void compute_turn (void) {
|
||||||
|
char * problem [] = { "rats", "thieves", "rotting", "cracking" };
|
||||||
|
|
||||||
|
int index;
|
||||||
|
|
||||||
|
for (index = 0; index < resources; ++index) {
|
||||||
|
int gained = construction [index] * 20;
|
||||||
|
int lost = random (1, 10);
|
||||||
|
|
||||||
|
resource [index] += gained - lost;
|
||||||
|
|
||||||
|
print ("Your fortress gained /2%i/- units of %s, but lost /1%i/- due to %s.\n", gained, resource_name [index], lost, problem [index]);
|
||||||
|
}
|
||||||
|
|
||||||
|
print ("Your strategy has been submitted to the council, now you can only wait...\n");
|
||||||
|
|
||||||
|
separate ();
|
||||||
|
}
|
||||||
|
|
||||||
int main (void) {
|
int main (void) {
|
||||||
int index;
|
int index;
|
||||||
int reply;
|
int reply;
|
||||||
@ -189,10 +212,10 @@ int main (void) {
|
|||||||
|
|
||||||
separate ();
|
separate ();
|
||||||
|
|
||||||
print ("-- Xerbia is clone of Sumerian game, made for fun in readable and formatted ANSI C.\n");
|
print ("/0-- Xerbia is clone of /7Sumerian Game/0, made for fun in readable and formatted ANSI C./-\n");
|
||||||
print ("-- Original game was designed by Mabel Addis and programmed by William McKay in 1964.\n");
|
print ("/0-- Original game was designed by /7Mabel Addis/0 and programmed by /7William McKay/0 in 1964./-\n");
|
||||||
print ("-- \n");
|
print ("/0-- /-\n");
|
||||||
print ("-- Ognjen 'xolatile' Milan Robovic\n");
|
print ("/0-- /4Ognjen 'xolatile' Milan Robovic/-\n");
|
||||||
|
|
||||||
for (reply = reply_help; reply != reply_quit; reply = query (reply_name, replies)) {
|
for (reply = reply_help; reply != reply_quit; reply = query (reply_name, replies)) {
|
||||||
separate ();
|
separate ();
|
||||||
@ -202,6 +225,7 @@ int main (void) {
|
|||||||
case reply_report: print_resources (); break;
|
case reply_report: print_resources (); break;
|
||||||
case reply_status: print_statistics (); break;
|
case reply_status: print_statistics (); break;
|
||||||
case reply_build: build_construction (); break;
|
case reply_build: build_construction (); break;
|
||||||
|
case reply_turn: compute_turn (); break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user