2005-10-08 23:34:00 +02:00
|
|
|
function loadscript(name)
|
|
|
|
local script = scriptpath .. "/" .. name
|
|
|
|
print("- loading " .. script)
|
|
|
|
if pcall(dofile, script)==0 then
|
|
|
|
print("Could not load " .. script)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2004-02-07 14:47:11 +01:00
|
|
|
function write_emails()
|
|
|
|
local locales = { "de", "en" }
|
|
|
|
local files = {}
|
|
|
|
local key
|
|
|
|
for key in locales do
|
|
|
|
local locale = locales[key]
|
2004-04-11 18:16:26 +02:00
|
|
|
files[locale] = io.open(basepath .. "/emails." .. locale, "w")
|
2004-02-07 14:47:11 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
local faction
|
|
|
|
for faction in factions() do
|
2004-02-10 00:28:12 +01:00
|
|
|
-- print(faction.id .. " - " .. faction.locale)
|
2004-04-11 18:16:26 +02:00
|
|
|
files[faction.locale]:write(faction.email .. "\n")
|
2004-02-07 14:47:11 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
for key in files do
|
|
|
|
files[key]:close()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2003-12-14 17:34:00 +01:00
|
|
|
function process(orders)
|
2005-10-02 17:54:24 +02:00
|
|
|
-- initialize starting equipment for new players
|
2005-10-02 22:28:44 +02:00
|
|
|
equipment_setitem("new_faction", "conquesttoken", "1");
|
2005-11-20 13:58:59 +01:00
|
|
|
equipment_setitem("new_faction", "log", "30");
|
2005-10-02 22:28:44 +02:00
|
|
|
equipment_setitem("new_faction", "stone", "30");
|
|
|
|
equipment_setitem("new_faction", "money", "4200");
|
2005-10-02 17:54:24 +02:00
|
|
|
|
2003-12-14 20:17:59 +01:00
|
|
|
file = "" .. get_turn()
|
2004-05-30 05:25:10 +02:00
|
|
|
if read_game(file)~=0 then
|
2003-12-14 17:34:00 +01:00
|
|
|
print("could not read game")
|
|
|
|
return -1
|
|
|
|
end
|
2005-04-16 15:03:35 +02:00
|
|
|
init_summary()
|
2003-12-14 17:34:00 +01:00
|
|
|
|
2005-04-09 11:11:41 +02:00
|
|
|
-- run the turn:
|
|
|
|
read_orders(orders)
|
|
|
|
|
2005-11-26 12:03:44 +01:00
|
|
|
-- create new monsters:
|
|
|
|
spawn_dragons()
|
|
|
|
spawn_undead()
|
2005-10-02 18:06:12 +02:00
|
|
|
spawn_braineaters(0.25)
|
2005-11-26 12:03:44 +01:00
|
|
|
|
2005-04-09 11:11:41 +02:00
|
|
|
plan_monsters()
|
|
|
|
process_orders()
|
2005-11-26 12:03:44 +01:00
|
|
|
|
|
|
|
-- post-turn updates:
|
|
|
|
update_guards()
|
|
|
|
update_scores()
|
|
|
|
|
2005-04-09 11:11:41 +02:00
|
|
|
|
|
|
|
-- use newfactions file to place out new players
|
2005-08-07 15:48:18 +02:00
|
|
|
autoseed(basepath .. "/newfactions", true)
|
2004-05-30 05:25:10 +02:00
|
|
|
|
2003-12-14 17:34:00 +01:00
|
|
|
write_passwords()
|
|
|
|
write_reports()
|
2004-02-07 14:47:11 +01:00
|
|
|
write_emails()
|
2005-04-16 15:03:35 +02:00
|
|
|
write_summary()
|
2004-02-07 14:47:11 +01:00
|
|
|
|
2003-12-14 20:17:59 +01:00
|
|
|
file = "" .. get_turn()
|
|
|
|
if write_game(file)~=0 then
|
2003-12-14 17:34:00 +01:00
|
|
|
print("could not write game")
|
|
|
|
return -1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- main body of script
|
|
|
|
--
|
|
|
|
|
|
|
|
-- orderfile: contains the name of the orders.
|
|
|
|
if orderfile==nil then
|
|
|
|
print "you must specify an orderfile"
|
|
|
|
else
|
2005-10-08 23:34:00 +02:00
|
|
|
loadscript("spells.lua")
|
2005-10-29 16:48:37 +02:00
|
|
|
loadscript("extensions.lua")
|
2003-12-14 17:34:00 +01:00
|
|
|
process(orderfile)
|
|
|
|
end
|
2004-01-24 01:18:49 +01:00
|
|
|
|