server/src/scripts/wdw-run.lua

81 lines
1.5 KiB
Lua
Raw Normal View History

2004-08-21 14:02:45 +02:00
function process(orders)
-- read game and orders
2003-12-28 16:30:43 +01:00
local turnfile = "" .. get_turn()
if read_game(turnfile)~=0 then
print("could not read game")
return -1
end
init_summary()
2004-08-21 14:02:45 +02:00
-- read the orders file
read_orders(orders)
-- set up the sphinx
-- init_sphinxhints()
update_phoenix()
sphinx_handler()
2004-08-21 14:02:45 +02:00
sphinx_weekly()
-- run the turn:
plan_monsters()
process_orders()
-- create new monsters:
spawn_dragons()
spawn_undead()
-- (no more braineaters) spawn_braineaters(0.25)
-- post-turn updates:
update_guards()
update_scores()
-- write out the initial reports (no need to run a turn)
write_passwords()
write_reports()
2005-11-21 22:22:00 +01:00
write_emails()
write_summary()
2004-08-21 14:02:45 +02:00
-- siegbedingungen ausgeben
write_standings()
2004-08-21 14:02:45 +02:00
-- save the game
outfile = "" .. get_turn()
2003-12-18 00:11:52 +01:00
if write_game(outfile)~=0 then
print("could not write game")
return -1
end
end
2004-08-21 14:02:45 +02:00
--
-- main body of script
--
print("- Running wdw-run.lua")
scripts = {
"spells.lua",
"extensions.lua",
"familiars.lua",
2005-11-27 14:40:09 +01:00
"write_emails.lua",
"wdw/sphinx.lua",
"wdw/phoenix.lua",
"wdw/standings.lua"
}
2004-08-21 14:02:45 +02:00
-- orderfile: contains the name of the orders.
if orderfile==nil then
print "you must specify an orderfile"
else
local name
local index
for index, name in pairs(scripts) do
local script = scriptpath .. "/" .. name
2004-08-21 14:02:45 +02:00
print("- loading " .. script)
if pcall(dofile, script)==0 then
print("Could not load " .. script)
end
end
process(orderfile)
end