diff --git a/src/scripts/eressea.lua b/src/scripts/eressea.lua index d3ae91222..adc5c9324 100644 --- a/src/scripts/eressea.lua +++ b/src/scripts/eressea.lua @@ -25,9 +25,9 @@ function run_scripts() scripts = { "spells.lua", "extensions.lua", - "eternath.lua", - "wedding-jadee.lua", - "ponnuki.lua" + "eressea/eternath.lua", + "eressea/wedding-jadee.lua", + "eressea/ponnuki.lua" } for index in scripts do loadscript(scripts[index]) @@ -69,7 +69,7 @@ function process(orders) init_summary() -- kill multi-players (external script) - loadscript("eressea-multis.lua") + loadscript("eressea/multis.lua") -- run the turn: if read_orders(orders) ~= 0 then diff --git a/src/scripts/artrewards.lua b/src/scripts/eressea/artrewards.lua similarity index 100% rename from src/scripts/artrewards.lua rename to src/scripts/eressea/artrewards.lua diff --git a/src/scripts/eternath.lua b/src/scripts/eressea/eternath.lua similarity index 100% rename from src/scripts/eternath.lua rename to src/scripts/eressea/eternath.lua diff --git a/src/scripts/igjaruk.lua b/src/scripts/eressea/igjaruk.lua similarity index 100% rename from src/scripts/igjaruk.lua rename to src/scripts/eressea/igjaruk.lua diff --git a/src/scripts/eressea-multis.lua b/src/scripts/eressea/multis.lua similarity index 100% rename from src/scripts/eressea-multis.lua rename to src/scripts/eressea/multis.lua diff --git a/src/scripts/ponnuki.lua b/src/scripts/eressea/ponnuki.lua similarity index 100% rename from src/scripts/ponnuki.lua rename to src/scripts/eressea/ponnuki.lua diff --git a/src/scripts/wedding-jadee.lua b/src/scripts/eressea/wedding-jadee.lua similarity index 100% rename from src/scripts/wedding-jadee.lua rename to src/scripts/eressea/wedding-jadee.lua diff --git a/src/scripts/xmas2004.lua b/src/scripts/eressea/xmas2004.lua similarity index 100% rename from src/scripts/xmas2004.lua rename to src/scripts/eressea/xmas2004.lua diff --git a/src/scripts/gates.lua b/src/scripts/gates.lua index 24c026e58..c3afc67ce 100644 --- a/src/scripts/gates.lua +++ b/src/scripts/gates.lua @@ -1,3 +1,6 @@ +-- implements gates and travel between them +-- used in HSE and Eressea + function gate_travel(b, units) -- we've found which units we want to exchange, now swap them: local u diff --git a/src/scripts/hse-buildings.lua b/src/scripts/hse/buildings.lua similarity index 100% rename from src/scripts/hse-buildings.lua rename to src/scripts/hse/buildings.lua diff --git a/src/scripts/hse-grails.lua b/src/scripts/hse/grails.lua similarity index 100% rename from src/scripts/hse-grails.lua rename to src/scripts/hse/grails.lua diff --git a/src/scripts/hse-portals.lua b/src/scripts/hse/portals.lua similarity index 100% rename from src/scripts/hse-portals.lua rename to src/scripts/hse/portals.lua diff --git a/src/scripts/hse-spoils.lua b/src/scripts/hse/spoils.lua similarity index 100% rename from src/scripts/hse-spoils.lua rename to src/scripts/hse/spoils.lua diff --git a/src/scripts/hse-stats.lua b/src/scripts/hse/stats.lua similarity index 67% rename from src/scripts/hse-stats.lua rename to src/scripts/hse/stats.lua index edff5149e..e6f4217e1 100644 --- a/src/scripts/hse-stats.lua +++ b/src/scripts/hse/stats.lua @@ -1,6 +1,6 @@ -dofile(scriptpath .. "/hse-grails.lua") -dofile(scriptpath .. "/hse-spoils.lua") -dofile(scriptpath .. "/hse-buildings.lua") +dofile(scriptpath .. "/hse/grails.lua") +dofile(scriptpath .. "/hse/spoils.lua") +dofile(scriptpath .. "/hse/buildings.lua") function write_stats(filename) local file = io.open(reportpath .. "/" .. filename, "w") diff --git a/src/scripts/hse3-run.lua b/src/scripts/hse3-run.lua index 0732fee41..71e3c7de8 100644 --- a/src/scripts/hse3-run.lua +++ b/src/scripts/hse3-run.lua @@ -2,8 +2,8 @@ function run_scripts() scripts = { "spells.lua", "extensions.lua", - "hse-portals.lua", - "hse-stats.lua" + "hse/portals.lua", + "hse/stats.lua" } for index in scripts do local script = scriptpath .. "/" .. scripts[index] diff --git a/src/scripts/hse4-run.lua b/src/scripts/hse4-run.lua index 72eed8ed3..181f5011c 100644 --- a/src/scripts/hse4-run.lua +++ b/src/scripts/hse4-run.lua @@ -2,8 +2,8 @@ function run_scripts() scripts = { "spells.lua", "extensions.lua", - "hse-portals.lua", - "hse-stats.lua" + "hse/portals.lua", + "hse/stats.lua" } for index in scripts do local script = scriptpath .. "/" .. scripts[index] diff --git a/src/scripts/igjarjuk-call.lua b/src/scripts/igjarjuk-call.lua deleted file mode 100644 index 7ab3e3440..000000000 --- a/src/scripts/igjarjuk-call.lua +++ /dev/null @@ -1,49 +0,0 @@ -function teleport(u, r) - u.region:add_notice(tostring(u) .. " wird durchsichtig und verschwindet.") - u.region = r - u.region:add_notice(tostring(u) .. " erscheint.") -end - -function call_igjarjuk() - u = get_unit(atoi36("50ki")) - if (u==nil) then - return - end - fog = u.region - - laoris = get_unit(atoi36("cshL")) - wyrm = get_unit(atoi36("igjr")) - if (laoris==nil or wyrm==nil or laoris.region==fog) then - return - end - - -- make him a special kind of wyrm - wyrm.race = "skeletal_wyrm" - wyrm.hp = 10000 - wyrm.status = 1 - wyrm.magic = "nomagic" - wyrm:set_skill("magic", 20) - wyrm.aura = 1000 - wyrm.faction:set_policy(laoris.faction, "fight", true) - wyrm.faction:set_policy(get_faction(atoi36("dpen")), "fight", true) - - laoris:add_item("wand_of_tears", -6) - -- inform the folks in the grave about what's up - grave = wyrm.region - fog:add_notice(tostring(laoris) .. " schwingt die Schwinge des Greifen. Das Auge des Dämons glüht in hellem weißen Licht, Blitze springen auf " .. tostring(wyrm) .. " über.") - fog:add_notice(tostring(wyrm) .. " wird durchsichtig und verschwindet.") - fog:add_notice(tostring(laoris) .. " wird durchsichtig und verschwindet.") - - -- andere Pentagramm-Meister - teleport(get_unit(atoi36("q7qf")), fog) - teleport(get_unit(atoi36("abqp")), fog) - - -- Wyrm und Laoris - wyrm.region = fog - laoris.region = fog - - fog:add_notice("von " .. tostring(wyrm) .. ": 'DER TAG MEINER RÜCKKEHR IST GEKOMMEN. MIT DEM BLUT DER STERBLICHEN WILL ICH AUF DIESEN TAG ANSTOSSEN.'") - fog:add_notice(tostring(laoris) .. " erscheint. Auf seinem Rücken sind die Schwingen eines mächtigen Greifen zu sehen, in seinen Händen hält er beschwörend einen hell leuchtenden Kristall, das Auge des Dämon.") - fog:add_notice(tostring(wyrm) .. " erscheint.") - fog:add_notice("von " .. tostring(wyrm) .. ": 'WAS IST DAS? DIES IST NICHT DIE WELT DER STERBLICHEN. LAORIS! WOHIN HAST DU MICH GEBRACHT?'") -end diff --git a/src/scripts/kingdoms-run.lua b/src/scripts/kingdoms-run.lua new file mode 100644 index 000000000..d7567edf7 --- /dev/null +++ b/src/scripts/kingdoms-run.lua @@ -0,0 +1,92 @@ +function loadscript(name) + local script = scriptpath .. "/" .. name + print("- loading " .. script) + if pcall(dofile, script)==0 then + print("Could not load " .. script) + end +end + +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 update_owners() +-- update the region's owners. currently uses the owner of +-- the largest castle. + local r + for r in regions() do + local lb = nil + for b in r.buildings do + if b.type=="castle" and (lb==nil or b.size>lb.size) then + lb = b + end + end + local u + u = b.units() + if u~=nil and u.faction~=r.owner then + r.owner = u.faction + end + end +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: + read_orders(orders) + + -- DISABLED: plan_monsters() + process_orders() + update_owners() + + -- use newfactions file to place out new players + autoseed(basepath .. "/newfactions", true) + + write_passwords() + write_reports() + write_emails() + write_summary() + + 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 + -- loadscript("spells.lua") + loadscript("extensions.lua") + loadscript("kingdoms/extensions.lua") + process(orderfile) +end + diff --git a/src/scripts/kingdoms/extensions.lua b/src/scripts/kingdoms/extensions.lua new file mode 100644 index 000000000..2f9991a90 --- /dev/null +++ b/src/scripts/kingdoms/extensions.lua @@ -0,0 +1,19 @@ +function get_wage(r, f, race) + return 10 +end + + +function get_maintenance(u) + local f = u.region.owner + if f ~= nil then + if f == u.faction then + return 2 * u.number + else if f:get_policy(u.faction, "money") then + return 5 * u.number + end + end + return 10 * u.number +end + +overload("maintenance", get_maintenance) +overload("wage", get_wage) diff --git a/src/scripts/wdw-run.lua b/src/scripts/wdw-run.lua index 3ad8959ce..5133422da 100644 --- a/src/scripts/wdw-run.lua +++ b/src/scripts/wdw-run.lua @@ -47,8 +47,8 @@ print("- Running wdw-run.lua") scripts = { "spells.lua", "extensions.lua", - "wdw-sphinx.lua", - "wdw-standings.lua" + "wdw/sphinx.lua", + "wdw/standings.lua" } -- orderfile: contains the name of the orders. diff --git a/src/scripts/sphinx-announce.lua b/src/scripts/wdw/sphinx-announce.lua similarity index 100% rename from src/scripts/sphinx-announce.lua rename to src/scripts/wdw/sphinx-announce.lua diff --git a/src/scripts/sphinx-initfactions.lua b/src/scripts/wdw/sphinx-initfactions.lua similarity index 100% rename from src/scripts/sphinx-initfactions.lua rename to src/scripts/wdw/sphinx-initfactions.lua diff --git a/src/scripts/wdw-sphinx.lua b/src/scripts/wdw/sphinx.lua similarity index 100% rename from src/scripts/wdw-sphinx.lua rename to src/scripts/wdw/sphinx.lua diff --git a/src/scripts/wdw-standings.lua b/src/scripts/wdw/standings.lua similarity index 100% rename from src/scripts/wdw-standings.lua rename to src/scripts/wdw/standings.lua