From 235c7df5898af5c990568c962c499a278b64d5f9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 10 Mar 2010 21:01:55 -0800 Subject: [PATCH] =?UTF-8?q?http://bugs.eressea.de/view.php=3Fid=3D1728=20"?= =?UTF-8?q?E3=20Personen=20wurden=20=C3=BCbergeben"=20changed=20configurat?= =?UTF-8?q?ion=20and=20added=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- res/config-e3a.xml | 1 + scripts/tests/e3a.lua | 45 ++++++++++++++++++++++++++++++++------- scripts/tests/eressea.lua | 21 +++++++++++++++++- 3 files changed, 58 insertions(+), 9 deletions(-) diff --git a/res/config-e3a.xml b/res/config-e3a.xml index 32f994fdd..bd0da1f4e 100644 --- a/res/config-e3a.xml +++ b/res/config-e3a.xml @@ -130,6 +130,7 @@ + diff --git a/scripts/tests/e3a.lua b/scripts/tests/e3a.lua index e51962278..da380c6a5 100644 --- a/scripts/tests/e3a.lua +++ b/scripts/tests/e3a.lua @@ -189,7 +189,6 @@ function test_ship_capacity() end function test_owners() - free_game() local r = region.create(0, 0, "plain") local f1 = faction.create("noreply@eressea.de", "human", "de") local u1 = unit.create(f1, r, 1) @@ -219,7 +218,6 @@ function test_owners() end function test_taxes() - free_game() local r = region.create(0, 0, "plain") r:set_resource("peasant", 1000) r:set_resource("money", 5000) @@ -238,7 +236,6 @@ function test_taxes() end function test_leave() - free_game() local r = region.create(0, 0, "plain") local f = faction.create("noreply@eressea.de", "human", "de") f.id = 42 @@ -260,7 +257,6 @@ end function test_market() -- if i am the only trader around, i should be getting all the herbs from all 7 regions local herb_multi = 500 -- from rc_herb_trade() - free_game() local r, idx local herbnames = { 'h0', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'h7', 'h8' } idx = 1 @@ -297,7 +293,6 @@ function test_market() end function test_market_gives_items() - free_game() local r for x = -1, 1 do for y = -1, 1 do r = region.create(x, y, "plain") @@ -323,7 +318,6 @@ function test_market_gives_items() end function test_spells() - free_game() local r = region.create(0, 0, "plain") local f = faction.create("noreply@eressea.de", "human", "de") local u = unit.create(f, r, 1) @@ -353,7 +347,6 @@ function test_spells() end function test_alliance() - free_game() local r = region.create(0, 0, "plain") local f1 = faction.create("noreply@eressea.de", "human", "de") local u1 = unit.create(f1, r, 1) @@ -484,7 +477,6 @@ function test_give_50_percent_of_money() end function test_give_100_percent_of_items() - free_game() local u1, u2 = two_units(region.create(0, 0, "plain"), two_factions()) local r = u2.region u1.faction.age = 10 @@ -501,3 +493,40 @@ function test_give_100_percent_of_items() assert_equal(m1-332, u1:get_item("log")) assert_equal(m2+332, u2:get_item("log")) end + +function test_cannot_give_person() + local r = region.create(0, 0, "plain") + local f1 = faction.create("noreply@eressea.de", "human", "de") + local f2 = faction.create("noreply@eressea.de", "human", "de") + local u1 = unit.create(f1, r, 10) + local u2 = unit.create(f2, r, 10) + u1.faction.age = 10 + u2.faction.age = 10 + u1:add_item("money", 500) + u2:add_item("money", 500) + u2:clear_orders() + u2:add_order("GIB ".. itoa36(u1.id) .. " 1 PERSON") + u2:add_order("HELFE ".. itoa36(f1.id) .. " GIB") + u1:add_order("HELFE ".. itoa36(f2.id) .. " GIB") + process_orders() + assert_equal(10, u2.number) + assert_equal(10, u1.number) +end + +function test_cannot_give_unit() + local r = region.create(0, 0, "plain") + local f1 = faction.create("noreply@eressea.de", "human", "de") + local f2 = faction.create("noreply@eressea.de", "human", "de") + local u1 = unit.create(f1, r, 10) + local u2 = unit.create(f2, r, 10) + u1.faction.age = 10 + u2.faction.age = 10 + u1:add_item("money", 500) + u2:add_item("money", 500) + u2:clear_orders() + u2:add_order("GIB ".. itoa36(u1.id) .. " EINHEIT") + u2:add_order("HELFE ".. itoa36(f1.id) .. " GIB") + u1:add_order("HELFE ".. itoa36(f2.id) .. " GIB") + process_orders() + assert_not_equal(u2.faction.id, u1.faction.id) +end diff --git a/scripts/tests/eressea.lua b/scripts/tests/eressea.lua index a213d3257..96874a1e6 100644 --- a/scripts/tests/eressea.lua +++ b/scripts/tests/eressea.lua @@ -84,7 +84,7 @@ function test_ship_capacity() assert_not_equal(r2.id, u2.region.id, "boat with too many people has moved") assert_not_equal(r2.id, u4.region.id, "boat with too much cargo has moved") end - + function test_levitate() local r = region.create(0,0, "plain") local f = faction.create("noreply@eressea.de", "human", "de") @@ -117,3 +117,22 @@ function test_races() assert_not_equal(nil, f) end end + +function test_can_give_person() + local r = region.create(0, 0, "plain") + local f1 = faction.create("noreply@eressea.de", "human", "de") + local f2 = faction.create("noreply@eressea.de", "human", "de") + local u1 = unit.create(f1, r, 10) + local u2 = unit.create(f2, r, 10) + u1.faction.age = 10 + u2.faction.age = 10 + u1:add_item("money", 500) + u2:add_item("money", 500) + u2:clear_orders() + u2:add_order("GIB ".. itoa36(u1.id) .. " 1 PERSON") + u2:add_order("HELFE ".. itoa36(f1.id) .. " GIB") + u1:add_order("HELFE ".. itoa36(f2.id) .. " GIB") + process_orders() + assert_equal(9, u2.number) + assert_equal(11, u1.number) +end