add tests for additional (race-related) production rules.

This commit is contained in:
Enno Rehling 2017-03-30 21:00:35 +02:00
parent e50d5a812e
commit 4115b321b3
4 changed files with 159 additions and 2 deletions

View File

@ -5536,8 +5536,8 @@
<arg name="region" type="region"/> <arg name="region" type="region"/>
<arg name="command" type="order"/> <arg name="command" type="order"/>
</type> </type>
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - Nur Elfen können diese Bögen herstellen."</text> <text locale="de">"$unit($unit) in $region($region): '$order($command)' - Diesen Gegenstand kann die Einheit nicht herstellen."</text>
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - Only elves can make these bows."</text> <text locale="en">"$unit($unit) in $region($region): '$order($command)' - This unit cannot produce that."</text>
</message> </message>
<message name="error116" section="errors"> <message name="error116" section="errors">
<type> <type>

View File

@ -59,5 +59,22 @@ end
function test_dwarf_mining_bonus() function test_dwarf_mining_bonus()
-- Von Zwergen abgebautes Eisen wird nur zu 60% vom "Regionsvorrat" abgezogen. -- Von Zwergen abgebautes Eisen wird nur zu 60% vom "Regionsvorrat" abgezogen.
-- Dieser Effekt ist kumulativ zu einem Bergwerk (siehe hier und hier). -- Dieser Effekt ist kumulativ zu einem Bergwerk (siehe hier und hier).
local r = region.create(0, 0, 'mountain')
local f = create_faction('human')
local u = unit.create(f, r, 1)
turn_begin()
r:set_resource('iron', 100)
u:set_skill('mining', 10)
u:add_order('MACHE Eisen')
turn_process() -- humans get no bonus
write_report(f)
assert_equal(10, u:get_item('iron'))
assert_equal(90, r:get_resource('iron'))
u.race = 'dwarf'
u:set_skill('mining', 8)
turn_process() -- dwarves have +2 to mining, and save 40%
assert_equal(20, u:get_item('iron'))
assert_equal(84, r:get_resource('iron'))
end end

View File

@ -11,4 +11,5 @@ require 'tests.common'
require 'tests.items' require 'tests.items'
require 'tests.magicbag' require 'tests.magicbag'
require 'tests.process' require 'tests.process'
require 'tests.e3.production'
require 'tests.production' require 'tests.production'

View File

@ -0,0 +1,139 @@
require "lunit"
module("tests.e3.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, race .. '@example.com', "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("error118"))
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_no_quarrying_bonus()
-- Trolle kriegen keinen Rohstoffbonus wie in E2
local r = region.create(0, 0, 'mountain')
local f = create_faction('troll')
local u = unit.create(f, r, 1)
turn_begin()
r:set_resource("stone", 100)
u:set_skill('quarrying', 2) -- +2 Rassenbonus
u:add_order("MACHE Steine")
turn_process()
write_report(f)
assert_equal(4, u:get_item('stone'))
assert_equal(96, r:get_resource('stone'))
end
function test_dwarf_no_mining_bonus()
-- E3: Zwerge verlieren den Eisenabbaubonus
local r = region.create(0, 0, 'mountain')
local f = create_faction('dwarf')
local u = unit.create(f, r, 1)
turn_begin()
r:set_resource('iron', 100)
u:set_skill('mining', 8) -- +2 skill bonus
u:add_order('MACHE Eisen')
turn_process()
write_report(f)
assert_equal(10, u:get_item('iron'))
assert_equal(90, r:get_resource('iron'))
end
function test_dwarf_towershield()
-- Zwerge können als einzige Rasse Turmschilde, Schuppenpanzer
-- und Repetierarmbrüste bauen.
local r = region.create(0, 0, 'plain')
local f = create_faction('human')
local u = unit.create(f, r, 1)
turn_begin()
u:set_skill('armorer', 4)
u:add_item('iron', 1)
u:add_order("MACHE Turmschild")
turn_process() -- humans cannot do it
assert_equal(1, f:count_msg_type("error118"))
assert_equal(0, u:get_item('towershield'))
assert_equal(1, u:get_item('iron'))
u.race = 'dwarf'
u:set_skill('armorer', 2) -- dwarf has bonus +2
turn_process() -- but dwarves can
assert_equal(1, u:get_item('towershield'))
assert_equal(0, u:get_item('iron'))
end
function test_dwarf_scale()
-- Zwerge können als einzige Rasse Turmschilde, Schuppenpanzer
-- und Repetierarmbrüste bauen.
local r = region.create(0, 0, 'plain')
local f = create_faction('human')
local u = unit.create(f, r, 1)
turn_begin()
u:set_skill('armorer', 5)
u:add_item('iron', 2)
u:add_order("MACHE Schuppenpanzer")
turn_process() -- humans cannot do it
assert_equal(1, f:count_msg_type("error118"))
assert_equal(0, u:get_item('scale'))
assert_equal(2, u:get_item('iron'))
u.race = 'dwarf'
u:set_skill('armorer', 3) -- dwarf has bonus +2
turn_process() -- but dwarves can
assert_equal(1, u:get_item('scale'))
assert_equal(0, u:get_item('iron'))
end
function test_dwarf_rep_xbow()
-- Zwerge können als einzige Rasse Turmschilde, Schuppenpanzer
-- und Repetierarmbrüste bauen.
local r = region.create(0, 0, 'plain')
local f = create_faction('human')
local u = unit.create(f, r, 1)
turn_begin()
u:set_skill('weaponsmithing', 5)
u:add_item('iron', 1)
u:add_item('log', 1)
u:add_order("MACHE Repetierarmbrust")
turn_process() -- humans cannot do it
assert_equal(1, f:count_msg_type("error118"))
assert_equal(0, u:get_item('rep_crossbow'))
assert_equal(1, u:get_item('iron'))
assert_equal(1, u:get_item('log'))
u.race = 'dwarf'
u:set_skill('weaponsmithing', 3) -- dwarf has bonus +2
turn_process() -- but dwarves can
assert_equal(1, u:get_item('rep_crossbow'))
assert_equal(0, u:get_item('iron'))
assert_equal(0, u:get_item('log'))
end