forked from github/server
fix broken laen tests by hacking in another config setting
This commit is contained in:
parent
1fe075e82d
commit
cde0ce0742
|
@ -570,10 +570,11 @@ function test_config()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function _test_create_laen()
|
local function _test_create_laen()
|
||||||
|
eressea.settings.set("rules.terraform.all", "1")
|
||||||
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)
|
r:set_resource("laen", 50)
|
||||||
return r, u1
|
return r, u1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -596,15 +597,18 @@ function test_laen2()
|
||||||
u1:set_skill("mining", 15)
|
u1:set_skill("mining", 15)
|
||||||
u1:clear_orders()
|
u1:clear_orders()
|
||||||
u1:add_order("MACHEN Laen")
|
u1:add_order("MACHEN Laen")
|
||||||
|
u1.name = "Laenmeister"
|
||||||
|
|
||||||
local b = building.create(r, "mine")
|
local b = building.create(r, "mine")
|
||||||
b.size = 10
|
b.size = 10
|
||||||
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"))
|
init_reports()
|
||||||
|
write_report(u1.faction)
|
||||||
assert_equal(laen - 2, r:get_resource("laen"))
|
assert_equal(laen - 2, r:get_resource("laen"))
|
||||||
|
assert_equal(2, u1:get_item("laen"))
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_mine()
|
function test_mine()
|
||||||
|
|
|
@ -82,6 +82,10 @@ void terraform_resources(region * r)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
const terrain_type *terrain = r->terrain;
|
const terrain_type *terrain = r->terrain;
|
||||||
|
static int terraform_all = -1;
|
||||||
|
if (terraform_all<0) {
|
||||||
|
terraform_all = get_param_int(global.parameters, "rules.terraform.all", 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (terrain->production == NULL)
|
if (terrain->production == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -94,10 +98,11 @@ void terraform_resources(region * r)
|
||||||
if (rm->type->rtype == rtype)
|
if (rm->type->rtype == rtype)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (rm)
|
if (rm) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
if (chance(production->chance)) {
|
|
||||||
|
if (terraform_all || chance(production->chance)) {
|
||||||
add_resource(r, dice_rand(production->startlevel),
|
add_resource(r, dice_rand(production->startlevel),
|
||||||
dice_rand(production->base), dice_rand(production->divisor),
|
dice_rand(production->base), dice_rand(production->divisor),
|
||||||
production->type);
|
production->type);
|
||||||
|
|
Loading…
Reference in New Issue