diff --git a/res/e3a/races.xml b/res/e3a/races.xml index 8b0cfae6d..349b60a09 100644 --- a/res/e3a/races.xml +++ b/res/e3a/races.xml @@ -783,7 +783,7 @@ - + diff --git a/res/eressea/races.xml b/res/eressea/races.xml index 986e2b85f..56c0c541b 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -1031,7 +1031,7 @@ - + diff --git a/scripts/tests/e2/e2features.lua b/scripts/tests/e2/e2features.lua index 1a4047d63..ffe3266e3 100644 --- a/scripts/tests/e2/e2features.lua +++ b/scripts/tests/e2/e2features.lua @@ -408,3 +408,19 @@ end function test_calendar_season_2328() assert_equal("fall", get_season(1026)) end + +function test_give_to_other_okay() + -- can give a person to another faction + eressea.settings.set("GiveRestriction", "0") + local r = region.create(0, 0, "plain") + local f1 = faction.create("human") + local f2 = faction.create("human") + + local u1 = unit.create(f1, r, 2, "human") + local u2 = unit.create(f2, r, 1, "human") + u2:add_order("KONTAKTIERE " .. itoa36(u1.id)) + u1:add_order("GIB " .. itoa36(u2.id) .. " 1 PERSON") + process_orders() + assert_equal(1, u1.number) + assert_equal(2, u2.number) +end diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua index 7fbc0eb95..fd2f0b423 100644 --- a/scripts/tests/e2/init.lua +++ b/scripts/tests/e2/init.lua @@ -21,3 +21,4 @@ require 'tests.process' require 'tests.xmas' require 'tests.production' require 'tests.spells' +require 'tests.undead' diff --git a/scripts/tests/e3/init.lua b/scripts/tests/e3/init.lua index fc0586f89..04b7da4a2 100644 --- a/scripts/tests/e3/init.lua +++ b/scripts/tests/e3/init.lua @@ -14,3 +14,4 @@ require 'tests.items' require 'tests.magicbag' require 'tests.process' require 'tests.production' +require 'tests.undead' diff --git a/scripts/tests/e3/rules.lua b/scripts/tests/e3/rules.lua index 7eb2f13a3..92e02f29b 100644 --- a/scripts/tests/e3/rules.lua +++ b/scripts/tests/e3/rules.lua @@ -991,3 +991,20 @@ function test_bug2187() set_rule("rules.food.flags", "4") end + + +function test_give_to_other_fails() + -- E3: cannot give a person to another faction + local r = region.create(0, 0, "plain") + local f1 = faction.create("human") + local f2 = faction.create("human") + + local u1 = unit.create(f1, r, 2, "human") + local u2 = unit.create(f2, r, 1, "human") + -- u2:add_order("HELFE " .. itoa36(f1.id) .. " GIB") + u2:add_order("KONTAKTIERE " .. itoa36(u1.id)) + u1:add_order("GIB " .. itoa36(u2.id) .. " 1 PERSON") + process_orders() + assert_equal(2, u1.number) + assert_equal(1, u2.number) +end diff --git a/scripts/tests/undead.lua b/scripts/tests/undead.lua new file mode 100644 index 000000000..1ed94620b --- /dev/null +++ b/scripts/tests/undead.lua @@ -0,0 +1,66 @@ +require "lunit" + +module("tests.undead", package.seeall, lunit.testcase) + +function setup() + eressea.free_game() + eressea.settings.set("nmr.timeout", "0") + eressea.settings.set("NewbieImmunity", "0") + eressea.settings.set("rules.food.flags", "4") + eressea.settings.set("rules.encounters", "0") + eressea.settings.set("rules.peasants.growth", "1") + eressea.settings.set("study.random_progress", "0") + eressea.settings.set("GiveRestriction", "0") +end + +function test_give_undead_to_self() + -- generic undead cannot be given + local r = region.create(0, 0, "plain") + local f = faction.create("human") + local u1 = unit.create(f, r, 2, "undead") + local u2 = unit.create(f, r, 1, "undead") + u1:add_order("GIB " .. itoa36(u2.id) .. " 1 PERSON") + process_orders() + assert_equal(2, u1.number) + assert_equal(1, u2.number) +end + +function test_give_self_undead_fail() + -- disallow giving basic undead units + local r = region.create(0, 0, "plain") + local f = faction.create("human") + local u1 = unit.create(f, r, 2, "undead") + local u2 = unit.create(f, r, 1, "undead") + u1:add_order("GIB " .. itoa36(u2.id) .. " 1 PERSON") + process_orders() + assert_equal(2, u1.number) + assert_equal(1, u2.number) +end + +function test_give_other_zombie_fail() + -- cannot give undead units to another faction + local r = region.create(0, 0, "plain") + local f1 = faction.create("human") + local f2 = faction.create("human") + + local u1 = unit.create(f1, r, 2, "zombie") + local u2 = unit.create(f2, r, 1, "zombie") + u2:add_order("KONTAKTIERE " .. itoa36(u1.id)) + u1:add_order("GIB " .. itoa36(u2.id) .. " 1 PERSON") + -- TODO: Migranten blockieren das derzeit, nicht Untoten-Eigenschaften + process_orders() + assert_equal(2, u1.number) + assert_equal(1, u2.number) +end + +function test_give_self_zombie_okay() + -- allow giving undead units to own units of same race + local r = region.create(0, 0, "plain") + local f = faction.create("human") + local u1 = unit.create(f, r, 2, "zombie") + local u2 = unit.create(f, r, 1, "zombie") + u1:add_order("GIB " .. itoa36(u2.id) .. " 1 PERSON") + process_orders() + assert_equal(1, u1.number) + assert_equal(2, u2.number) +end