this test fails when btype->maxsize isn't used as a limit for building.

This commit is contained in:
Enno Rehling 2017-07-17 14:01:08 +02:00
parent 0bf003cdc4
commit 3c2754071d
4 changed files with 22 additions and 40 deletions

View File

@ -129,7 +129,7 @@
<building name="harbour" capacity="1" maxcapacity="25" maxsize="25" unique="yes">
<maintenance type="money" amount="250"/>
<construction skill="building" minskill="3" reqsize="25" maxsize="25">
<construction skill="building" minskill="3" reqsize="25">
<requirement type="log" quantity="125"/>
<requirement type="stone" quantity="125"/>
<requirement type="money" quantity="6250"/>

View File

@ -52,22 +52,26 @@ function test_build_castle_stages()
assert_equal(250, b.size)
end
function test_build_maxsize()
local r = region.create(0,0, "plain")
local f = faction.create("human")
local u = unit.create(f, r, 100)
local b = building.create(r, "harbour")
b.size = 20
u:add_item("stone", 1000)
u:add_item("log", 1000)
u:add_item("money", 10000)
u:set_skill("building", 100)
function test_build_harbour()
-- try to reproduce mantis bug 2221
local r = region.create(0, 0, "plain")
local f = faction.create("human", "harbour@eressea.de", "de")
local u = unit.create(f, r)
size = 30
u.number = 20
u:set_skill("building", 3)
u:add_item("money", size*250)
u:add_item("stone", size*5)
u:add_item("log", size*5)
u:clear_orders()
u:add_order("MACHE BURG " .. itoa36(b.id))
u:add_order("MACHE HAFEN")
process_orders()
assert_equal(25, b.size) -- build no more than max
assert_not_nil(u.building)
assert_equal("harbour", u.building.type)
assert_equal(20, u.building.size)
process_orders()
assert_equal(25, b.size) -- stop at max
assert_equal(25, u.building.size)
process_orders()
assert_equal(25, u.building.size)
end

View File

@ -62,29 +62,6 @@ function test_dwarf_bonus()
assert_equal(70, r:get_resource("iron"))
end
function test_build_harbour()
-- try to reproduce mantis bug 2221
local r = region.create(0, 0, "plain")
local f = faction.create("human", "harbour@eressea.de", "de")
local u = unit.create(f, r)
size = 30
u.number = 20
u:set_skill("building", 3)
u:add_item("money", size*250)
u:add_item("stone", size*5)
u:add_item("log", size*5)
u:clear_orders()
u:add_order("MACHE HAFEN")
process_orders()
assert_not_nil(u.building)
assert_equal("harbour", u.building.type)
assert_equal(20, u.building.size)
process_orders()
assert_equal(25, u.building.size)
process_orders()
assert_equal(25, u.building.size)
end
local function one_unit(r, f)
local u = unit.create(f, r, 1)
u:add_item("money", u.number * 100)

View File

@ -717,8 +717,9 @@ build_building(unit * u, const building_type * btype, int id, int want, order *
b = u->building;
}
if (b)
if (b) {
btype = b->type;
}
if (fval(btype, BTF_UNIQUE) && buildingtype_exists(r, btype, false)) {
/* only one of these per region */