xerbia/xerbia.c

90 lines
2.6 KiB
C
Raw Normal View History

2024-06-16 05:41:47 -04:00
#include <xolatile/xtandard.c>
2024-06-16 06:02:32 -04:00
static int wheat = 600,
gold = 600,
wood = 600,
stone = 600;
2024-06-16 05:41:47 -04:00
2024-06-16 06:02:32 -04:00
static int granaries = 1,
mines = 1,
storehouses = 1,
quarries = 1;
2024-06-16 05:41:47 -04:00
2024-06-16 06:02:32 -04:00
static int check_resource (int have, int need, char * name) {
2024-06-16 05:41:47 -04:00
if (have < need) {
2024-06-16 06:02:32 -04:00
print ("You have only /3%i %s/- and you need /3%i/-, meaning that you miss /1%i/- more.\n", have, name, need, need - have);
return (true);
2024-06-16 05:41:47 -04:00
}
2024-06-16 06:02:32 -04:00
return (false);
2024-06-16 05:41:47 -04:00
}
static void build_granary (void) {
2024-06-16 06:02:32 -04:00
if (check_resource (gold, 10, "gold") || check_resource (wood, 60, "wood") || check_resource (stone, 30, "stone")) {
print ("Your architects humbly refused to build the /1granary/-, complaining about lacking the resources for that.\n");
} else {
gold -= 10;
wood -= 60;
stone -= 30;
2024-06-16 05:41:47 -04:00
2024-06-16 06:02:32 -04:00
print ("/2Granary/- that you ordered to be built was finished without issues, now you have /2%i/- granaries.\n", ++granaries);
2024-06-16 05:41:47 -04:00
}
}
static void build_mine (void) {
2024-06-16 06:02:32 -04:00
if (check_resource (gold, 120, "gold") || check_resource (wood, 60, "wood") || check_resource (stone, 30, "stone")) {
print ("Your architects humbly refused to build the /1mine/-, complaining about lacking the resources for that.\n");
} else {
gold -= 120;
wood -= 60;
stone -= 30;
2024-06-16 05:41:47 -04:00
2024-06-16 06:02:32 -04:00
print ("/2Mine/- that you ordered to be built was finished without issues, now you have /2%i/- mines.\n", ++mines);
2024-06-16 05:41:47 -04:00
}
}
static void build_storehouse (void) {
2024-06-16 06:02:32 -04:00
if (check_resource (gold, 30, "gold") || check_resource (wood, 10, "wood") || check_resource (stone, 60, "stone")) {
print ("Your architects humbly refused to build the /1storehouse/-, complaining about lacking the resources for that.\n");
} else {
gold -= 30;
wood -= 10;
stone -= 60;
2024-06-16 05:41:47 -04:00
2024-06-16 06:02:32 -04:00
print ("/2Storehouse/- that you ordered to be built was finished without issues, now you have /2%i/- storehouses.\n", ++storehouses);
2024-06-16 05:41:47 -04:00
}
}
static void build_quarry (void) {
2024-06-16 06:02:32 -04:00
if (check_resource (gold, 60, "gold") || check_resource (wood, 30, "wood") || check_resource (stone, 10, "stone")) {
print ("Your architects humbly refused to build the /1quarry/-, complaining about lacking the resources for that.\n");
} else {
gold -= 60;
wood -= 30;
stone -= 10;
2024-06-16 05:41:47 -04:00
2024-06-16 06:02:32 -04:00
print ("/2Quarry/- that you ordered to be built was finished without issues, now you have /2%i/- quarries.\n", ++quarries);
2024-06-16 05:41:47 -04:00
}
}
2024-06-16 06:02:32 -04:00
static void print_resources (void) {
print ("Wheat = %i\n", wheat);
print ("Gold = %i\n", gold);
print ("Wood = %i\n", wood);
print ("Stone = %i\n", stone);
}
2024-06-16 05:41:47 -04:00
int main (void) {
2024-06-16 06:02:32 -04:00
print_resources ();
build_granary ();
build_mine ();
2024-06-16 05:41:47 -04:00
build_storehouse ();
2024-06-16 06:02:32 -04:00
build_quarry ();
print_resources ();
2024-06-16 05:41:47 -04:00
return (log_success);
}