forked from github/server
calculating income for dragons is no longer hard-coded
This commit is contained in:
parent
26a416c5ba
commit
d3efc265c3
11 changed files with 37 additions and 17 deletions
|
@ -1,7 +1,8 @@
|
||||||
<race name="dragon" magres="0.700000" maxaura="1.0" regaura="2.000000" weight="10000" capacity="1000000" speed="1.500000" hp="900" ac=
|
<race name="dragon" magres="0.700000" maxaura="1.0" regaura="2.000000" weight="10000" capacity="1000000" speed="1.500000" hp="900" ac=
|
||||||
"6" damage="2d30" unarmedattack="0" unarmeddefense="0"
|
"6" damage="2d30" unarmedattack="0" unarmeddefense="0"
|
||||||
attackmodifier="7" defensemodifier="7" scarepeasants="yes" fly="yes"
|
attackmodifier="7" defensemodifier="7" scarepeasants="yes" fly="yes"
|
||||||
walk="yes" teach="no" getitem="yes" resistbash="yes" dragon="yes">
|
income="1000" walk="yes" teach="no" getitem="yes" resistbash="yes"
|
||||||
|
dragon="yes">
|
||||||
<ai splitsize="2" killpeasants="yes" learn="yes" scare="400"/>
|
<ai splitsize="2" killpeasants="yes" learn="yes" scare="400"/>
|
||||||
<function name="name" value="namedragon"/>
|
<function name="name" value="namedragon"/>
|
||||||
<function name="age" value="agedragon"/>
|
<function name="age" value="agedragon"/>
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
<race name="wyrm" magres="0.900000" maxaura="1.0" regaura="3.000000" weight="18000" capacity="1000000" speed="1.0" hp="2700" ac="8" damage="2d60" unarmedattack="0" unarmeddefense="0" attackmodifier="10" defensemodifier="10" scarepeasants="yes" fly="yes" walk="yes" teach="no" getitem="yes" resistbash="yes" dragon="yes">
|
<race name="wyrm" magres="0.900000" maxaura="1.0" regaura="3.000000"
|
||||||
|
weight="18000" capacity="1000000" speed="1.0" hp="2700" ac="8"
|
||||||
|
damage="2d60" unarmedattack="0" unarmeddefense="0" attackmodifier="10"
|
||||||
|
defensemodifier="10" scarepeasants="yes" fly="yes" walk="yes"
|
||||||
|
teach="no" getitem="yes" resistbash="yes" dragon="yes" income="5000">
|
||||||
<ai splitsize="1" killpeasants="yes" learn="yes" scare="1000"/>
|
<ai splitsize="1" killpeasants="yes" learn="yes" scare="1000"/>
|
||||||
<function name="name" value="namedragon"/>
|
<function name="name" value="namedragon"/>
|
||||||
<function name="move" value="movedragon"/>
|
<function name="move" value="movedragon"/>
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
<race name="youngdragon" magres="0.500000" maxaura="1.0" regaura="1.0" weight="8000" capacity="10000" speed="1.0" hp="300" ac="4" damage="2d15" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="4" scarepeasants="yes" fly="yes" walk="yes" teach="no" getitem="yes" resistbash="yes" dragon="yes">
|
<race name="youngdragon" magres="0.500000" maxaura="1.0" regaura="1.0"
|
||||||
|
weight="8000" capacity="10000" speed="1.0" hp="300" ac="4"
|
||||||
|
damage="2d15" unarmedattack="0" unarmeddefense="0" attackmodifier="4"
|
||||||
|
defensemodifier="4" scarepeasants="yes" fly="yes" walk="yes"
|
||||||
|
teach="no" getitem="yes" resistbash="yes" dragon="yes" income="150">
|
||||||
<ai splitsize="6" killpeasants="yes" learn="yes" scare="160"/>
|
<ai splitsize="6" killpeasants="yes" learn="yes" scare="160"/>
|
||||||
<function name="name" value="namedragon"/>
|
<function name="name" value="namedragon"/>
|
||||||
<function name="age" value="agefiredragon"/>
|
<function name="age" value="agefiredragon"/>
|
||||||
|
|
|
@ -114,20 +114,8 @@ static void recruit_init(void)
|
||||||
|
|
||||||
int income(const unit * u)
|
int income(const unit * u)
|
||||||
{
|
{
|
||||||
// TODO: make this a property, like race.income, no hard-coding of values
|
const race *rc = u_race(u);
|
||||||
if (fval(u_race(u), RCF_DRAGON)) {
|
return rc->income * u->number;
|
||||||
switch (old_race(u_race(u))) {
|
|
||||||
case RC_FIREDRAGON:
|
|
||||||
return 150 * u->number;
|
|
||||||
case RC_DRAGON:
|
|
||||||
return 1000 * u->number;
|
|
||||||
case RC_WYRM:
|
|
||||||
return 5000 * u->number;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 20 * u->number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void scramble(void *data, unsigned int n, size_t width)
|
static void scramble(void *data, unsigned int n, size_t width)
|
||||||
|
|
|
@ -328,11 +328,25 @@ static void test_recruit(CuTest *tc) {
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_income(CuTest *tc)
|
||||||
|
{
|
||||||
|
race *rc;
|
||||||
|
unit *u;
|
||||||
|
test_setup();
|
||||||
|
rc = test_create_race("nerd");
|
||||||
|
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0));
|
||||||
|
CuAssertIntEquals(tc, 20, income(u));
|
||||||
|
u->number = 5;
|
||||||
|
CuAssertIntEquals(tc, 100, income(u));
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
CuSuite *get_economy_suite(void)
|
CuSuite *get_economy_suite(void)
|
||||||
{
|
{
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
SUITE_ADD_TEST(suite, test_give_control_building);
|
SUITE_ADD_TEST(suite, test_give_control_building);
|
||||||
SUITE_ADD_TEST(suite, test_give_control_ship);
|
SUITE_ADD_TEST(suite, test_give_control_ship);
|
||||||
|
SUITE_ADD_TEST(suite, test_income);
|
||||||
SUITE_ADD_TEST(suite, test_steal_okay);
|
SUITE_ADD_TEST(suite, test_steal_okay);
|
||||||
SUITE_ADD_TEST(suite, test_steal_ocean);
|
SUITE_ADD_TEST(suite, test_steal_ocean);
|
||||||
SUITE_ADD_TEST(suite, test_steal_nosteal);
|
SUITE_ADD_TEST(suite, test_steal_nosteal);
|
||||||
|
|
|
@ -481,6 +481,9 @@ static void json_race(cJSON *json, race *rc) {
|
||||||
else if (strcmp(child->string, "capacity") == 0) {
|
else if (strcmp(child->string, "capacity") == 0) {
|
||||||
rc->capacity = child->valueint;
|
rc->capacity = child->valueint;
|
||||||
}
|
}
|
||||||
|
else if (strcmp(child->string, "income") == 0) {
|
||||||
|
rc->income = child->valueint;
|
||||||
|
}
|
||||||
else if (strcmp(child->string, "hp") == 0) {
|
else if (strcmp(child->string, "hp") == 0) {
|
||||||
rc->hitpoints = child->valueint;
|
rc->hitpoints = child->valueint;
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,6 +141,7 @@ static void test_races(CuTest * tc)
|
||||||
"\"maintenance\" : 2,"
|
"\"maintenance\" : 2,"
|
||||||
"\"weight\" : 3,"
|
"\"weight\" : 3,"
|
||||||
"\"capacity\" : 4,"
|
"\"capacity\" : 4,"
|
||||||
|
"\"income\" : 30,"
|
||||||
"\"hp\" : 5,"
|
"\"hp\" : 5,"
|
||||||
"\"ac\" : 6,"
|
"\"ac\" : 6,"
|
||||||
"\"flags\" : [ \"npc\", \"walk\", \"undead\" ]"
|
"\"flags\" : [ \"npc\", \"walk\", \"undead\" ]"
|
||||||
|
@ -167,6 +168,7 @@ static void test_races(CuTest * tc)
|
||||||
CuAssertIntEquals(tc, 2, rc->maintenance);
|
CuAssertIntEquals(tc, 2, rc->maintenance);
|
||||||
CuAssertIntEquals(tc, 3, rc->weight);
|
CuAssertIntEquals(tc, 3, rc->weight);
|
||||||
CuAssertIntEquals(tc, 4, rc->capacity);
|
CuAssertIntEquals(tc, 4, rc->capacity);
|
||||||
|
CuAssertIntEquals(tc, 30, rc->income);
|
||||||
CuAssertIntEquals(tc, 5, rc->hitpoints);
|
CuAssertIntEquals(tc, 5, rc->hitpoints);
|
||||||
CuAssertIntEquals(tc, 6, rc->armor);
|
CuAssertIntEquals(tc, 6, rc->armor);
|
||||||
cJSON_Delete(json);
|
cJSON_Delete(json);
|
||||||
|
|
|
@ -173,6 +173,7 @@ race *rc_create(const char *zName)
|
||||||
rc->hitpoints = 1;
|
rc->hitpoints = 1;
|
||||||
rc->weight = PERSON_WEIGHT;
|
rc->weight = PERSON_WEIGHT;
|
||||||
rc->capacity = 540;
|
rc->capacity = 540;
|
||||||
|
rc->income = 20;
|
||||||
rc->recruit_multi = 1.0F;
|
rc->recruit_multi = 1.0F;
|
||||||
rc->regaura = 1.0F;
|
rc->regaura = 1.0F;
|
||||||
rc->speed = 1.0F;
|
rc->speed = 1.0F;
|
||||||
|
|
|
@ -124,6 +124,7 @@ extern "C" {
|
||||||
int splitsize;
|
int splitsize;
|
||||||
int weight;
|
int weight;
|
||||||
int capacity;
|
int capacity;
|
||||||
|
int income;
|
||||||
float speed;
|
float speed;
|
||||||
float aggression; /* chance that a monster will attack */
|
float aggression; /* chance that a monster will attack */
|
||||||
int hitpoints;
|
int hitpoints;
|
||||||
|
|
|
@ -32,6 +32,7 @@ static void test_rc_defaults(CuTest *tc) {
|
||||||
CuAssertIntEquals(tc, 0, rc->recruitcost);
|
CuAssertIntEquals(tc, 0, rc->recruitcost);
|
||||||
CuAssertIntEquals(tc, 0, rc->maintenance);
|
CuAssertIntEquals(tc, 0, rc->maintenance);
|
||||||
CuAssertIntEquals(tc, 540, rc->capacity);
|
CuAssertIntEquals(tc, 540, rc->capacity);
|
||||||
|
CuAssertIntEquals(tc, 20, rc->income);
|
||||||
CuAssertIntEquals(tc, 1, rc->hitpoints);
|
CuAssertIntEquals(tc, 1, rc->hitpoints);
|
||||||
CuAssertIntEquals(tc, 0, rc->armor);
|
CuAssertIntEquals(tc, 0, rc->armor);
|
||||||
CuAssertIntEquals(tc, 0, rc->at_bonus);
|
CuAssertIntEquals(tc, 0, rc->at_bonus);
|
||||||
|
|
|
@ -1656,6 +1656,7 @@ static int parse_races(xmlDocPtr doc)
|
||||||
rc->maintenance = xml_ivalue(node, "maintenance", rc->maintenance);
|
rc->maintenance = xml_ivalue(node, "maintenance", rc->maintenance);
|
||||||
rc->weight = xml_ivalue(node, "weight", rc->weight);
|
rc->weight = xml_ivalue(node, "weight", rc->weight);
|
||||||
rc->capacity = xml_ivalue(node, "capacity", rc->capacity);
|
rc->capacity = xml_ivalue(node, "capacity", rc->capacity);
|
||||||
|
rc->income = xml_ivalue(node, "income", rc->income);
|
||||||
rc->speed = (float)xml_fvalue(node, "speed", rc->speed);
|
rc->speed = (float)xml_fvalue(node, "speed", rc->speed);
|
||||||
rc->hitpoints = xml_ivalue(node, "hp", rc->hitpoints);
|
rc->hitpoints = xml_ivalue(node, "hp", rc->hitpoints);
|
||||||
rc->armor = (char)xml_ivalue(node, "ac", rc->armor);
|
rc->armor = (char)xml_ivalue(node, "ac", rc->armor);
|
||||||
|
|
Loading…
Reference in a new issue