removed all unused items

This commit is contained in:
Enno Rehling 2011-03-04 20:38:36 +01:00
parent a11d49b406
commit b0f1445d68
2 changed files with 63 additions and 13 deletions

View File

@ -354,12 +354,12 @@ function test_produce()
local u = unit.create(f, r, 1)
u:clear_orders()
u:set_skill("weaponsmithing", 3)
u:add_item("iron", 2)
u:add_item("iron", 10)
u:add_item("money", u.number * 10)
u:add_order("MACHE Schwert")
process_orders()
assert(u:get_item("iron")==1)
assert(u:get_item("sword")==1)
assert_equal(10-3/test.swordmakeskill*test.swordiron, u:get_item("iron"))
assert_equal(3/test.swordmakeskill, u:get_item("sword"))
end
function test_work()
@ -431,7 +431,7 @@ function test_mallorn()
r:set_resource("tree", 100)
assert(r:get_resource("tree")==100)
local m = region.create(0, 0, "plain")
m:set_flag(1, true) -- not mallorn
m:set_flag(1, true) -- mallorn
m:set_resource("tree", 100)
assert(m:get_resource("tree")==100)
@ -454,10 +454,17 @@ function test_mallorn()
u3:set_skill("forestry", 2)
u3:clear_orders()
u3:add_order("MACHE Mallorn")
process_orders()
assert(u1:get_item("log")==2)
assert(u2:get_item("log")==2)
assert(u3:get_item("mallorn")==1)
if (has_item("mallorn")) then
assert(u3:get_item("mallorn")==1)
else
assert_equal(-1, u3:get_item("mallorn"))
assert_equal(0, u3:get_item("log"))
end
end
function test_coordinate_translation()
@ -696,8 +703,9 @@ function test_ride_with_horse()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
local pweight = u.weight
u:add_item("horse", 1)
u:add_item("sword", 10)
u:add_item("sword", (test.horsecapacity - pweight)/100)
u:set_skill("riding", 2)
u:clear_orders()
@ -718,14 +726,37 @@ function test_ride_with_horses_and_cart()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u:add_item("cart", 1)
assert_equal(1, u:get_item("cart")) -- every game has a cart, right? right?
u:add_item("horse", 2)
assert_equal(2, u:get_item("horse")) -- every game has a horse, right? right?
u:add_item("sword", 120)
assert_equal(120, u:get_item("sword")) -- every game has a sword, right? and it weighs 1 unit?
local carts = 0
local horses = 0
local pweight = u.weight
if (has_item("cart")) then
u:add_item("cart", 1)
assert_equal(1, u:get_item("cart")) -- every game has a cart, right? right? no! atlantis hasn't!
carts = u:get_item("cart")
end
u:add_item("horse", 1)
assert_equal(1, u:get_item("horse")) -- every game has a horse, right? right?
local horses = u:get_item("horse")
assert(horses+carts>0)
local capacity = test.horsecapacity*(horses+1) + test.cartcapacity*carts - pweight
capacity = capacity / 100
u:add_item("sword", capacity)
assert_equal(capacity, u:get_item("sword")) -- every game has a sword, right? and it weighs 1 unit?
u:set_skill("riding", 3)
if (has_item("cart")) then
-- need 2 horses for a cart
u:clear_orders()
u:add_order("NACH O O")
process_orders()
assert_equal(0, u.region.x)
end
u:add_item("horse", 1)
assert_equal(2, u:get_item("horse"))
horses = u:get_item("horse")
-- ride
u:clear_orders()
u:add_order("NACH O O")
@ -733,7 +764,7 @@ function test_ride_with_horses_and_cart()
assert_equal(2, u.region.x)
-- walk
u:add_item("sword", 20)
u:add_item("sword", 10)
r:get_key("eviL")
u:clear_orders()
u:add_order("NACH W W")

View File

@ -1018,6 +1018,22 @@ tolua_settings_set(lua_State* L)
return 0;
}
/*
* Paramter: item name
* Returns true if the item type is known in the game
*/
static int
tolua_has_item(lua_State* L)
{
const char * iname = tolua_tostring(L, 1, 0);
const item_type * itype = NULL;
if (iname!=NULL) {
itype = it_find(iname);
}
lua_pushboolean(L, itype!=NULL);
return 1;
}
static void
parse_inifile(lua_State* L, dictionary * d, const char * section)
{
@ -1202,6 +1218,9 @@ tolua_eressea_open(lua_State* L)
tolua_function(L, TOLUA_CAST "read_xml", tolua_read_xml);
/* test helpers */
tolua_function(L, TOLUA_CAST "has_item", tolua_has_item);
}
tolua_endmodule(L);
return 1;