fix broken laen tests by hacking in another config setting

This commit is contained in:
Enno Rehling 2012-08-03 00:41:17 -07:00
parent 1fe075e82d
commit cde0ce0742
2 changed files with 16 additions and 7 deletions

View File

@ -570,10 +570,11 @@ function test_config()
end
local function _test_create_laen()
eressea.settings.set("rules.terraform.all", "1")
local r = region.create(0,0, "mountain")
local f1 = faction.create("noreply@eressea.de", "human", "de")
local u1 = unit.create(f1, r, 1)
r:set_resource("laen", 3)
r:set_resource("laen", 50)
return r, u1
end
@ -596,6 +597,7 @@ function test_laen2()
u1:set_skill("mining", 15)
u1:clear_orders()
u1:add_order("MACHEN Laen")
u1.name = "Laenmeister"
local b = building.create(r, "mine")
b.size = 10
@ -603,8 +605,10 @@ function test_laen2()
local laen = r:get_resource("laen")
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(2, u1:get_item("laen"))
end
function test_mine()

View File

@ -82,6 +82,10 @@ void terraform_resources(region * r)
{
int i;
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)
return;
@ -94,10 +98,11 @@ void terraform_resources(region * r)
if (rm->type->rtype == rtype)
break;
}
if (rm)
if (rm) {
continue;
}
if (chance(production->chance)) {
if (terraform_all || chance(production->chance)) {
add_resource(r, dice_rand(production->startlevel),
dice_rand(production->base), dice_rand(production->divisor),
production->type);