From 9e2e7bfe972e19666c3757094e505141ec34c892 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 6 Jul 2014 01:13:09 -0700 Subject: [PATCH] test giving silver from the pool --- tests/init.lua | 1 + tests/pool.lua | 26 +++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/tests/init.lua b/tests/init.lua index f286cbcf7..a5c198203 100644 --- a/tests/init.lua +++ b/tests/init.lua @@ -1,4 +1,5 @@ -- new tests 2014-06-11 +require "tests.pool" require "tests.settings" require "tests.config" require "tests.locale" diff --git a/tests/pool.lua b/tests/pool.lua index 01f62420f..20d2ea0bb 100644 --- a/tests/pool.lua +++ b/tests/pool.lua @@ -10,7 +10,7 @@ function setup() eressea.settings.set("nmr.timeout", "0") conf = [[{ "races": { - "human" : {} + "human" : { "flags" : [ "giveitem", "getitem" ] } }, "terrains" : { "plain": { "flags" : [ "land" ] } @@ -19,6 +19,11 @@ function setup() "de" : { "give" : "GIB" } + }, + "strings" : { + "de" : { + "money" : "Silber" + } } }]] @@ -31,8 +36,23 @@ function test_give_nopool() local u1 = unit.create(f, r, 1) local u2 = unit.create(f, r, 1) u1:add_item("money", 100) - u1:add_order("GIB " .. itoa36(u2.id) .. " 100 SILBER") + u1:add_order("GIB " .. itoa36(u2.id) .. " 50 SILBER") + process_orders() + assert_equal(50, u1:get_item("money")) + assert_equal(50, u2:get_item("money")) +end + +function test_give_from_faction() + local r = region.create(1, 1, "plain") + local f = faction.create("test@example.com", "human", "de") + local u1 = unit.create(f, r, 1) + local u2 = unit.create(f, r, 1) + local u3 = unit.create(f, r, 1) + u1:add_item("money", 50) + u2:add_item("money", 50) + u1:add_order("GIB " .. itoa36(u3.id) .. " 100 SILBER") process_orders() assert_equal(0, u1:get_item("money")) - assert_equal(100, u2:get_item("money")) + assert_equal(0, u2:get_item("money")) + assert_equal(100, u3:get_item("money")) end