From c634a01a3ff629e286ec2d4a8137bf1cd60dff87 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 1 Jul 2015 22:13:24 +0200 Subject: [PATCH] Bug 1949: Zauberbeutelverhalten (magic bag tests & config changes) https://bugs.eressea.de/view.php?id=1949 --- res/core/resources/cart.xml | 4 +-- res/core/weapons/catapult.xml | 2 +- scripts/tests/e2/init.lua | 1 + scripts/tests/e3/init.lua | 1 + scripts/tests/magicbag.lua | 50 +++++++++++++++++++++++++++++++++++ 5 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 scripts/tests/magicbag.lua diff --git a/res/core/resources/cart.xml b/res/core/resources/cart.xml index a72b222d3..af3860c9c 100644 --- a/res/core/resources/cart.xml +++ b/res/core/resources/cart.xml @@ -1,6 +1,6 @@ - - + + diff --git a/res/core/weapons/catapult.xml b/res/core/weapons/catapult.xml index 2ea16d9a2..08dc83457 100644 --- a/res/core/weapons/catapult.xml +++ b/res/core/weapons/catapult.xml @@ -1,6 +1,6 @@ - + diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua index 322e87195..2f69f6a71 100644 --- a/scripts/tests/e2/init.lua +++ b/scripts/tests/e2/init.lua @@ -6,3 +6,4 @@ require 'tests.e2.stealth' require 'tests.orders' require 'tests.common' require 'tests.storage' +require 'tests.magicbag' diff --git a/scripts/tests/e3/init.lua b/scripts/tests/e3/init.lua index 63c26cacf..2a31be599 100644 --- a/scripts/tests/e3/init.lua +++ b/scripts/tests/e3/init.lua @@ -6,3 +6,4 @@ require 'tests.e3.parser' require 'tests.e3.morale' require 'tests.orders' require 'tests.common' +require 'tests.magicbag' diff --git a/scripts/tests/magicbag.lua b/scripts/tests/magicbag.lua new file mode 100644 index 000000000..e0b294cfd --- /dev/null +++ b/scripts/tests/magicbag.lua @@ -0,0 +1,50 @@ +require "lunit" + +module("tests.magicbag", package.seeall, lunit.testcase) + +local u + +function setup() + eressea.free_game() + u = unit.create(faction.create("test@example.com", "human", "de"), region.create(0, 0, "plain"), 1) +end + +function test_magicbag_weight() + assert_equal(1000, u.weight) + u:add_item("log", 10) + assert_equal(6000, u.weight) + u:add_item("magicbag", 1) + assert_equal(1100, u.weight) +end + +function test_magicbag_no_stone() + assert_equal(1000, u.weight) + u:add_item("stone", 1) + assert_equal(7000, u.weight) + u:add_item("magicbag", 1) + assert_equal(7100, u.weight) +end + +function test_magicbag_no_carts() + assert_equal(1000, u.weight) + u:add_item("cart", 1) + assert_equal(5000, u.weight) + u:add_item("magicbag", 1) + assert_equal(5100, u.weight) +end + +function test_magicbag_no_catapult() + assert_equal(1000, u.weight) + u:add_item("catapult", 1) + assert_equal(11000, u.weight) + u:add_item("magicbag", 1) + assert_equal(11100, u.weight) +end + +function test_magicbag_no_horses() + assert_equal(1000, u.weight) + u:add_item("horse", 1) + assert_equal(6000, u.weight) + u:add_item("magicbag", 1) + assert_equal(6100, u.weight) +end