forked from github/server
add a test for btype.maxsize
This commit is contained in:
parent
b79db40f41
commit
0bf003cdc4
|
@ -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
|
||||||
|
|
|
@ -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)];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue