forked from github/server
test that ships are encumbered by money. define money in XML, not just in code.
This commit is contained in:
parent
468882f974
commit
6fb23af66a
4 changed files with 45 additions and 1 deletions
|
@ -1,6 +1,10 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
|
<resource name="money">
|
||||||
|
<item weight="1"/>
|
||||||
|
</resource>
|
||||||
|
|
||||||
<resource name="ao_healing" appearance="amulet">
|
<resource name="ao_healing" appearance="amulet">
|
||||||
<item weight="0" score="6000"/>
|
<item weight="0" score="6000"/>
|
||||||
</resource>
|
</resource>
|
||||||
|
|
|
@ -729,6 +729,25 @@ function test_silver_weight_stops_movement()
|
||||||
assert_equal(r2, u1.region)
|
assert_equal(r2, u1.region)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function test_silver_weight_stops_ship()
|
||||||
|
local r1 = region.create(1, 1, "ocean")
|
||||||
|
local r2 = region.create(2, 1, "ocean")
|
||||||
|
region.create(3, 1, "ocean")
|
||||||
|
local f1 = faction.create("noreply@eressea.de", "human", "de")
|
||||||
|
local u1 = unit.create(f1, r1, 1)
|
||||||
|
u1:set_skill("sailing", 3)
|
||||||
|
local s1 = ship.create(r1, "canoe")
|
||||||
|
u1.ship = s1
|
||||||
|
u1:clear_orders()
|
||||||
|
u1:add_order("NACH OST")
|
||||||
|
u1:add_item("money", 2000)
|
||||||
|
process_orders()
|
||||||
|
assert_equal(r2, u1.region)
|
||||||
|
u1:add_item("money", 1)
|
||||||
|
process_orders()
|
||||||
|
assert_equal(r2, u1.region)
|
||||||
|
end
|
||||||
|
|
||||||
function test_building_owner_can_enter_ship()
|
function test_building_owner_can_enter_ship()
|
||||||
local r1 = region.create(1, 2, "plain")
|
local r1 = region.create(1, 2, "plain")
|
||||||
local f1 = faction.create("noreply@eressea.de", "human", "de")
|
local f1 = faction.create("noreply@eressea.de", "human", "de")
|
||||||
|
|
|
@ -960,7 +960,6 @@ void init_resources(void)
|
||||||
rtype->uchange = res_changeitem;
|
rtype->uchange = res_changeitem;
|
||||||
rtype->itype = it_get_or_create(rtype);
|
rtype->itype = it_get_or_create(rtype);
|
||||||
rtype->itype->give = give_money;
|
rtype->itype->give = give_money;
|
||||||
rtype->itype->weight = 1;
|
|
||||||
|
|
||||||
// R_PERMAURA
|
// R_PERMAURA
|
||||||
rtype = rt_get_or_create(resourcenames[R_PERMAURA]);
|
rtype = rt_get_or_create(resourcenames[R_PERMAURA]);
|
||||||
|
|
|
@ -143,6 +143,27 @@ static void test_fix_demand(CuTest *tc) {
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_core_resources(CuTest *tc) {
|
||||||
|
resource_type * rtype;
|
||||||
|
test_cleanup();
|
||||||
|
init_resources();
|
||||||
|
CuAssertPtrNotNull(tc, rtype = rt_find("money"));
|
||||||
|
CuAssertPtrNotNull(tc, rtype->itype);
|
||||||
|
CuAssertPtrNotNull(tc, rtype->uchange);
|
||||||
|
CuAssertPtrNotNull(tc, rtype->itype->give);
|
||||||
|
CuAssertPtrNotNull(tc, rtype = rt_find("peasant"));
|
||||||
|
CuAssertPtrEquals(tc, 0, rtype->itype);
|
||||||
|
CuAssertPtrNotNull(tc, rtype = rt_find("person"));
|
||||||
|
CuAssertPtrEquals(tc, 0, rtype->itype);
|
||||||
|
CuAssertPtrNotNull(tc, rtype = rt_find("permaura"));
|
||||||
|
CuAssertPtrEquals(tc, 0, rtype->itype);
|
||||||
|
CuAssertPtrNotNull(tc, rtype = rt_find("hp"));
|
||||||
|
CuAssertPtrEquals(tc, 0, rtype->itype);
|
||||||
|
CuAssertPtrNotNull(tc, rtype = rt_find("aura"));
|
||||||
|
CuAssertPtrEquals(tc, 0, rtype->itype);
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
CuSuite *get_item_suite(void)
|
CuSuite *get_item_suite(void)
|
||||||
{
|
{
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
|
@ -153,5 +174,6 @@ CuSuite *get_item_suite(void)
|
||||||
SUITE_ADD_TEST(suite, test_finditemtype);
|
SUITE_ADD_TEST(suite, test_finditemtype);
|
||||||
SUITE_ADD_TEST(suite, test_findresourcetype);
|
SUITE_ADD_TEST(suite, test_findresourcetype);
|
||||||
SUITE_ADD_TEST(suite, test_fix_demand);
|
SUITE_ADD_TEST(suite, test_fix_demand);
|
||||||
|
SUITE_ADD_TEST(suite, test_core_resources);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue