forked from github/server
fixed reversed logic for demon peasant hunger (bug 2187)
renamed config variable hunger.demons to hunger.demons.peasant_tolerance and reversed reversed logic in upkeep.c
This commit is contained in:
parent
aa3397a24f
commit
11b8d85167
|
@ -42,9 +42,9 @@
|
|||
"nmr.removenewbie": 0,
|
||||
"GiveRestriction": 3,
|
||||
"hunger.long": false,
|
||||
"hunger.demon.skill": true,
|
||||
"hunger.damage": "1d9+9",
|
||||
"hunger.demons": true,
|
||||
"hunger.demons.skill": true,
|
||||
"hunger.demons.peasant_tolerance": true,
|
||||
"init_spells": 0,
|
||||
"recruit.allow_merge": true,
|
||||
"study.expensivemigrants": true,
|
||||
|
|
|
@ -42,9 +42,9 @@
|
|||
"nmr.removenewbie": 0,
|
||||
"GiveRestriction": 3,
|
||||
"hunger.long": false,
|
||||
"hunger.demon.skill": true,
|
||||
"hunger.damage": "1d9+9",
|
||||
"hunger.demons": true,
|
||||
"hunger.demons.skill": true,
|
||||
"hunger.demons.peasant_tolerance"": true,
|
||||
"init_spells": 0,
|
||||
"recruit.allow_merge": true,
|
||||
"study.expensivemigrants": true,
|
||||
|
|
|
@ -965,3 +965,24 @@ function test_no_uruk()
|
|||
local f1 = faction.create("noreply@eressea.de", "uruk", "de")
|
||||
assert_equal(f1.race, "orc")
|
||||
end
|
||||
|
||||
function test_bug2187()
|
||||
set_rule("rules.food.flags", "0")
|
||||
|
||||
local r = region.create(0,0,"plain")
|
||||
local f = faction.create("2187@eressea.de", "goblin", "de")
|
||||
local u = unit.create(f, r, 1)
|
||||
u.race = "demon"
|
||||
u.hp = u.hp_max * u.number
|
||||
|
||||
r:set_resource("peasant", 0)
|
||||
u:add_item("money", 500)
|
||||
|
||||
hp = u.hp
|
||||
process_orders()
|
||||
assert_equal(hp, u.hp)
|
||||
-- init_reports()
|
||||
-- write_report(f)
|
||||
|
||||
set_rule("rules.food.flags", "4")
|
||||
end
|
|
@ -1299,6 +1299,44 @@ static void test_immigration(CuTest * tc)
|
|||
test_cleanup();
|
||||
}
|
||||
|
||||
static void test_demon_hunger(CuTest * tc)
|
||||
{
|
||||
const resource_type *rtype;
|
||||
region *r;
|
||||
race *rc;
|
||||
faction *f;
|
||||
unit *u;
|
||||
message* msg;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
r = findregion(0, 0);
|
||||
rc = test_create_race("demon");
|
||||
f = test_create_faction(rc);
|
||||
u = test_create_unit(f, r);
|
||||
u->hp = 999;
|
||||
|
||||
config_set("hunger.demons.peasant_tolerance", "1");
|
||||
|
||||
rtype = get_resourcetype(R_SILVER);
|
||||
i_change(&u->items, rtype->itype, 30);
|
||||
scale_number(u, 1);
|
||||
rsetpeasants(r, 0);
|
||||
|
||||
get_food(r);
|
||||
|
||||
CuAssertIntEquals(tc, 20, i_get(u->items, rtype->itype));
|
||||
CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "malnourish"));
|
||||
|
||||
config_set("hunger.demons.peasant_tolerance", "0");
|
||||
|
||||
get_food(r);
|
||||
|
||||
CuAssertIntEquals(tc, 10, i_get(u->items, rtype->itype));
|
||||
msg = test_get_last_message(u->faction->msgs);
|
||||
CuAssertStrEquals(tc, "malnourish", test_get_messagetype(msg));
|
||||
}
|
||||
|
||||
CuSuite *get_laws_suite(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
|
@ -1358,6 +1396,7 @@ CuSuite *get_laws_suite(void)
|
|||
SUITE_ADD_TEST(suite, test_name_ship);
|
||||
SUITE_ADD_TEST(suite, test_show_without_item);
|
||||
SUITE_ADD_TEST(suite, test_immigration);
|
||||
SUITE_ADD_TEST(suite, test_demon_hunger);
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -963,7 +963,7 @@ static void demon_skillchanges(void)
|
|||
|
||||
if (fval(u, UFL_HUNGER)) {
|
||||
/* hungry demons only go down, never up in skill */
|
||||
int rule_hunger = config_get_int("hunger.demon.skill", 0) != 0;
|
||||
int rule_hunger = config_get_int("hunger.demons.skill", 0) != 0;
|
||||
if (rule_hunger) {
|
||||
upchance = 0;
|
||||
downchance = 15;
|
||||
|
|
|
@ -271,7 +271,7 @@ void get_food(region * r)
|
|||
peasantfood = 0;
|
||||
}
|
||||
if (hungry > 0) {
|
||||
bool demon_hunger = config_get_int("hunger.demons", 0) != 0;
|
||||
bool demon_hunger = config_get_int("hunger.demons.peasant_tolerance", 0) == 0;
|
||||
if (demon_hunger) {
|
||||
/* demons who don't feed are hungry */
|
||||
if (hunger(hungry, u))
|
||||
|
|
Loading…
Reference in New Issue