From a452ad1517ebe5b2eb05c665ca858a0ca8115c48 Mon Sep 17 00:00:00 2001 From: Philipp Dreher Date: Fri, 6 Nov 2015 20:53:10 +0100 Subject: [PATCH] added a lua-test New lua-test for the bug concerning the minskill for castle-stages. (#1859) --- scripts/tests/e3/castles.lua | 23 +++++++++++++++++++++++ src/kernel/build.c | 4 +++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/scripts/tests/e3/castles.lua b/scripts/tests/e3/castles.lua index b9cbabe0b..b32f80f5d 100644 --- a/scripts/tests/e3/castles.lua +++ b/scripts/tests/e3/castles.lua @@ -50,3 +50,26 @@ function test_build_packice() process_orders() assert_equal(nil, u.building) end + +function test_build_castle_stages() + local r = region.create(0,0, "plain") + local f = faction.create("castle@eressea.de", "human", "de") + local u = unit.create(f, r, 1000) + local b = building.create(r, "castle") + + u:add_item("stone", 1000) + + u:set_skill("building", 1) + u:clear_orders() + + u:add_order("MACHE BURG " .. itoa36(b.id)) + process_orders() + assert_equal(10, b.size) + + u:set_skill("building", 3) + u:clear_orders() + + u:add_order("MACHE BURG " .. itoa36(b.id)) + process_orders() + assert_equal(250, b.size) +end diff --git a/src/kernel/build.c b/src/kernel/build.c index e38d76641..3952c732a 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -522,7 +522,9 @@ int build(unit * u, const construction * ctype, int completed, int want) if (basesk < type->minskill) { if (made == 0) - return ELOWSKILL; /* not good enough to go on */ + return ELOWSKILL; + else + return made; /* not good enough to go on */ } /* n = maximum buildable size */