Merge pull request #246 from badgerman/develop

Bug 2080: improved tests for DESTROY, fix destroy-after-attack
This commit is contained in:
Enno Rehling 2015-07-03 14:06:24 +02:00
commit 9a9efe305d
4 changed files with 52 additions and 14 deletions

View File

@ -0,0 +1,46 @@
require "lunit"
module("tests.e2.destroy", package.seeall, lunit.testcase)
function setup()
eressea.free_game()
eressea.settings.set("NewbieImmunity", "0")
end
function test_dont_move_after_destroy()
local r1 = region.create(0, 0, "plain")
local r2 = region.create(1, 0, "plain")
local f = faction.create("test@example.com", "human", "de")
local u = unit.create(f, r1, 1)
u.building = building.create(u.region, "castle")
u:clear_orders()
u:add_order("NACH O")
u:add_order("ZERSTOERE " .. itoa36(u.building.id))
process_orders()
assert_equal(r1, u.region)
assert_equal(nil, u.building)
end
function test_dont_destroy_after_attack()
local r1 = region.create(0, 0, "plain")
local u = unit.create(faction.create("one@example.com", "human", "de"), r1, 10)
local u2 = unit.create(faction.create("two@example.com", "human", "de"), r1, 1)
u.building = building.create(u.region, "castle")
u:clear_orders()
u:add_order("ATTACKIERE " .. itoa36(u2.id))
u:add_order("ZERSTOERE " .. itoa36(u.building.id))
process_orders()
assert_not_nil(u.building)
end
function test_destroy_is_long()
local r1 = region.create(0, 0, "plain")
local u = unit.create(faction.create("one@example.com", "human", "de"), r1, 10)
u.building = building.create(u.region, "castle")
u:clear_orders()
u:add_order("LERNE Unterhaltung")
u:add_order("ZERSTOERE " .. itoa36(u.building.id))
process_orders()
assert_equal(0, u:get_skill("entertainment"))
assert_equal(nil, u.building)
end

View File

@ -2,6 +2,7 @@ require 'tests.e2.undead'
require 'tests.e2.shiplanding' require 'tests.e2.shiplanding'
require 'tests.e2.e2features' require 'tests.e2.e2features'
require 'tests.e2.movement' require 'tests.e2.movement'
require 'tests.e2.destroy'
require 'tests.e2.guard' require 'tests.e2.guard'
require 'tests.e2.stealth' require 'tests.e2.stealth'
require 'tests.orders' require 'tests.orders'

View File

@ -84,17 +84,3 @@ function test_follow_ship()
assert_equal(2, u1.region.x) assert_equal(2, u1.region.x)
assert_equal(2, u2.region.x) assert_equal(2, u2.region.x)
end end
function test_dont_move_after_destroy()
local r1 = region.create(0, 0, "plain")
local r2 = region.create(1, 0, "plain")
local f = faction.create("test@example.com", "human", "de")
local u = unit.create(f, r1, 1)
u.building = building.create(r1, "castle")
u:clear_orders()
u:add_order("NACH O")
u:add_order("ZERSTOERE " .. itoa36(u.building.id))
process_orders()
assert_equal(r1, u.region)
assert_equal(nil, u.building)
end

View File

@ -153,6 +153,11 @@ int destroy_cmd(unit * u, struct order *ord)
if (u->number < 1) if (u->number < 1)
return 0; return 0;
if (fval(u, UFL_LONGACTION)) {
cmistake(u, ord, 52, MSG_PRODUCE);
return 0;
}
init_order(ord); init_order(ord);
s = gettoken(token, sizeof(token)); s = gettoken(token, sizeof(token));