add a test for btype.maxsize

This commit is contained in:
Enno Rehling 2017-07-17 13:37:40 +02:00
parent b79db40f41
commit 0bf003cdc4
2 changed files with 21 additions and 0 deletions

View File

@ -51,3 +51,23 @@ function test_build_castle_stages()
process_orders() process_orders()
assert_equal(250, b.size) assert_equal(250, b.size)
end 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)
u:clear_orders()
u:add_order("MACHE BURG " .. itoa36(b.id))
process_orders()
assert_equal(25, b.size) -- build no more than max
process_orders()
assert_equal(25, b.size) -- stop at max
end

View File

@ -310,6 +310,7 @@ static const int watch_bonus[3] = { 0, 1, 2 };
int building_protection(const building_type * btype, int stage) int building_protection(const building_type * btype, int stage)
{ {
assert(btype->flags & BTF_FORTIFICATION);
if (btype->maxsize < 0) { if (btype->maxsize < 0) {
return castle_bonus[MIN(stage, 5)]; return castle_bonus[MIN(stage, 5)];
} }