forked from github/server
commit
0c90d50d83
|
@ -48,8 +48,7 @@
|
||||||
"healing.forest": 2.0,
|
"healing.forest": 2.0,
|
||||||
"hunger.long": false,
|
"hunger.long": false,
|
||||||
"hunger.damage": "1d9+9",
|
"hunger.damage": "1d9+9",
|
||||||
"hunger.demons.skill": true,
|
"hunger.demon.peasant_tolerance": true,
|
||||||
"hunger.demons.peasant_tolerance": true,
|
|
||||||
"init_spells": 0,
|
"init_spells": 0,
|
||||||
"recruit.allow_merge": true,
|
"recruit.allow_merge": true,
|
||||||
"study.expensivemigrants": true,
|
"study.expensivemigrants": true,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<resource name="firesword">
|
<resource name="firesword">
|
||||||
<item weight="100">
|
<item weight="100">
|
||||||
<weapon minskill="7" magres="0.3" cut="true" skill="melee" offmod="1" defmod="1">
|
<weapon magres="0.3" cut="true" skill="melee" offmod="1" defmod="1">
|
||||||
<function name="attack" value="attack_firesword"/>
|
<function name="attack" value="attack_firesword"/>
|
||||||
<damage type="rider" value="3d6+10"/>
|
<damage type="rider" value="3d6+10"/>
|
||||||
<damage type="footman" value="3d6+10"/>
|
<damage type="footman" value="3d6+10"/>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<construction skill="weaponsmithing" minskill="5">
|
<construction skill="weaponsmithing" minskill="5">
|
||||||
<requirement type="mallorn" quantity="2"/>
|
<requirement type="mallorn" quantity="2"/>
|
||||||
</construction>
|
</construction>
|
||||||
<weapon pierce="true" skill="polearm" minskill="5" offmod="0" defmod="0" magres="0.15">
|
<weapon pierce="true" skill="polearm" offmod="0" defmod="0" magres="0.15">
|
||||||
<damage type="footman" value="1d5+1"/>
|
<damage type="footman" value="1d5+1"/>
|
||||||
<damage type="rider" value="2d6+6"/>
|
<damage type="rider" value="2d6+6"/>
|
||||||
</weapon>
|
</weapon>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<construction skill="weaponsmithing" minskill="5">
|
<construction skill="weaponsmithing" minskill="5">
|
||||||
<requirement type="mallorn" quantity="1"/>
|
<requirement type="mallorn" quantity="1"/>
|
||||||
</construction>
|
</construction>
|
||||||
<weapon pierce="true" skill="polearm" minskill="5" offmod="0" defmod="0" magres="0.15">
|
<weapon pierce="true" skill="polearm" offmod="0" defmod="0" magres="0.15">
|
||||||
<damage type="footman" value="1d10+1"/>
|
<damage type="footman" value="1d10+1"/>
|
||||||
<damage type="rider" value="1d12+3"/>
|
<damage type="rider" value="1d12+3"/>
|
||||||
<modifier type="skill" value="1" riding="true" against_riding="true" against_walking="true" offensive="true"/>
|
<modifier type="skill" value="1" riding="true" against_riding="true" against_walking="true" offensive="true"/>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<resource name="runesword">
|
<resource name="runesword">
|
||||||
<item weight="100" score="2000">
|
<item weight="100" score="2000">
|
||||||
<weapon minskill="7" cut="true" magical="yes" skill="melee" offmod="2" defmod="2">
|
<weapon cut="true" magical="yes" skill="melee" offmod="2" defmod="2">
|
||||||
<function name="attack" value="attack_firesword"/>
|
<function name="attack" value="attack_firesword"/>
|
||||||
<damage type="rider" value="3d10+10"/>
|
<damage type="rider" value="3d10+10"/>
|
||||||
<damage type="footman" value="3d10+10"/>
|
<damage type="footman" value="3d10+10"/>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<construction skill="weaponsmithing" minskill="5">
|
<construction skill="weaponsmithing" minskill="5">
|
||||||
<requirement type="mallorn" quantity="2"/>
|
<requirement type="mallorn" quantity="2"/>
|
||||||
</construction>
|
</construction>
|
||||||
<weapon pierce="true" skill="polearm" minskill="5" offmod="0" defmod="0" magres="0.15">
|
<weapon pierce="true" skill="polearm" offmod="0" defmod="0" magres="0.15">
|
||||||
<damage type="footman" value="1d5+2"/>
|
<damage type="footman" value="1d5+2"/>
|
||||||
<damage type="rider" value="2d6+7"/>
|
<damage type="rider" value="2d6+7"/>
|
||||||
</weapon>
|
</weapon>
|
||||||
|
|
|
@ -34,7 +34,7 @@ function test_sail_into_glacier()
|
||||||
u1:add_order("NACH OST")
|
u1:add_order("NACH OST")
|
||||||
u2.ship = u1.ship
|
u2.ship = u1.ship
|
||||||
process_orders()
|
process_orders()
|
||||||
assert_equal(r, u2.region)
|
assert_equal(r2, u2.region)
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_recruit_in_winter()
|
function test_recruit_in_winter()
|
||||||
|
@ -71,13 +71,3 @@ function test_recruit_in_desert()
|
||||||
assert_equal('winter', get_season(get_turn()))
|
assert_equal('winter', get_season(get_turn()))
|
||||||
assert_equal(2, u.number)
|
assert_equal(2, u.number)
|
||||||
end
|
end
|
||||||
|
|
||||||
function bug_1841_test_hunger_in_glacier()
|
|
||||||
local r = region.create(0, 0, "glacier")
|
|
||||||
local f = faction.create("insect", "insect@eressea.de", "de")
|
|
||||||
local u = unit.create(f, r, 1)
|
|
||||||
|
|
||||||
local flags = u.flags
|
|
||||||
process_orders()
|
|
||||||
assert_equal(flags+2048, u.flags)
|
|
||||||
end
|
|
||||||
|
|
|
@ -1015,7 +1015,7 @@ function test_demons_using_mallornlance()
|
||||||
local f = faction.create('goblin')
|
local f = faction.create('goblin')
|
||||||
local u = unit.create(f, r, 1, 'demon')
|
local u = unit.create(f, r, 1, 'demon')
|
||||||
u:set_skill('taxation', 1)
|
u:set_skill('taxation', 1)
|
||||||
u:set_skill('polearm', 4) -- demon has +1
|
u:set_skill('polearm', 1)
|
||||||
u:add_item('mallornlance', 1)
|
u:add_item('mallornlance', 1)
|
||||||
u:add_order('BEWACHE')
|
u:add_order('BEWACHE')
|
||||||
process_orders()
|
process_orders()
|
||||||
|
|
|
@ -0,0 +1,108 @@
|
||||||
|
require "lunit"
|
||||||
|
|
||||||
|
module("tests.hunger", package.seeall, lunit.testcase)
|
||||||
|
|
||||||
|
function setup()
|
||||||
|
eressea.free_game()
|
||||||
|
conf = [[{
|
||||||
|
"races": {
|
||||||
|
"demon": {
|
||||||
|
"maintenance": 10,
|
||||||
|
"hp" : 50
|
||||||
|
},
|
||||||
|
"insect": {
|
||||||
|
"maintenance": 10,
|
||||||
|
"hp" : 50
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"terrains" : {
|
||||||
|
"plain": { "flags" : [ "land", "walk" ] },
|
||||||
|
"glacier": { "flags" : [ "arctic", "land", "walk" ] }
|
||||||
|
}
|
||||||
|
}]]
|
||||||
|
|
||||||
|
eressea.config.reset()
|
||||||
|
eressea.config.parse(conf)
|
||||||
|
|
||||||
|
eressea.settings.set("rules.peasants.growth.factor", "0")
|
||||||
|
eressea.settings.set("rules.peasantluck.growth.factor", "0")
|
||||||
|
eressea.settings.set("hunger.damage", "10")
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_maintenance()
|
||||||
|
local r = region.create(0, 0, "plain")
|
||||||
|
local f = faction.create("insect")
|
||||||
|
local u = unit.create(f, r, 2)
|
||||||
|
local flags = u.flags
|
||||||
|
u:add_item('money', 100)
|
||||||
|
|
||||||
|
process_orders()
|
||||||
|
assert_equal(flags, u.flags, "should not be hungry")
|
||||||
|
assert_equal(80, u:get_item('money'), "should pay maintenance")
|
||||||
|
assert_equal(100, u.hp, "should not take damage")
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_demons_eat_peasants()
|
||||||
|
local r = region.create(0, 0, "plain")
|
||||||
|
local f = faction.create("demon")
|
||||||
|
local u = unit.create(f, r, 10)
|
||||||
|
local flags = u.flags
|
||||||
|
u:add_item('money', 120)
|
||||||
|
|
||||||
|
r.peasants = 3
|
||||||
|
process_orders()
|
||||||
|
assert_equal(20, u:get_item('money'))
|
||||||
|
assert_equal(2, r.peasants)
|
||||||
|
assert_equal(flags, u.flags)
|
||||||
|
assert_equal(500, u.hp)
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_demons_need_peasants()
|
||||||
|
local r = region.create(0, 0, "plain")
|
||||||
|
local f = faction.create("demon")
|
||||||
|
local u = unit.create(f, r, 1)
|
||||||
|
local flags = u.flags
|
||||||
|
u:add_item('money', 100)
|
||||||
|
|
||||||
|
eressea.settings.set("hunger.demon.peasant_tolerance", "0")
|
||||||
|
r.peasants = 0
|
||||||
|
process_orders()
|
||||||
|
assert_equal(90, u:get_item('money')) -- use money even if no peasants
|
||||||
|
assert_equal(flags+2048, u.flags)
|
||||||
|
assert_equal(40, u.hp)
|
||||||
|
|
||||||
|
eressea.settings.set("hunger.demon.peasant_tolerance", "1")
|
||||||
|
u.flags = flags
|
||||||
|
u.hp = 50
|
||||||
|
process_orders()
|
||||||
|
assert_equal(80, u:get_item('money')) -- use money even if no peasants
|
||||||
|
assert_equal(flags+2048, u.flags)
|
||||||
|
assert_equal(50, u.hp)
|
||||||
|
assert_equal(0, r.peasants)
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_insects_hunger_in_glacier()
|
||||||
|
-- bug 2389
|
||||||
|
local r = region.create(0, 0, "plain")
|
||||||
|
local f = faction.create("insect")
|
||||||
|
local u = unit.create(f, r, 1)
|
||||||
|
local flags = u.flags
|
||||||
|
u:add_item('money', 1000)
|
||||||
|
|
||||||
|
-- eressea.settings.set("hunger.insect.cold", "1") -- default
|
||||||
|
process_orders()
|
||||||
|
assert_equal(flags, u.flags)
|
||||||
|
assert_equal(50, u.hp)
|
||||||
|
|
||||||
|
r.terrain = 'glacier'
|
||||||
|
process_orders()
|
||||||
|
assert_equal(flags+2048, u.flags)
|
||||||
|
assert_equal(40, u.hp)
|
||||||
|
|
||||||
|
u.flags = u.flags-2048
|
||||||
|
u.hp = 50
|
||||||
|
eressea.settings.set("hunger.insect.cold", "0")
|
||||||
|
process_orders()
|
||||||
|
assert_equal(flags, u.flags)
|
||||||
|
assert_equal(50, u.hp)
|
||||||
|
end
|
|
@ -9,3 +9,4 @@ require 'tests.settings'
|
||||||
require 'tests.study'
|
require 'tests.study'
|
||||||
require 'tests.laws'
|
require 'tests.laws'
|
||||||
require 'tests.bindings'
|
require 'tests.bindings'
|
||||||
|
require 'tests.hunger'
|
||||||
|
|
|
@ -640,8 +640,6 @@ weapon_skill(const weapon_type * wtype, const unit * u, bool attacking)
|
||||||
if (!i_canuse(u, wtype->itype))
|
if (!i_canuse(u, wtype->itype))
|
||||||
return -1;
|
return -1;
|
||||||
skill = effskill(u, wtype->skill, 0);
|
skill = effskill(u, wtype->skill, 0);
|
||||||
if (skill < wtype->minskill)
|
|
||||||
skill = 0;
|
|
||||||
if (skill > 0) {
|
if (skill > 0) {
|
||||||
if (attacking) {
|
if (attacking) {
|
||||||
skill += u_race(u)->at_bonus;
|
skill += u_race(u)->at_bonus;
|
||||||
|
|
|
@ -268,7 +268,7 @@ static void test_calculate_armor(CuTest * tc)
|
||||||
ashield = new_armortype(ishield, 0.0, v50p, 1, ATF_SHIELD);
|
ashield = new_armortype(ishield, 0.0, v50p, 1, ATF_SHIELD);
|
||||||
ichain = it_get_or_create(rt_get_or_create("chainmail"));
|
ichain = it_get_or_create(rt_get_or_create("chainmail"));
|
||||||
achain = new_armortype(ichain, 0.0, v50p, 3, ATF_NONE);
|
achain = new_armortype(ichain, 0.0, v50p, 3, ATF_NONE);
|
||||||
wtype = new_weapontype(it_get_or_create(rt_get_or_create("sword")), 0, v50p, 0, 0, 0, 0, SK_MELEE, 1);
|
wtype = new_weapontype(it_get_or_create(rt_get_or_create("sword")), 0, v50p, 0, 0, 0, 0, SK_MELEE);
|
||||||
rc = test_create_race("human");
|
rc = test_create_race("human");
|
||||||
du = test_create_unit(test_create_faction(rc), r);
|
du = test_create_unit(test_create_faction(rc), r);
|
||||||
dt.index = 0;
|
dt.index = 0;
|
||||||
|
@ -409,7 +409,7 @@ static void test_projectile_armor(CuTest * tc)
|
||||||
ashield = new_armortype(ishield, 0.0, v50p, 1, ATF_SHIELD);
|
ashield = new_armortype(ishield, 0.0, v50p, 1, ATF_SHIELD);
|
||||||
ichain = it_get_or_create(rt_get_or_create("chainmail"));
|
ichain = it_get_or_create(rt_get_or_create("chainmail"));
|
||||||
achain = new_armortype(ichain, 0.0, v50p, 3, ATF_NONE);
|
achain = new_armortype(ichain, 0.0, v50p, 3, ATF_NONE);
|
||||||
wtype = new_weapontype(it_get_or_create(rt_get_or_create("sword")), 0, v50p, 0, 0, 0, 0, SK_MELEE, 1);
|
wtype = new_weapontype(it_get_or_create(rt_get_or_create("sword")), 0, v50p, 0, 0, 0, 0, SK_MELEE);
|
||||||
rc = test_create_race("human");
|
rc = test_create_race("human");
|
||||||
rc->battle_flags |= BF_EQUIPMENT;
|
rc->battle_flags |= BF_EQUIPMENT;
|
||||||
du = test_create_unit(test_create_faction(rc), r);
|
du = test_create_unit(test_create_faction(rc), r);
|
||||||
|
|
|
@ -536,6 +536,27 @@ static int tolua_region_get_age(lua_State * L)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int tolua_region_get_peasants(lua_State * L)
|
||||||
|
{
|
||||||
|
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||||
|
|
||||||
|
if (self) {
|
||||||
|
lua_pushinteger(L, self->land ? self->land->peasants : 0);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int tolua_region_set_peasants(lua_State * L)
|
||||||
|
{
|
||||||
|
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||||
|
|
||||||
|
if (self && self->land) {
|
||||||
|
self->land->peasants = lua_tointeger(L, 2);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int tolua_region_getkey(lua_State * L)
|
static int tolua_region_getkey(lua_State * L)
|
||||||
{
|
{
|
||||||
region *self = (region *)tolua_tousertype(L, 1, 0);
|
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||||
|
@ -734,6 +755,8 @@ void tolua_region_open(lua_State * L)
|
||||||
tolua_variable(L, TOLUA_CAST "age", tolua_region_get_age, NULL);
|
tolua_variable(L, TOLUA_CAST "age", tolua_region_get_age, NULL);
|
||||||
tolua_variable(L, TOLUA_CAST "buildings", tolua_region_get_buildings,
|
tolua_variable(L, TOLUA_CAST "buildings", tolua_region_get_buildings,
|
||||||
NULL);
|
NULL);
|
||||||
|
tolua_variable(L, TOLUA_CAST "peasants", tolua_region_get_peasants,
|
||||||
|
tolua_region_set_peasants);
|
||||||
tolua_variable(L, TOLUA_CAST "terrain", tolua_region_get_terrain,
|
tolua_variable(L, TOLUA_CAST "terrain", tolua_region_get_terrain,
|
||||||
tolua_region_set_terrain);
|
tolua_region_set_terrain);
|
||||||
tolua_function(L, TOLUA_CAST "get_resourcelevel",
|
tolua_function(L, TOLUA_CAST "get_resourcelevel",
|
||||||
|
|
|
@ -326,7 +326,7 @@ static void test_tax_cmd(CuTest *tc) {
|
||||||
silver = get_resourcetype(R_SILVER)->itype;
|
silver = get_resourcetype(R_SILVER)->itype;
|
||||||
|
|
||||||
sword = test_create_itemtype("sword");
|
sword = test_create_itemtype("sword");
|
||||||
new_weapontype(sword, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE, 1);
|
new_weapontype(sword, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE);
|
||||||
i_change(&u->items, sword, 1);
|
i_change(&u->items, sword, 1);
|
||||||
set_level(u, SK_MELEE, 1);
|
set_level(u, SK_MELEE, 1);
|
||||||
|
|
||||||
|
|
|
@ -44,14 +44,19 @@ static void test_guard_unskilled(CuTest * tc)
|
||||||
|
|
||||||
test_setup();
|
test_setup();
|
||||||
itype = it_get_or_create(rt_get_or_create("sword"));
|
itype = it_get_or_create(rt_get_or_create("sword"));
|
||||||
new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE, 2);
|
new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE);
|
||||||
r = test_create_region(0, 0, 0);
|
r = test_create_region(0, 0, 0);
|
||||||
u = test_create_unit(test_create_faction(0), r);
|
u = test_create_unit(test_create_faction(0), r);
|
||||||
ug = test_create_unit(test_create_faction(0), r);
|
ug = test_create_unit(test_create_faction(0), r);
|
||||||
i_change(&ug->items, itype, 1);
|
i_change(&ug->items, itype, 1);
|
||||||
|
|
||||||
|
setguard(ug, true);
|
||||||
|
CuAssertPtrEquals(tc, NULL, is_guarded(r, u));
|
||||||
|
|
||||||
set_level(ug, SK_MELEE, 1);
|
set_level(ug, SK_MELEE, 1);
|
||||||
setguard(ug, true);
|
setguard(ug, true);
|
||||||
CuAssertPtrEquals(tc, 0, is_guarded(r, u));
|
CuAssertPtrEquals(tc, ug, is_guarded(r, u));
|
||||||
|
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +68,7 @@ static void test_guard_armed(CuTest * tc)
|
||||||
|
|
||||||
test_setup();
|
test_setup();
|
||||||
itype = it_get_or_create(rt_get_or_create("sword"));
|
itype = it_get_or_create(rt_get_or_create("sword"));
|
||||||
new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE, 2);
|
new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE);
|
||||||
r = test_create_region(0, 0, 0);
|
r = test_create_region(0, 0, 0);
|
||||||
u = test_create_unit(test_create_faction(0), r);
|
u = test_create_unit(test_create_faction(0), r);
|
||||||
ug = test_create_unit(test_create_faction(0), r);
|
ug = test_create_unit(test_create_faction(0), r);
|
||||||
|
@ -82,18 +87,14 @@ static void test_is_guard(CuTest * tc)
|
||||||
|
|
||||||
test_setup();
|
test_setup();
|
||||||
itype = it_get_or_create(rt_get_or_create("sword"));
|
itype = it_get_or_create(rt_get_or_create("sword"));
|
||||||
new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE, 2);
|
new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE);
|
||||||
r = test_create_region(0, 0, 0);
|
r = test_create_region(0, 0, 0);
|
||||||
ug = test_create_unit(test_create_faction(0), r);
|
ug = test_create_unit(test_create_faction(0), r);
|
||||||
i_change(&ug->items, itype, 1);
|
i_change(&ug->items, itype, 1);
|
||||||
set_level(ug, SK_MELEE, 2);
|
|
||||||
setguard(ug, true);
|
setguard(ug, true);
|
||||||
CuAssertIntEquals(tc, 1, armedmen(ug, false));
|
|
||||||
CuAssertTrue(tc, is_guard(ug));
|
|
||||||
set_level(ug, SK_MELEE, 1);
|
|
||||||
CuAssertIntEquals(tc, 0, armedmen(ug, false));
|
CuAssertIntEquals(tc, 0, armedmen(ug, false));
|
||||||
CuAssertTrue(tc, !is_guard(ug));
|
CuAssertTrue(tc, !is_guard(ug));
|
||||||
set_level(ug, SK_MELEE, 2);
|
set_level(ug, SK_MELEE, 1);
|
||||||
CuAssertIntEquals(tc, 1, armedmen(ug, false));
|
CuAssertIntEquals(tc, 1, armedmen(ug, false));
|
||||||
CuAssertTrue(tc, is_guard(ug));
|
CuAssertTrue(tc, is_guard(ug));
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
|
@ -142,11 +143,11 @@ static void test_update_guard(CuTest * tc)
|
||||||
t_ocean = test_create_terrain("ocean", SEA_REGION);
|
t_ocean = test_create_terrain("ocean", SEA_REGION);
|
||||||
t_plain = test_create_terrain("packice", ARCTIC_REGION);
|
t_plain = test_create_terrain("packice", ARCTIC_REGION);
|
||||||
itype = it_get_or_create(rt_get_or_create("sword"));
|
itype = it_get_or_create(rt_get_or_create("sword"));
|
||||||
new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE, 2);
|
new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE);
|
||||||
r = test_create_region(0, 0, t_plain);
|
r = test_create_region(0, 0, t_plain);
|
||||||
ug = test_create_unit(test_create_faction(0), r);
|
ug = test_create_unit(test_create_faction(0), r);
|
||||||
i_change(&ug->items, itype, 1);
|
i_change(&ug->items, itype, 1);
|
||||||
set_level(ug, SK_MELEE, 2);
|
set_level(ug, SK_MELEE, 1);
|
||||||
setguard(ug, true);
|
setguard(ug, true);
|
||||||
CuAssertIntEquals(tc, 1, armedmen(ug, false));
|
CuAssertIntEquals(tc, 1, armedmen(ug, false));
|
||||||
CuAssertTrue(tc, is_guard(ug));
|
CuAssertTrue(tc, is_guard(ug));
|
||||||
|
@ -169,11 +170,11 @@ static void test_guard_on(CuTest * tc)
|
||||||
t_ocean = test_create_terrain("ocean", SEA_REGION);
|
t_ocean = test_create_terrain("ocean", SEA_REGION);
|
||||||
t_plain = test_create_terrain("plain", LAND_REGION);
|
t_plain = test_create_terrain("plain", LAND_REGION);
|
||||||
itype = it_get_or_create(rt_get_or_create("sword"));
|
itype = it_get_or_create(rt_get_or_create("sword"));
|
||||||
new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE, 2);
|
new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE);
|
||||||
r = test_create_region(0, 0, t_plain);
|
r = test_create_region(0, 0, t_plain);
|
||||||
ug = test_create_unit(test_create_faction(0), r);
|
ug = test_create_unit(test_create_faction(0), r);
|
||||||
i_change(&ug->items, itype, 1);
|
i_change(&ug->items, itype, 1);
|
||||||
set_level(ug, SK_MELEE, 2);
|
set_level(ug, SK_MELEE, 1);
|
||||||
ug->thisorder = create_order(K_GUARD, ug->faction->locale, NULL);
|
ug->thisorder = create_order(K_GUARD, ug->faction->locale, NULL);
|
||||||
|
|
||||||
setguard(ug, false);
|
setguard(ug, false);
|
||||||
|
|
|
@ -271,11 +271,10 @@ luxury_type *new_luxurytype(item_type * itype, int price)
|
||||||
|
|
||||||
weapon_type *new_weapontype(item_type * itype,
|
weapon_type *new_weapontype(item_type * itype,
|
||||||
int wflags, variant magres, const char *damage[], int offmod, int defmod,
|
int wflags, variant magres, const char *damage[], int offmod, int defmod,
|
||||||
int reload, skill_t sk, int minskill)
|
int reload, skill_t sk)
|
||||||
{
|
{
|
||||||
weapon_type *wtype;
|
weapon_type *wtype;
|
||||||
|
|
||||||
assert(minskill > 0);
|
|
||||||
assert(itype && (!itype->rtype || !resource2weapon(itype->rtype)));
|
assert(itype && (!itype->rtype || !resource2weapon(itype->rtype)));
|
||||||
|
|
||||||
wtype = calloc(sizeof(weapon_type), 1);
|
wtype = calloc(sizeof(weapon_type), 1);
|
||||||
|
@ -287,7 +286,6 @@ weapon_type *new_weapontype(item_type * itype,
|
||||||
wtype->flags |= wflags;
|
wtype->flags |= wflags;
|
||||||
wtype->itype = itype;
|
wtype->itype = itype;
|
||||||
wtype->magres = magres;
|
wtype->magres = magres;
|
||||||
wtype->minskill = minskill;
|
|
||||||
wtype->offmod = offmod;
|
wtype->offmod = offmod;
|
||||||
wtype->reload = reload;
|
wtype->reload = reload;
|
||||||
wtype->skill = sk;
|
wtype->skill = sk;
|
||||||
|
|
|
@ -187,7 +187,6 @@ extern "C" {
|
||||||
char *damage[2];
|
char *damage[2];
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
skill_t skill;
|
skill_t skill;
|
||||||
int minskill;
|
|
||||||
int offmod;
|
int offmod;
|
||||||
int defmod;
|
int defmod;
|
||||||
variant magres;
|
variant magres;
|
||||||
|
@ -232,7 +231,7 @@ extern "C" {
|
||||||
luxury_type *new_luxurytype(item_type * itype, int price);
|
luxury_type *new_luxurytype(item_type * itype, int price);
|
||||||
weapon_type *new_weapontype(item_type * itype, int wflags,
|
weapon_type *new_weapontype(item_type * itype, int wflags,
|
||||||
variant magres, const char *damage[], int offmod, int defmod, int reload,
|
variant magres, const char *damage[], int offmod, int defmod, int reload,
|
||||||
skill_t sk, int minskill);
|
skill_t sk);
|
||||||
armor_type *new_armortype(item_type * itype, double penalty,
|
armor_type *new_armortype(item_type * itype, double penalty,
|
||||||
variant magres, int prot, unsigned int flags);
|
variant magres, int prot, unsigned int flags);
|
||||||
potion_type *new_potiontype(item_type * itype, int level);
|
potion_type *new_potiontype(item_type * itype, int level);
|
||||||
|
|
|
@ -1429,7 +1429,7 @@ int read_game(gamedata *data)
|
||||||
/* Burgen */
|
/* Burgen */
|
||||||
READ_INT(store, &p);
|
READ_INT(store, &p);
|
||||||
if (p > 0 && !r->land) {
|
if (p > 0 && !r->land) {
|
||||||
log_error("%s, uid=%d has %d %s", regionname(r, NULL), r->uid, p, (p==1) ? "building" : "buildings");
|
log_debug("%s, uid=%d has %d %s", regionname(r, NULL), r->uid, p, (p==1) ? "building" : "buildings");
|
||||||
}
|
}
|
||||||
bp = &r->buildings;
|
bp = &r->buildings;
|
||||||
|
|
||||||
|
|
|
@ -523,7 +523,6 @@ static weapon_type *xml_readweapon(xmlXPathContextPtr xpath, item_type * itype)
|
||||||
xmlChar *propValue;
|
xmlChar *propValue;
|
||||||
int k;
|
int k;
|
||||||
skill_t sk;
|
skill_t sk;
|
||||||
int minskill = xml_ivalue(node, "minskill", 1);
|
|
||||||
int offmod = xml_ivalue(node, "offmod", 0);
|
int offmod = xml_ivalue(node, "offmod", 0);
|
||||||
int defmod = xml_ivalue(node, "defmod", 0);
|
int defmod = xml_ivalue(node, "defmod", 0);
|
||||||
int reload = xml_ivalue(node, "reload", 0);
|
int reload = xml_ivalue(node, "reload", 0);
|
||||||
|
@ -555,8 +554,7 @@ static weapon_type *xml_readweapon(xmlXPathContextPtr xpath, item_type * itype)
|
||||||
xmlFree(propValue);
|
xmlFree(propValue);
|
||||||
|
|
||||||
wtype =
|
wtype =
|
||||||
new_weapontype(itype, flags, magres, NULL, offmod, defmod, reload, sk,
|
new_weapontype(itype, flags, magres, NULL, offmod, defmod, reload, sk);
|
||||||
minskill);
|
|
||||||
|
|
||||||
/* reading weapon/damage */
|
/* reading weapon/damage */
|
||||||
xpath->node = node;
|
xpath->node = node;
|
||||||
|
|
|
@ -3904,9 +3904,8 @@ int armedmen(const unit * u, bool siege_weapons)
|
||||||
const weapon_type *wtype = resource2weapon(itm->type->rtype);
|
const weapon_type *wtype = resource2weapon(itm->type->rtype);
|
||||||
if (wtype == NULL || (!siege_weapons && (wtype->flags & WTF_SIEGE)))
|
if (wtype == NULL || (!siege_weapons && (wtype->flags & WTF_SIEGE)))
|
||||||
continue;
|
continue;
|
||||||
if (effskill(u, wtype->skill, 0) >= wtype->minskill)
|
if (effskill(u, wtype->skill, 0) >= 1)
|
||||||
n += itm->number;
|
n += itm->number;
|
||||||
/* if (effskill(u, wtype->skill) >= wtype->minskill) n += itm->number; */
|
|
||||||
if (n >= u->number)
|
if (n >= u->number)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -720,9 +720,9 @@ void setup_guard(guard_fixture *fix, bool armed) {
|
||||||
if (armed) {
|
if (armed) {
|
||||||
item_type *itype;
|
item_type *itype;
|
||||||
itype = it_get_or_create(rt_get_or_create("sword"));
|
itype = it_get_or_create(rt_get_or_create("sword"));
|
||||||
new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE, 2);
|
new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE);
|
||||||
i_change(&u->items, itype, 1);
|
i_change(&u->items, itype, 1);
|
||||||
set_level(u, SK_MELEE, 2);
|
set_level(u, SK_MELEE, 1);
|
||||||
}
|
}
|
||||||
fix->u = u;
|
fix->u = u;
|
||||||
}
|
}
|
||||||
|
@ -786,11 +786,11 @@ static void test_monsters_can_guard(CuTest *tc) {
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_low_skill_cannot_guard(CuTest *tc) {
|
static void test_unskilled_cannot_guard(CuTest *tc) {
|
||||||
guard_fixture fix;
|
guard_fixture fix;
|
||||||
|
|
||||||
setup_guard(&fix, true);
|
setup_guard(&fix, true);
|
||||||
set_level(fix.u, SK_MELEE, 1);
|
set_level(fix.u, SK_MELEE, 0);
|
||||||
CuAssertIntEquals(tc, E_GUARD_UNARMED, can_start_guarding(fix.u));
|
CuAssertIntEquals(tc, E_GUARD_UNARMED, can_start_guarding(fix.u));
|
||||||
update_guards();
|
update_guards();
|
||||||
CuAssertTrue(tc, !fval(fix.u, UFL_GUARD));
|
CuAssertTrue(tc, !fval(fix.u, UFL_GUARD));
|
||||||
|
@ -1607,7 +1607,7 @@ static void test_demon_hunger(CuTest * tc)
|
||||||
u = test_create_unit(f, r);
|
u = test_create_unit(f, r);
|
||||||
u->hp = 999;
|
u->hp = 999;
|
||||||
|
|
||||||
config_set("hunger.demons.peasant_tolerance", "1");
|
config_set("hunger.demon.peasant_tolerance", "1");
|
||||||
|
|
||||||
rtype = get_resourcetype(R_SILVER);
|
rtype = get_resourcetype(R_SILVER);
|
||||||
i_change(&u->items, rtype->itype, 30);
|
i_change(&u->items, rtype->itype, 30);
|
||||||
|
@ -1619,7 +1619,7 @@ static void test_demon_hunger(CuTest * tc)
|
||||||
CuAssertIntEquals(tc, 20, i_get(u->items, rtype->itype));
|
CuAssertIntEquals(tc, 20, i_get(u->items, rtype->itype));
|
||||||
CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "malnourish"));
|
CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "malnourish"));
|
||||||
|
|
||||||
config_set("hunger.demons.peasant_tolerance", "0");
|
config_set("hunger.demon.peasant_tolerance", "0");
|
||||||
|
|
||||||
get_food(r);
|
get_food(r);
|
||||||
|
|
||||||
|
@ -1638,7 +1638,7 @@ static void test_armedmen(CuTest *tc) {
|
||||||
test_setup();
|
test_setup();
|
||||||
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||||
it_sword = test_create_itemtype("sword");
|
it_sword = test_create_itemtype("sword");
|
||||||
wtype = new_weapontype(it_sword, 0, frac_make(1, 2), 0, 0, 0, 0, SK_MELEE, 1);
|
wtype = new_weapontype(it_sword, 0, frac_make(1, 2), 0, 0, 0, 0, SK_MELEE);
|
||||||
CuAssertIntEquals(tc, 0, armedmen(u, false));
|
CuAssertIntEquals(tc, 0, armedmen(u, false));
|
||||||
CuAssertIntEquals(tc, 0, armedmen(u, true));
|
CuAssertIntEquals(tc, 0, armedmen(u, true));
|
||||||
set_level(u, SK_MELEE, 1);
|
set_level(u, SK_MELEE, 1);
|
||||||
|
@ -1655,11 +1655,6 @@ static void test_armedmen(CuTest *tc) {
|
||||||
set_level(u, SK_MELEE, 1);
|
set_level(u, SK_MELEE, 1);
|
||||||
i_change(&u->items, it_sword, -1);
|
i_change(&u->items, it_sword, -1);
|
||||||
CuAssertIntEquals(tc, 1, armedmen(u, false));
|
CuAssertIntEquals(tc, 1, armedmen(u, false));
|
||||||
wtype->minskill = 2;
|
|
||||||
CuAssertIntEquals(tc, 0, armedmen(u, false));
|
|
||||||
set_level(u, SK_MELEE, 2);
|
|
||||||
CuAssertIntEquals(tc, 1, armedmen(u, false));
|
|
||||||
CuAssertIntEquals(tc, 1, armedmen(u, true));
|
|
||||||
wtype->flags |= WTF_SIEGE;
|
wtype->flags |= WTF_SIEGE;
|
||||||
CuAssertIntEquals(tc, 0, armedmen(u, false));
|
CuAssertIntEquals(tc, 0, armedmen(u, false));
|
||||||
CuAssertIntEquals(tc, 1, armedmen(u, true));
|
CuAssertIntEquals(tc, 1, armedmen(u, true));
|
||||||
|
@ -1806,7 +1801,7 @@ CuSuite *get_laws_suite(void)
|
||||||
SUITE_ADD_TEST(suite, test_unarmed_races_can_guard);
|
SUITE_ADD_TEST(suite, test_unarmed_races_can_guard);
|
||||||
SUITE_ADD_TEST(suite, test_monsters_can_guard);
|
SUITE_ADD_TEST(suite, test_monsters_can_guard);
|
||||||
SUITE_ADD_TEST(suite, test_fleeing_cannot_guard);
|
SUITE_ADD_TEST(suite, test_fleeing_cannot_guard);
|
||||||
SUITE_ADD_TEST(suite, test_low_skill_cannot_guard);
|
SUITE_ADD_TEST(suite, test_unskilled_cannot_guard);
|
||||||
SUITE_ADD_TEST(suite, test_reserve_self);
|
SUITE_ADD_TEST(suite, test_reserve_self);
|
||||||
SUITE_ADD_TEST(suite, test_reserve_cmd);
|
SUITE_ADD_TEST(suite, test_reserve_cmd);
|
||||||
SUITE_ADD_TEST(suite, test_pay_cmd);
|
SUITE_ADD_TEST(suite, test_pay_cmd);
|
||||||
|
|
20
src/move.c
20
src/move.c
|
@ -677,21 +677,6 @@ int check_ship_allowed(struct ship *sh, const region * r)
|
||||||
int c = 0;
|
int c = 0;
|
||||||
const building_type *bt_harbour = bt_find("harbour");
|
const building_type *bt_harbour = bt_find("harbour");
|
||||||
|
|
||||||
if (sh->region && r_insectstalled(r)) {
|
|
||||||
/* insekten dürfen nicht hier rein. haben wir welche? */
|
|
||||||
unit *u;
|
|
||||||
|
|
||||||
for (u = sh->region->units; u != NULL; u = u->next) {
|
|
||||||
if (u->ship != sh) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_freezing(u)) {
|
|
||||||
return SA_NO_INSECT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bt_harbour && buildingtype_exists(r, bt_harbour, true)) {
|
if (bt_harbour && buildingtype_exists(r, bt_harbour, true)) {
|
||||||
unit* harbourmaster = NULL;
|
unit* harbourmaster = NULL;
|
||||||
harbourmaster = owner_buildingtyp(r, bt_harbour);
|
harbourmaster = owner_buildingtyp(r, bt_harbour);
|
||||||
|
@ -1852,10 +1837,7 @@ static void sail(unit * u, order * ord, region_list ** routep, bool drifting)
|
||||||
reason = check_ship_allowed(sh, next_point);
|
reason = check_ship_allowed(sh, next_point);
|
||||||
if (reason < 0) {
|
if (reason < 0) {
|
||||||
/* for some reason or another, we aren't allowed in there.. */
|
/* for some reason or another, we aren't allowed in there.. */
|
||||||
if (reason == SA_NO_INSECT) {
|
if (check_leuchtturm(current_point, NULL)) {
|
||||||
ADDMSG(&f->msgs, msg_message("detectforbidden", "unit region", u, sh->region));
|
|
||||||
}
|
|
||||||
else if (check_leuchtturm(current_point, NULL)) {
|
|
||||||
ADDMSG(&f->msgs, msg_message("sailnolandingstorm", "ship region", sh, next_point));
|
ADDMSG(&f->msgs, msg_message("sailnolandingstorm", "ship region", sh, next_point));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -90,8 +90,7 @@ extern "C" {
|
||||||
|
|
||||||
#define SA_HARBOUR 1
|
#define SA_HARBOUR 1
|
||||||
#define SA_COAST 0
|
#define SA_COAST 0
|
||||||
#define SA_NO_INSECT -1
|
#define SA_NO_COAST -1
|
||||||
#define SA_NO_COAST -2
|
|
||||||
|
|
||||||
int check_ship_allowed(struct ship *sh, const struct region * r);
|
int check_ship_allowed(struct ship *sh, const struct region * r);
|
||||||
direction_t drift_target(struct ship *sh);
|
direction_t drift_target(struct ship *sh);
|
||||||
|
|
|
@ -64,7 +64,7 @@ static void test_all_spy_message(CuTest *tc) {
|
||||||
set_factionstealth(fix.victim, fix.spy->faction);
|
set_factionstealth(fix.victim, fix.spy->faction);
|
||||||
|
|
||||||
itype = it_get_or_create(rt_get_or_create("sword"));
|
itype = it_get_or_create(rt_get_or_create("sword"));
|
||||||
new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE, 2);
|
new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE);
|
||||||
i_change(&fix.victim->items, itype, 1);
|
i_change(&fix.victim->items, itype, 1);
|
||||||
|
|
||||||
spy_message(99, fix.spy, fix.victim);
|
spy_message(99, fix.spy, fix.victim);
|
||||||
|
|
27
src/upkeep.c
27
src/upkeep.c
|
@ -109,16 +109,27 @@ void get_food(region * r)
|
||||||
plane *pl = rplane(r);
|
plane *pl = rplane(r);
|
||||||
unit *u;
|
unit *u;
|
||||||
int peasantfood = rpeasants(r) * 10;
|
int peasantfood = rpeasants(r) * 10;
|
||||||
int food_rules = config_get_int("rules.food.flags", 0);
|
static const race *rc_demon, *rc_insect;
|
||||||
static const race *rc_demon;
|
static int rc_cache, config_cache;
|
||||||
static int rc_cache;
|
static int food_rules;
|
||||||
|
static bool insect_hunger;
|
||||||
|
static bool demon_hunger;
|
||||||
|
bool is_cold;
|
||||||
|
|
||||||
if (rc_changed(&rc_cache)) {
|
if (rc_changed(&rc_cache)) {
|
||||||
rc_demon = get_race(RC_DAEMON);
|
rc_demon = get_race(RC_DAEMON);
|
||||||
|
rc_insect = get_race(RC_INSECT);
|
||||||
|
}
|
||||||
|
if (config_changed(&config_cache)) {
|
||||||
|
food_rules = config_get_int("rules.food.flags", 0);
|
||||||
|
insect_hunger = config_get_int("hunger.insect.cold", 1) != 0;
|
||||||
|
demon_hunger = config_get_int("hunger.demon.peasant_tolerance", 0) == 0;
|
||||||
}
|
}
|
||||||
if (food_rules & FOOD_IS_FREE) {
|
if (food_rules & FOOD_IS_FREE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
is_cold = insect_hunger && r_insectstalled(r);
|
||||||
|
|
||||||
/* 1. Versorgung von eigenen Einheiten. Das vorhandene Silber
|
/* 1. Versorgung von eigenen Einheiten. Das vorhandene Silber
|
||||||
* wird zun<EFBFBD>chst so auf die Einheiten aufgeteilt, dass idealerweise
|
* wird zun<EFBFBD>chst so auf die Einheiten aufgeteilt, dass idealerweise
|
||||||
* jede Einheit genug Silber f<EFBFBD>r ihren Unterhalt hat. */
|
* jede Einheit genug Silber f<EFBFBD>r ihren Unterhalt hat. */
|
||||||
|
@ -227,7 +238,8 @@ void get_food(region * r)
|
||||||
* bei fehlenden Bauern den D<EFBFBD>mon hungern lassen
|
* bei fehlenden Bauern den D<EFBFBD>mon hungern lassen
|
||||||
*/
|
*/
|
||||||
for (u = r->units; u; u = u->next) {
|
for (u = r->units; u; u = u->next) {
|
||||||
if (u_race(u) == rc_demon) {
|
const race * rc = u_race(u);
|
||||||
|
if (rc == rc_demon) {
|
||||||
int hungry = u->number;
|
int hungry = u->number;
|
||||||
|
|
||||||
/* use peasantblood before eating the peasants themselves */
|
/* use peasantblood before eating the peasants themselves */
|
||||||
|
@ -271,7 +283,6 @@ void get_food(region * r)
|
||||||
peasantfood = 0;
|
peasantfood = 0;
|
||||||
}
|
}
|
||||||
if (hungry > 0) {
|
if (hungry > 0) {
|
||||||
bool demon_hunger = config_get_int("hunger.demons.peasant_tolerance", 0) == 0;
|
|
||||||
if (demon_hunger) {
|
if (demon_hunger) {
|
||||||
/* demons who don't feed are hungry */
|
/* demons who don't feed are hungry */
|
||||||
if (hunger(hungry, u))
|
if (hunger(hungry, u))
|
||||||
|
@ -284,6 +295,12 @@ void get_food(region * r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (is_cold && rc == rc_insect) {
|
||||||
|
/* insects in glaciers get hunger damage */
|
||||||
|
if (hunger(u->number, u)) {
|
||||||
|
fset(u, UFL_HUNGER);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rsetpeasants(r, peasantfood / 10);
|
rsetpeasants(r, peasantfood / 10);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue