diff --git a/scripts/tests/e3/items.lua b/scripts/tests/e3/items.lua index d916be744..caf566468 100644 --- a/scripts/tests/e3/items.lua +++ b/scripts/tests/e3/items.lua @@ -23,7 +23,6 @@ end function test_goblins() local r = region.create(0, 0, "plain") - assert(r) local f1 = faction.create("goblin@eressea.de", "goblin", "de") local f2 = faction.create("dwarf@eressea.de", "dwarf", "de") local f3 = faction.create("elf@eressea.de", "elf", "de") @@ -51,3 +50,27 @@ function test_goblins() ud:add_order("ATTACKIERE " .. itoa36(u3.id)) process_orders() end + +function test_make_horse() + eressea.settings.set("rules.horses.growth", "0") + local r = region.create(0, 0, "plain") + local f = faction.create("horses@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + u:set_skill("training", 4) + r:set_resource("horse", 100) + u:add_order("MACHE 1 PFERD") + process_orders() + assert_equal(1, u:get_item("horse")) + assert_equal(99, r:get_resource("horse")) + + u:clear_orders() + u:add_order("MACHE 1 STREITROSS") + u:add_item("money", 200) + u:add_item("iron", 1) + process_orders() + assert_equal(1, u:get_item("charger")) + assert_equal(0, u:get_item("horse")) + assert_equal(0, u:get_item("iron")) + assert_equal(0, u:get_item("money")) + assert_equal(99, r:get_resource("horse")) +end diff --git a/src/laws.c b/src/laws.c index cc10baeb5..b8291440f 100644 --- a/src/laws.c +++ b/src/laws.c @@ -333,7 +333,7 @@ int peasant_luck_effect(int peasants, int luck, int maxp, double variance) #endif -static void peasants(region * r) +static void peasants(region * r, int rule) { int peasants = rpeasants(r); int money = rmoney(r); @@ -341,7 +341,7 @@ static void peasants(region * r) int n, satiated; int dead = 0; - if (peasants > 0 && config_get_int("rules.peasants.growth", 1)) { + if (peasants > 0 && rule > 0) { int luck = 0; double fraction = peasants * peasant_growth_factor(); int births = RAND_ROUND(fraction); @@ -812,6 +812,8 @@ void demographics(void) static int last_weeks_season = -1; static int current_season = -1; int plant_rules = config_get_int("rules.grow.formula", 2); + int horse_rules = config_get_int("rules.horses.growth", 1); + int peasant_rules = config_get_int("rules.peasants.growth", 1); const struct building_type *bt_harbour = bt_find("harbour"); if (current_season < 0) { @@ -843,7 +845,8 @@ void demographics(void) * und gewandert sind */ calculate_emigration(r); - peasants(r); + peasants(r, peasant_rules); + if (r->age > 20) { double mwp = MAX(region_maxworkers(r), 1); double prob = @@ -854,7 +857,9 @@ void demographics(void) plagues(r); } } - horses(r); + if (horse_rules > 0) { + horses(r); + } if (plant_rules == 2) { /* E2 */ growing_trees(r, current_season, last_weeks_season); growing_herbs(r, current_season, last_weeks_season);