forked from github/server
laen test does not work. trying to make setresource add the raw material to fix it
This commit is contained in:
parent
166d4ccc2c
commit
1fe075e82d
|
@ -570,20 +570,11 @@ function test_config()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function _test_create_laen()
|
local function _test_create_laen()
|
||||||
local r = region.create(0,0, "mountain")
|
local r = region.create(0,0, "mountain")
|
||||||
local f1 = faction.create("noreply@eressea.de", "human", "de")
|
local f1 = faction.create("noreply@eressea.de", "human", "de")
|
||||||
local u1 = unit.create(f1, r, 1)
|
local u1 = unit.create(f1, r, 1)
|
||||||
|
r:set_resource("laen", 3)
|
||||||
-- TODO this is a stupid way to create a laen region
|
return r, u1
|
||||||
for i = 1, 10000 do
|
|
||||||
r = region.create(i,0, "mountain")
|
|
||||||
if r:get_resource("laen") > 2 then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
assert(r:get_resource("laen")>2, "could not run test properly, please try again")
|
|
||||||
|
|
||||||
return r, u1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_laen1()
|
function test_laen1()
|
||||||
|
@ -611,7 +602,7 @@ function test_laen2()
|
||||||
u1.building = b
|
u1.building = b
|
||||||
local laen = r:get_resource("laen")
|
local laen = r:get_resource("laen")
|
||||||
|
|
||||||
process_orders()
|
process_orders()
|
||||||
assert_equal(2, u1:get_item("laen"))
|
assert_equal(2, u1:get_item("laen"))
|
||||||
assert_equal(laen - 2, r:get_resource("laen"))
|
assert_equal(laen - 2, r:get_resource("laen"))
|
||||||
end
|
end
|
||||||
|
|
|
@ -1016,6 +1016,16 @@ void region_setresource(region * r, const resource_type * rtype, int value)
|
||||||
rsetpeasants(r, value);
|
rsetpeasants(r, value);
|
||||||
else if (rtype == rt_find("horse"))
|
else if (rtype == rt_find("horse"))
|
||||||
rsethorses(r, value);
|
rsethorses(r, value);
|
||||||
|
else {
|
||||||
|
int i;
|
||||||
|
for (i = 0; r->terrain->production[i].type; ++i) {
|
||||||
|
const terrain_production *production = r->terrain->production + i;
|
||||||
|
if (production->type==rtype) {
|
||||||
|
add_resource(r, 1, value, dice_rand(production->divisor), rtype);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue