From 6e3ed568ea3425c94db56138c72d987abbd2cecb Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 17 Mar 2014 08:21:35 +0100 Subject: [PATCH] fix lua test for blessed harvest. --- scripts/tests/spells.lua | 32 +++++++++++++++----------------- src/kernel/reports.c | 2 +- src/laws.c | 6 ++---- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/scripts/tests/spells.lua b/scripts/tests/spells.lua index 7a1cb6d86..a96607a96 100644 --- a/scripts/tests/spells.lua +++ b/scripts/tests/spells.lua @@ -5,6 +5,9 @@ module("tests.e3.spells", package.seeall, lunit.testcase) function setup() eressea.free_game() eressea.settings.set("magic.fumble.enable", "0") + eressea.settings.set("nmr.removenewbie", "0") + eressea.settings.set("nmr.timeout", "0") + eressea.settings.set("rules.peasants.growth", "0") end function test_blessedharvest_lasts_n_turn() @@ -25,25 +28,20 @@ function test_blessedharvest_lasts_n_turn() assert_equal(0, err) u:clear_orders() - local level = 5 - u:add_order("ZAUBERE STUFE " .. level .. " Regentanz") + u:add_order("ZAUBERE STUFE 3 Regentanz") assert_equal(0, r:get_resource("money"), 0) local m = 0 local p = 100 - for i=1,level+2 do - process_orders() - local income = p * 12 - p = r:get_resource("peasant") - income = income - p * 10 - m = m + income - -- print(i, m, p, r:get_resource("money")) - if (i>level+1) then - assert_not_equal(m, r:get_resource("money")) - else - assert_equal(m, r:get_resource("money")) - end - u:clear_orders() - u:add_order("ARBEITEN") - end + + process_orders() + assert_equal(200, r:get_resource("money")) + u:clear_orders() + u:add_order("ARBEITEN") + process_orders() + process_orders() + process_orders() + assert_equal(800, r:get_resource("money")) + process_orders() + assert_equal(900, r:get_resource("money")) end diff --git a/src/kernel/reports.c b/src/kernel/reports.c index 9282ee091..1154cb930 100644 --- a/src/kernel/reports.c +++ b/src/kernel/reports.c @@ -1606,7 +1606,7 @@ int write_reports(faction * f, time_t ltime) ctx.userdata = NULL; get_seen_interval(&ctx); get_addresses(&ctx); - + _mkdir(reportpath()); do { report_type *rtype = report_types; diff --git a/src/laws.c b/src/laws.c index abd02651e..02d8b448a 100755 --- a/src/laws.c +++ b/src/laws.c @@ -496,7 +496,7 @@ static void peasants(region * r) /* Bis zu 1000 Bauern können Zwillinge bekommen oder 1000 Bauern * wollen nicht! */ - if (peasants > 0) { + if (peasants > 0 && get_param_int(global.parameters, "rules.peasants.growth", 1)) { int glueck = 0; double fraction = peasants * 0.0001F * PEASANTGROWTH; int births = (int)fraction; @@ -938,9 +938,7 @@ void demographics(void) * und gewandert sind */ calculate_emigration(r); - if (get_param_int(global.parameters, "rules.peasants.growth", 1)) { - peasants(r); - } + peasants(r); if (r->age > 20) { plagues(r, false); }