2005-03-23 19:55:47 +01:00
|
|
|
function loadscript(name)
|
|
|
|
local script = scriptpath .. "/" .. name
|
|
|
|
print("- loading " .. script)
|
|
|
|
if pcall(dofile, script)==0 then
|
|
|
|
print("Could not load " .. script)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2005-04-09 11:11:41 +02:00
|
|
|
function change_locales()
|
2005-09-09 00:25:56 +02:00
|
|
|
-- local localechange = { }
|
|
|
|
local localechange = { en = { "bLub" } }
|
2005-04-09 11:11:41 +02:00
|
|
|
|
|
|
|
for loc, flist in localechange do
|
|
|
|
for index, name in flist do
|
|
|
|
f = get_faction(atoi36(name))
|
|
|
|
if f ~= nil then
|
|
|
|
f.locale = loc
|
|
|
|
print("LOCALECHANGE ", f, loc)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2005-01-01 18:50:35 +01:00
|
|
|
function run_scripts()
|
|
|
|
scripts = {
|
|
|
|
"eternath.lua",
|
2005-03-23 19:55:47 +01:00
|
|
|
"wedding-jadee.lua",
|
2005-07-24 09:52:05 +02:00
|
|
|
"ponnuki.lua"
|
2005-01-01 18:50:35 +01:00
|
|
|
}
|
|
|
|
for index in scripts do
|
2005-03-23 19:55:47 +01:00
|
|
|
loadscript(scripts[index])
|
2005-01-01 18:50:35 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2004-06-26 22:51:19 +02:00
|
|
|
function write_emails()
|
|
|
|
local locales = { "de", "en" }
|
|
|
|
local files = {}
|
|
|
|
local key
|
|
|
|
for key in locales do
|
|
|
|
local locale = locales[key]
|
|
|
|
files[locale] = io.open(basepath .. "/emails." .. locale, "w")
|
|
|
|
end
|
|
|
|
|
|
|
|
local faction
|
|
|
|
for faction in factions() do
|
|
|
|
-- print(faction.id .. " - " .. faction.locale)
|
|
|
|
files[faction.locale]:write(faction.email .. "\n")
|
|
|
|
end
|
|
|
|
|
|
|
|
for key in files do
|
|
|
|
files[key]:close()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function process(orders)
|
|
|
|
file = "" .. get_turn()
|
|
|
|
if read_game(file)~=0 then
|
|
|
|
print("could not read game")
|
|
|
|
return -1
|
|
|
|
end
|
2005-04-16 15:03:35 +02:00
|
|
|
init_summary()
|
2004-06-26 22:51:19 +02:00
|
|
|
|
2005-07-23 22:38:14 +02:00
|
|
|
-- kill multi-players (external script)
|
2005-07-24 09:52:05 +02:00
|
|
|
loadscript("eressea-multis.lua")
|
2005-07-23 22:38:14 +02:00
|
|
|
|
2004-06-26 22:51:19 +02:00
|
|
|
-- run the turn:
|
2005-04-24 23:54:57 +02:00
|
|
|
if read_orders(orders) ~= 0 then
|
|
|
|
print("could not read " .. orders)
|
|
|
|
return -1
|
|
|
|
end
|
2005-01-01 18:50:35 +01:00
|
|
|
run_scripts()
|
|
|
|
|
2005-04-09 11:11:41 +02:00
|
|
|
-- initialize starting equipment for new players
|
|
|
|
add_equipment("conquesttoken", 1);
|
|
|
|
add_equipment("log", 30);
|
|
|
|
add_equipment("stone", 30);
|
|
|
|
add_equipment("money", 4200);
|
|
|
|
|
2005-06-04 17:34:04 +02:00
|
|
|
plan_monsters()
|
|
|
|
process_orders()
|
|
|
|
|
|
|
|
change_locales()
|
|
|
|
|
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", false)
|
2005-03-13 11:05:51 +01:00
|
|
|
|
2004-06-26 22:51:19 +02:00
|
|
|
write_passwords()
|
|
|
|
write_reports()
|
|
|
|
write_emails()
|
2005-04-16 15:03:35 +02:00
|
|
|
write_summary()
|
2004-06-26 22:51:19 +02:00
|
|
|
|
|
|
|
file = "" .. get_turn()
|
|
|
|
if write_game(file)~=0 then
|
|
|
|
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
|
|
|
|
process(orderfile)
|
|
|
|
end
|
|
|
|
|