diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua index 651a9ad9b..705fd5013 100644 --- a/scripts/tests/e2/init.lua +++ b/scripts/tests/e2/init.lua @@ -1,3 +1,4 @@ +require 'tests.e2.production' require 'tests.e2.adamantium' require 'tests.e2.undead' require 'tests.e2.shiplanding' @@ -17,3 +18,4 @@ require 'tests.storage' require 'tests.magicbag' require 'tests.process' require 'tests.xmas' +require 'tests.production' diff --git a/scripts/tests/e2/production.lua b/scripts/tests/e2/production.lua new file mode 100644 index 000000000..c6d074f50 --- /dev/null +++ b/scripts/tests/e2/production.lua @@ -0,0 +1,63 @@ +require "lunit" + +module("tests.e2.production", package.seeall, lunit.testcase ) + +function setup() + eressea.game.reset() + eressea.settings.set("rules.food.flags", "4") -- food is free + eressea.settings.set("NewbieImmunity", "0") +end + +local function create_faction(race) + return faction.create(race .. '@eressea.de', race, "de") +end + +function test_greatbow_needs_elf() +-- only elves can build a greatbow + local r = region.create(0, 0, 'mountain') + local f = create_faction('human') + local u = unit.create(f, r, 1) + + turn_begin() + u:set_skill('weaponsmithing', 5) + u:add_item('mallorn', 2) + u:add_order("MACHE Elfenbogen") + turn_process() -- humans cannot do it + assert_equal(1, f:count_msg_type("error_cannotmake")) + assert_equal(0, u:get_item('greatbow')) + assert_equal(2, u:get_item('mallorn')) + + u.race = 'elf' + turn_process() -- but elves can + assert_equal(1, u:get_item('greatbow')) + assert_equal(0, u:get_item('mallorn')) +end + +function test_troll_quarrying_bonus() +-- Von Trollen abgebaute Steine werden nur zu 75% vom "Regionsvorrat" abgezogen. +-- Dieser Effekt ist kumulativ zu einem Steinbruch. + local r = region.create(0, 0, 'mountain') + local f = create_faction('human') + local u = unit.create(f, r, 1) + + turn_begin() + r:set_resource("stone", 100) + u:set_skill('quarrying', 4) + u:add_order("MACHE Steine") + turn_process() -- humans get no bonus + write_report(f) + assert_equal(4, u:get_item('stone')) + assert_equal(96, r:get_resource('stone')) + + u.race = 'troll' + u:set_skill('quarrying', 2) + turn_process() -- trolls have +2 to quarrying, and save 25% + assert_equal(8, u:get_item('stone')) + assert_equal(93, r:get_resource('stone')) +end + +function test_dwarf_mining_bonus() +-- Von Zwergen abgebautes Eisen wird nur zu 60% vom "Regionsvorrat" abgezogen. +-- Dieser Effekt ist kumulativ zu einem Bergwerk (siehe hier und hier). + +end diff --git a/scripts/tests/e3/init.lua b/scripts/tests/e3/init.lua index 146d8733d..389e9db90 100644 --- a/scripts/tests/e3/init.lua +++ b/scripts/tests/e3/init.lua @@ -1,4 +1,3 @@ -require 'tests.e3.production' require 'tests.e3.castles' require 'tests.e3.stealth' require 'tests.e3.spells' @@ -12,3 +11,4 @@ require 'tests.common' require 'tests.items' require 'tests.magicbag' require 'tests.process' +require 'tests.production' diff --git a/scripts/tests/e3/production.lua b/scripts/tests/production.lua similarity index 98% rename from scripts/tests/e3/production.lua rename to scripts/tests/production.lua index 9cffe056a..f797f3d32 100644 --- a/scripts/tests/e3/production.lua +++ b/scripts/tests/production.lua @@ -1,6 +1,6 @@ require "lunit" -module("tests.e3.production", package.seeall, lunit.testcase ) +module("tests.production", package.seeall, lunit.testcase ) function setup() eressea.game.reset()