diff --git a/scripts/tests/e2/buildings.lua b/scripts/tests/e2/buildings.lua new file mode 100644 index 000000000..4797643e1 --- /dev/null +++ b/scripts/tests/e2/buildings.lua @@ -0,0 +1,53 @@ +require "lunit" + +module("tests.e2.buildings", package.seeall, lunit.testcase ) + +function setup() + eressea.game.reset() + eressea.settings.set("rules.food.flags", "4") +end + +function teardown() + eressea.settings.set("rules.food.flags", "0") +end + +function test_castle_names() + local r = region.create(0, 0, "plain") + local b = building.create(r, "castle") + + assert_equal("site", b:get_typename(1)) + assert_equal("tradepost", b:get_typename(2)) + assert_equal("tradepost", b:get_typename(9)) + assert_equal("fortification", b:get_typename(10)) + assert_equal("fortification", b:get_typename(49)) + assert_equal("tower", b:get_typename(50)) + assert_equal("tower", b:get_typename(249)) + assert_equal("castle", b:get_typename(250)) + assert_equal("castle", b:get_typename(1249)) + assert_equal("fortress", b:get_typename(1250)) + assert_equal("fortress", b:get_typename(6249)) + assert_equal("citadel", b:get_typename(6250)) +end + +function test_build_castle_stages() + local r = region.create(0,0, "plain") + local f = faction.create("human") + local u = unit.create(f, r, 1000) + local b = building.create(r, "castle") + + u:add_item("stone", 1000) + + u:set_skill("building", 1) + u:clear_orders() + + u:add_order("MACHE BURG " .. itoa36(b.id)) + process_orders() + assert_equal(10, b.size) + + u:set_skill("building", 3) + u:clear_orders() + + u:add_order("MACHE BURG " .. itoa36(b.id)) + process_orders() + assert_equal(250, b.size) +end diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua index 705fd5013..46afc966a 100644 --- a/scripts/tests/e2/init.lua +++ b/scripts/tests/e2/init.lua @@ -1,3 +1,4 @@ +require 'tests.e2.buildings' require 'tests.e2.production' require 'tests.e2.adamantium' require 'tests.e2.undead' diff --git a/scripts/tests/e3/castles.lua b/scripts/tests/e3/buildings.lua similarity index 80% rename from scripts/tests/e3/castles.lua rename to scripts/tests/e3/buildings.lua index c5641c68e..709e7df74 100644 --- a/scripts/tests/e3/castles.lua +++ b/scripts/tests/e3/buildings.lua @@ -1,6 +1,6 @@ require "lunit" -module("tests.e3.castles", package.seeall, lunit.testcase ) +module("tests.e3.buildings", package.seeall, lunit.testcase ) function setup() eressea.game.reset() @@ -11,6 +11,23 @@ function teardown() eressea.settings.set("rules.food.flags", "0") end +function test_castle_names() + local r = region.create(0, 0, "plain") + local b = building.create(r, "castle") + + assert_equal("site", b:get_typename(1)) + assert_equal("site", b:get_typename(9)) + assert_equal("fortification", b:get_typename(10)) + assert_equal("fortification", b:get_typename(49)) + assert_equal("tower", b:get_typename(50)) + assert_equal("tower", b:get_typename(249)) + assert_equal("castle", b:get_typename(250)) + assert_equal("castle", b:get_typename(1249)) + assert_equal("fortress", b:get_typename(1250)) + assert_equal("fortress", b:get_typename(6249)) + assert_equal("citadel", b:get_typename(6250)) +end + function test_build_watch() local r = region.create(0, 0, "plain") local f = faction.create("human", "e3build@eressea.de", "de") @@ -33,7 +50,7 @@ function test_build_watch() assert_equal(10, u.building.size) end -function test_watch() +function test_watch_names() local r = region.create(0, 0, "plain") local b = building.create(r, "watch") diff --git a/scripts/tests/e3/init.lua b/scripts/tests/e3/init.lua index 6094d0a25..06e03d9b4 100644 --- a/scripts/tests/e3/init.lua +++ b/scripts/tests/e3/init.lua @@ -1,4 +1,4 @@ -require 'tests.e3.castles' +require 'tests.e3.buildings' require 'tests.e3.stealth' require 'tests.e3.spells' require 'tests.e3.rules'