added a test to ensure ship capactiy cannot be exceeded. it fails

This commit is contained in:
Enno Rehling 2009-12-13 19:54:53 +00:00
parent de80f1f426
commit 3a57fedecb
3 changed files with 72 additions and 31 deletions

View File

@ -4,39 +4,49 @@ require "default"
require "spells"
require "extensions"
function run_editor()
local turn = get_turn()
if turn==0 then
turn = read_turn()
set_turn(turn)
end
read_game(turn .. ".dat")
gmtool.editor()
end
function run_tests()
print("running tests")
require "lunit"
lunit.clearstats()
local argv = tests or {}
local stats = lunit.main(argv)
if stats.errors > 0 or stats.failed > 0 then
return 1
end
return 0
print("running tests")
require "lunit"
lunit.clearstats()
local argv = tests or {}
local stats = lunit.main(argv)
if stats.errors > 0 or stats.failed > 0 then
return 1
end
return 0
end
function run_turn()
require "run-e3a"
-- the locales that this gameworld supports.
local locales = { "de", "en" }
local confirmed_multis = {
}
local suspected_multis = {
"odin"
}
local turn = get_turn()
if turn==0 then
turn = read_turn()
set_turn(turn)
end
orderfile = orderfile or basepath .. '/orders.' .. turn
print("executing turn " .. get_turn() .. " with " .. orderfile)
process(orderfile, confirmed_multis, suspected_multis, locales)
dbupdate()
return 0
require "run-e3a"
-- the locales that this gameworld supports.
local locales = { "de", "en" }
local confirmed_multis = {
}
local suspected_multis = {
"odin"
}
local turn = get_turn()
if turn==0 then
turn = read_turn()
set_turn(turn)
end
orderfile = orderfile or basepath .. '/orders.' .. turn
print("executing turn " .. get_turn() .. " with " .. orderfile)
process(orderfile, confirmed_multis, suspected_multis, locales)
dbupdate()
return 0
end

View File

@ -197,6 +197,7 @@ end
-- main body of script
--
function dbupdate()
update_scores()
edb = db.open(basepath.."/eressea.db")
edb:update_factions()
edb:update_scores()

View File

@ -2,6 +2,36 @@ require "lunit"
module( "e3", package.seeall, lunit.testcase )
function setup()
free_game()
end
function test_capacity()
local r = region.create(0,0, "ocean")
local r2 = region.create(1,0, "ocean")
local f = faction.create("noreply@eressea.de", "human", "de")
local s1 = ship.create(r, "cutter")
local u1 = unit.create(f, r, 5)
u1.ship = s1
u1:set_skill("sailing", 10)
u1:clear_orders()
u1:add_order("NACH O")
local s2 = ship.create(r, "cutter")
local u2 = unit.create(f, r, 6)
u2.ship = s2
u2:set_skill("sailing", 10)
u2:clear_orders()
u2:add_order("NACH O")
update_owners()
process_orders()
-- print(s.region, u.region, r2)
assert_equal(r2.id, u1.region.id)
assert_equal(r.id, u2.region.id)
end
function test_owners()
free_game()
local r = region.create(0, 0, "plain")