server/src/scripts/eressea.lua

120 lines
2.4 KiB
Lua
Raw Normal View History

-- 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")
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" } }
for loc, flist in pairs(localechange) do
for index, name in pairs(flist) do
f = get_faction(atoi36(name))
if f ~= nil then
f.locale = loc
print("LOCALECHANGE ", f, loc)
end
end
end
end
function load_scripts()
scripts = {
"spells.lua",
"extensions.lua",
"familiars.lua",
"eressea/eternath.lua",
"eressea/wedding-jadee.lua",
2005-12-11 13:33:57 +01:00
"eressea/ponnuki.lua",
"eressea/items.lua",
2006-10-07 23:26:31 +02:00
"eressea/10years.lua",
"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",
"eressea/embassy.lua",
2008-05-30 23:01:25 +02:00
"eressea/tunnels.lua",
"eressea/ents.lua"
}
for index, value in pairs(scripts) do
loadscript(value)
end
end
function process(orders)
-- initialize starting equipment for new players
2008-04-26 18:46:05 +02:00
if open_game(get_turn())~=0 then
print("could not read game")
return -1
end
init_summary()
2005-07-23 22:38:14 +02:00
-- kill multi-players (external script)
-- loadscript("eressea/multis.lua")
2005-07-23 22:38:14 +02:00
-- run the turn:
set_encoding("utf8")
if read_orders(orders) ~= 0 then
2005-04-24 23:54:57 +02:00
print("could not read " .. orders)
return -1
end
plan_monsters()
2006-08-20 18:23:46 +02:00
local nmrs = get_nmrs(1)
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")
process_orders()
-- create new monsters:
spawn_dragons()
spawn_undead()
spawn_braineaters(0.25)
spawn_ents()
-- post-turn updates:
update_xmas2006()
2005-12-11 13:33:57 +01:00
update_embassies()
update_guards()
update_scores()
change_locales()
-- use newfactions file to place out new players
autoseed(basepath .. "/newfactions", false)
2005-03-13 11:05:51 +01:00
write_files(locales)
2008-04-26 18:46:05 +02:00
file = "" .. get_turn() .. ".dat"
if write_game(file, "binary")~=0 then
print("could not write game")
return -1
end
end
--
-- main body of script
--
-- orderfile: contains the name of the orders.
load_scripts()
if orderfile==nil then
print "you must specify an orderfile"
else
process(orderfile)
end