From 2073e8f860670a4f7515cd1fad294a8ca2332661 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 20 Nov 2010 18:01:46 -0800 Subject: [PATCH] http://bugs.eressea.de/view.php?id=1816 repair snowmen (xmas 2004) --- scripts/eressea/xmas2004.lua | 2 +- scripts/tests/eressea.lua | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/scripts/eressea/xmas2004.lua b/scripts/eressea/xmas2004.lua index 6a6bcfa63..92913c183 100644 --- a/scripts/eressea/xmas2004.lua +++ b/scripts/eressea/xmas2004.lua @@ -1,6 +1,6 @@ function use_snowman(u, amount) if u.region.terrain == "glacier" then - local man = add_unit(u.faction, u.region) + local man = unit.create(u.faction, u.region) man.race = "snowman" man.number = amount u:add_item("snowman", -amount) diff --git a/scripts/tests/eressea.lua b/scripts/tests/eressea.lua index 767cff742..8a0060088 100644 --- a/scripts/tests/eressea.lua +++ b/scripts/tests/eressea.lua @@ -182,3 +182,21 @@ function test_no_uruk() local f1 = faction.create("noreply@eressea.de", "uruk", "de") assert_equal(f1.race, "orc") end + +function test_snowman() + local r = region.create(0, 0, "glacier") + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:add_item("snowman", 1) + u:clear_orders() + u:add_order("BENUTZEN 1 Schneemann") + process_orders() + for u2 in r.units do + if u2~=u then + assert_equal(u2.race, "snowman") + u = nil + break + end + end + assert_equal(nil, u) +end