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 "spells"
require "extensions" 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() function run_tests()
print("running tests") print("running tests")
require "lunit" require "lunit"
lunit.clearstats() lunit.clearstats()
local argv = tests or {} local argv = tests or {}
local stats = lunit.main(argv) local stats = lunit.main(argv)
if stats.errors > 0 or stats.failed > 0 then if stats.errors > 0 or stats.failed > 0 then
return 1 return 1
end end
return 0 return 0
end end
function run_turn() function run_turn()
require "run-e3a" require "run-e3a"
-- the locales that this gameworld supports. -- the locales that this gameworld supports.
local locales = { "de", "en" } local locales = { "de", "en" }
local confirmed_multis = { local confirmed_multis = {
} }
local suspected_multis = { local suspected_multis = {
"odin" "odin"
} }
local turn = get_turn() local turn = get_turn()
if turn==0 then if turn==0 then
turn = read_turn() turn = read_turn()
set_turn(turn) set_turn(turn)
end end
orderfile = orderfile or basepath .. '/orders.' .. turn orderfile = orderfile or basepath .. '/orders.' .. turn
print("executing turn " .. get_turn() .. " with " .. orderfile) print("executing turn " .. get_turn() .. " with " .. orderfile)
process(orderfile, confirmed_multis, suspected_multis, locales) process(orderfile, confirmed_multis, suspected_multis, locales)
dbupdate() dbupdate()
return 0 return 0
end end

View File

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

View File

@ -2,6 +2,36 @@ require "lunit"
module( "e3", package.seeall, lunit.testcase ) 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() function test_owners()
free_game() free_game()
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")