forked from github/server
940d236edc
- moved some summary functionality (emails, aliases) to Lua code - made default.lua an include for all the different run-scripts report.c is the last file that needs some work, everything else should be fine. Most importantly, all the messages are not internationalized, so that means just about no more German in the code. Yay!
80 lines
1.4 KiB
Lua
80 lines
1.4 KiB
Lua
function loadscript(name)
|
|
local script = scriptpath .. "/" .. name
|
|
print("- loading " .. script)
|
|
if pcall(dofile, script)==0 then
|
|
print("Could not load " .. script)
|
|
end
|
|
end
|
|
|
|
function run_scripts()
|
|
scripts = {
|
|
"default.lua",
|
|
"spells.lua",
|
|
"extensions.lua",
|
|
"familiars.lua"
|
|
}
|
|
for index, name in pairs(scripts) do
|
|
loadscript(name)
|
|
end
|
|
end
|
|
|
|
function equip_new_faction(u)
|
|
b = add_building(u.region, "castle")
|
|
b.size = 10
|
|
u.building = b
|
|
end
|
|
|
|
function process(orders)
|
|
file = "" .. get_turn()
|
|
if read_game(file)~=0 then
|
|
print("could not read game")
|
|
return -1
|
|
end
|
|
init_summary()
|
|
|
|
-- run the turn:
|
|
if read_orders(orders) ~= 0 then
|
|
print("could not read " .. orders)
|
|
return -1
|
|
end
|
|
run_scripts()
|
|
|
|
plan_monsters()
|
|
|
|
local nmrs = get_nmrs(1)
|
|
if nmrs >= 70 then
|
|
print("Shit. More than 70 factions with 1 NMR (" .. nmrs .. ")")
|
|
write_summary()
|
|
return -1
|
|
end
|
|
print (nmrs .. " Factions with 1 NMR")
|
|
|
|
process_orders()
|
|
|
|
-- post-turn updates:
|
|
update_guards()
|
|
update_scores()
|
|
|
|
-- use newfactions file to place out new players
|
|
autoseed(basepath .. "/newfactions", false)
|
|
|
|
write_files(locales)
|
|
|
|
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
|
|
|