2010-08-08 10:06:34 +02:00
|
|
|
require(config.game .. ".modules")
|
|
|
|
require "default"
|
|
|
|
require "resources"
|
|
|
|
|
|
|
|
function run_editor()
|
|
|
|
local turn = get_turn()
|
2014-04-25 07:47:23 +02:00
|
|
|
if turn<0 then
|
2010-08-08 10:06:34 +02:00
|
|
|
turn = read_turn()
|
|
|
|
set_turn(turn)
|
|
|
|
end
|
2012-06-07 18:47:02 +02:00
|
|
|
eressea.read_game(turn .. ".dat")
|
2010-08-08 10:06:34 +02:00
|
|
|
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
|
2014-03-02 19:55:35 +01:00
|
|
|
assert(stats.errors == 0 and stats.failed == 0)
|
2010-08-08 10:06:34 +02:00
|
|
|
end
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
|
|
|
|
function run_turn()
|
|
|
|
require(config.game .. ".main")
|
|
|
|
|
|
|
|
local turn = get_turn()
|
2014-04-25 07:47:23 +02:00
|
|
|
if turn<0 then
|
2010-08-08 10:06:34 +02:00
|
|
|
turn = read_turn()
|
|
|
|
set_turn(turn)
|
|
|
|
end
|
|
|
|
|
|
|
|
orderfile = orderfile or config.basepath .. '/orders.' .. turn
|
|
|
|
print("executing turn " .. get_turn() .. " with " .. orderfile)
|
|
|
|
local result = process(orderfile)
|
|
|
|
if result==0 then
|
|
|
|
dbupdate()
|
|
|
|
end
|
|
|
|
return result
|
|
|
|
end
|