2007-08-08 09:43:24 +02:00
|
|
|
-- the locales that this gameworld supports.
|
|
|
|
local locales = { "de", "en" }
|
|
|
|
|
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
|
|
|
|
|
2008-04-26 18:46:05 +02:00
|
|
|
loadscript("default.lua")
|
|
|
|
|
2005-04-09 11:11:41 +02:00
|
|
|
function change_locales()
|
2005-09-09 00:25:56 +02:00
|
|
|
-- local localechange = { }
|
2008-05-18 16:38:12 +02:00
|
|
|
local localechange = { en = { "won" } }
|
2005-04-09 11:11:41 +02:00
|
|
|
|
2007-06-13 14:38:15 +02:00
|
|
|
for loc, flist in pairs(localechange) do
|
|
|
|
for index, name in pairs(flist) do
|
2005-04-09 11:11:41 +02:00
|
|
|
f = get_faction(atoi36(name))
|
|
|
|
if f ~= nil then
|
|
|
|
f.locale = loc
|
|
|
|
print("LOCALECHANGE ", f, loc)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2008-05-22 23:44:23 +02:00
|
|
|
function load_scripts()
|
2005-01-01 18:50:35 +01:00
|
|
|
scripts = {
|
2005-10-08 23:34:00 +02:00
|
|
|
"spells.lua",
|
2005-10-29 16:48:37 +02:00
|
|
|
"extensions.lua",
|
2006-02-26 14:24:16 +01:00
|
|
|
"familiars.lua",
|
2005-11-26 00:32:56 +01:00
|
|
|
"eressea/eternath.lua",
|
|
|
|
"eressea/wedding-jadee.lua",
|
2005-12-11 13:33:57 +01:00
|
|
|
"eressea/ponnuki.lua",
|
2007-04-22 03:10:38 +02:00
|
|
|
"eressea/items.lua",
|
2006-10-07 23:26:31 +02:00
|
|
|
"eressea/10years.lua",
|
2008-05-22 23:44:23 +02:00
|
|
|
"eressea/xmas2004.lua",
|
2005-12-18 19:09:53 +01:00
|
|
|
"eressea/xmas2005.lua",
|
2006-12-24 00:58:03 +01:00
|
|
|
"eressea/xmas2006.lua",
|
2006-02-11 17:11:16 +01:00
|
|
|
"eressea/embassy.lua",
|
2008-05-30 23:01:25 +02:00
|
|
|
"eressea/tunnels.lua",
|
2006-02-11 17:11:16 +01:00
|
|
|
"eressea/ents.lua"
|
2005-01-01 18:50:35 +01:00
|
|
|
}
|
2007-06-13 14:38:15 +02:00
|
|
|
for index, value in pairs(scripts) do
|
|
|
|
loadscript(value)
|
2005-01-01 18:50:35 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2004-06-26 22:51:19 +02:00
|
|
|
function process(orders)
|
2005-10-02 17:54:24 +02:00
|
|
|
-- initialize starting equipment for new players
|
|
|
|
|
2008-04-26 18:46:05 +02:00
|
|
|
if open_game(get_turn())~=0 then
|
2004-06-26 22:51:19 +02:00
|
|
|
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)
|
2008-05-22 23:44:23 +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:
|
2007-11-15 21:38:44 +01:00
|
|
|
set_encoding("utf8")
|
2007-08-19 22:40:42 +02:00
|
|
|
if read_orders(orders) ~= 0 then
|
2005-04-24 23:54:57 +02:00
|
|
|
print("could not read " .. orders)
|
|
|
|
return -1
|
|
|
|
end
|
2005-01-01 18:50:35 +01:00
|
|
|
|
2005-06-04 17:34:04 +02:00
|
|
|
plan_monsters()
|
2006-08-20 18:23:46 +02:00
|
|
|
|
|
|
|
local nmrs = get_nmrs(1)
|
2006-12-03 14:24:11 +01:00
|
|
|
if nmrs >= 80 then
|
|
|
|
print("Shit. More than 80 factions with 1 NMR (" .. nmrs .. ")")
|
2006-10-07 23:26:31 +02:00
|
|
|
write_summary()
|
2006-08-20 18:23:46 +02:00
|
|
|
return -1
|
|
|
|
end
|
|
|
|
print (nmrs .. " Factions with 1 NMR")
|
|
|
|
|
2005-06-04 17:34:04 +02:00
|
|
|
process_orders()
|
2005-11-26 12:03:44 +01:00
|
|
|
|
2007-02-18 12:27:26 +01:00
|
|
|
-- create new monsters:
|
|
|
|
spawn_dragons()
|
|
|
|
spawn_undead()
|
|
|
|
spawn_braineaters(0.25)
|
|
|
|
spawn_ents()
|
|
|
|
|
2005-11-26 12:03:44 +01:00
|
|
|
-- post-turn updates:
|
2007-01-13 22:30:36 +01:00
|
|
|
update_xmas2006()
|
2005-12-11 13:33:57 +01:00
|
|
|
update_embassies()
|
2005-11-20 13:58:59 +01:00
|
|
|
update_guards()
|
|
|
|
update_scores()
|
2005-06-04 17:34:04 +02:00
|
|
|
|
|
|
|
change_locales()
|
2008-03-10 13:18:21 +01:00
|
|
|
|
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
|
|
|
|
2007-08-08 09:43:24 +02:00
|
|
|
write_files(locales)
|
2004-06-26 22:51:19 +02:00
|
|
|
|
2008-04-26 18:46:05 +02:00
|
|
|
file = "" .. get_turn() .. ".dat"
|
|
|
|
if write_game(file, "binary")~=0 then
|
2004-06-26 22:51:19 +02:00
|
|
|
print("could not write game")
|
|
|
|
return -1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--
|
|
|
|
-- main body of script
|
|
|
|
--
|
|
|
|
|
|
|
|
-- orderfile: contains the name of the orders.
|
2008-05-22 23:44:23 +02:00
|
|
|
load_scripts()
|
2004-06-26 22:51:19 +02:00
|
|
|
if orderfile==nil then
|
|
|
|
print "you must specify an orderfile"
|
|
|
|
else
|
|
|
|
process(orderfile)
|
|
|
|
end
|
|
|
|
|