2003-12-16 00:20:41 +01:00
|
|
|
function list_empty(list)
|
|
|
|
-- trickfunktion, die rausfindet, ob es schon eine partei gibt.
|
|
|
|
local _foo, _state, var_1 = list()
|
|
|
|
local begin = _foo(_state, var_1)
|
|
|
|
return begin == nil
|
|
|
|
end
|
|
|
|
|
|
|
|
function run_wdw()
|
|
|
|
-- load 'wdw-start', if it exists. otherwise, load the latest turn,
|
|
|
|
-- and make a backup called 'wdw-start'.
|
|
|
|
local file = "wdw-start"
|
|
|
|
local alliance, position, faction
|
|
|
|
if list_empty(factions) then
|
|
|
|
if read_game(file)~=0 then
|
|
|
|
local turnfile = "" .. get_turn()
|
|
|
|
if read_game(turnfile)~=0 then
|
|
|
|
print("could not read game")
|
|
|
|
return -1
|
|
|
|
end
|
|
|
|
if write_game(file)~=0 then
|
|
|
|
print("could not write game")
|
|
|
|
return -1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2003-12-18 00:11:52 +01:00
|
|
|
local outfile="wdw-setup"
|
2003-12-16 00:20:41 +01:00
|
|
|
-- run the alliances setup
|
|
|
|
if list_empty(alliances) then
|
|
|
|
dofile("wdw-setup.lua")
|
2003-12-18 00:11:52 +01:00
|
|
|
else
|
|
|
|
-- run the turn (not yet)
|
|
|
|
read_orders(orders)
|
|
|
|
process_orders()
|
|
|
|
outfile = "" .. get_turn()
|
2003-12-16 00:20:41 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
-- siegbedingungen ausgeben
|
|
|
|
dofile("wdw-standings.lua")
|
|
|
|
|
|
|
|
-- write out the initial reports (no need to run a turn)
|
|
|
|
write_passwords()
|
|
|
|
write_reports()
|
|
|
|
|
|
|
|
|
|
|
|
-- write the resulting file to 'wdw-setup'
|
2003-12-18 00:11:52 +01:00
|
|
|
if write_game(outfile)~=0 then
|
2003-12-16 00:20:41 +01:00
|
|
|
print("could not write game")
|
|
|
|
return -1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- main body of the script
|
|
|
|
run_wdw()
|