add a test for building items.

This commit is contained in:
Enno Rehling 2018-04-30 23:17:48 +02:00
parent e0e873044d
commit e0cae602dd
3 changed files with 17 additions and 5 deletions

View File

@ -284,8 +284,6 @@ function test_block_movement()
end
end
function test_block_movement_aots()
eressea.settings.set("rules.guard.base_stop_prob", "0.0")
eressea.settings.set("rules.guard.skill_stop_prob", "1.0")

View File

@ -12,6 +12,22 @@ local function create_faction(race)
return faction.create(race, race .. '@example.com', "de")
end
function test_produce_multi()
local r = region.create(0, 0, 'mountain')
local f = create_faction('human')
local u = unit.create(f, r, 1)
-- sword needs skill=3, iron=1
u:set_skill('weaponsmithing', 15)
u:add_item('iron', 5)
turn_begin()
u:add_order("MACHE 6 Schwert")
turn_process()
assert_equal(5, u:get_item('sword'))
assert_equal(0, u:get_item('iron'))
end
function test_greatbow_needs_elf()
-- only elves can build a greatbow
local r = region.create(0, 0, 'mountain')

View File

@ -589,9 +589,7 @@ int build(unit * u, const construction * ctype, int completed, int want, int ski
if (con->maxsize > 0) {
int req = con->maxsize - completed;
if (req < n) n = req;
if (con->improvement == NULL) {
want = n;
}
want = n;
}
n = count_materials(u, con, n, completed);