forked from github/server
Skripte in eigenem folder.
Starten von wdw mit Parameter -e wdw-run.lua + erkennt jetzt, ob schon allianzenausgesetzt wurden, ruft ansonsten das setup auf + schreibt reports/victory.txt Datei mit Spielstand
This commit is contained in:
parent
fd47232a21
commit
50e24a43e6
4 changed files with 303 additions and 0 deletions
56
src/scripts/wdw-run.lua
Normal file
56
src/scripts/wdw-run.lua
Normal file
|
@ -0,0 +1,56 @@
|
|||
function list_empty(list)
|
||||
-- trickfunktion, die rausfindet, ob es schon eine partei gibt.
|
||||
local _foo, _state, var_1 = list()
|
||||
local begin = _foo(_state, var_1)
|
||||
return begin == nil
|
||||
end
|
||||
|
||||
function run_wdw()
|
||||
-- load 'wdw-start', if it exists. otherwise, load the latest turn,
|
||||
-- and make a backup called 'wdw-start'.
|
||||
local file = "wdw-start"
|
||||
local alliance, position, faction
|
||||
if list_empty(factions) then
|
||||
if read_game(file)~=0 then
|
||||
local turnfile = "" .. get_turn()
|
||||
if read_game(turnfile)~=0 then
|
||||
print("could not read game")
|
||||
return -1
|
||||
end
|
||||
if write_game(file)~=0 then
|
||||
print("could not write game")
|
||||
return -1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- run the alliances setup
|
||||
if list_empty(alliances) then
|
||||
dofile("wdw-setup.lua")
|
||||
end
|
||||
-- -- run the turn (not yet)
|
||||
-- read_orders(orders)
|
||||
-- process_orders()
|
||||
|
||||
-- siegbedingungen ausgeben
|
||||
dofile("wdw-standings.lua")
|
||||
if 1 == 1 then
|
||||
return -1
|
||||
end
|
||||
|
||||
-- write out the initial reports (no need to run a turn)
|
||||
write_passwords()
|
||||
write_reports()
|
||||
|
||||
|
||||
-- write the resulting file to 'wdw-setup'
|
||||
if write_game("wdw-setup")~=0 then
|
||||
print("could not write game")
|
||||
return -1
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- main body of the script
|
||||
run_wdw()
|
204
src/scripts/wdw-setup.lua
Normal file
204
src/scripts/wdw-setup.lua
Normal file
|
@ -0,0 +1,204 @@
|
|||
positions = {}
|
||||
|
||||
function init_positions()
|
||||
-- init starting positions for the alliances here.
|
||||
positions = {
|
||||
[11] = get_region(0, 1),
|
||||
[12] = get_region(0, 2),
|
||||
[13] = get_region(0, 3),
|
||||
[14] = get_region(0, 4),
|
||||
[15] = get_region(0, 5),
|
||||
[17] = get_region(0, 6),
|
||||
[18] = get_region(0, 7),
|
||||
[19] = get_region(0, 8)
|
||||
}
|
||||
end
|
||||
|
||||
function get_position(aid)
|
||||
-- return the position at which alliance 'aid' will start.
|
||||
local pos = positions[aid]
|
||||
|
||||
-- hack, because i have no coordinates yet:
|
||||
if pos.terrain ~= "ocean" then
|
||||
return pos
|
||||
else
|
||||
-- find a region. let's use the region number 'aid' in the list,
|
||||
-- so everyone gets their own
|
||||
print("cannot place alliance " .. aid .. " at " .. pos.x .. ", " .. pos.y)
|
||||
for pos in regions() do
|
||||
if pos.terrain ~= "ocean" then
|
||||
if aid==0 then
|
||||
return pos
|
||||
else
|
||||
aid = aid-1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
gems = { "opal", "diamond", "zaphire", "topaz", "beryl", "agate", "garnet", "emerald" }
|
||||
|
||||
function get_gem(id)
|
||||
return gems[math.mod(id, 8)+1]
|
||||
end
|
||||
|
||||
ano = 0 -- counting active alliance
|
||||
numalliances = 8 -- number of alliances
|
||||
lastalliance = nil
|
||||
|
||||
function make_faction(position, alliance, number, email, race)
|
||||
local skillno = 27 -- es gibt 27 skills in der liste
|
||||
local units = (1+skillno)*6 / number -- jede allianz kriegt 168 leute
|
||||
local money = units * 5 * 10 -- jede allianz kriegt 8400 silber
|
||||
|
||||
local f = add_faction(email, race, "de")
|
||||
if f == nil then
|
||||
print("could not create " .. email .. " " .. race)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
print("\n" .. email .. " (" .. itoa36(f.id) .. ")")
|
||||
f.alliance = alliance
|
||||
local u = add_unit(f, position)
|
||||
-- erster ist der, der die extras kriegt:
|
||||
u.number = 1
|
||||
local units = units - 1
|
||||
u:add_item("money", money)
|
||||
if lastalliance==nil or alliance.id ~= lastalliance.id then
|
||||
ano=ano+1
|
||||
lastalliance = alliance
|
||||
u:add_item(get_gem(ano), numalliances-1)
|
||||
u:add_item(get_gem(ano+1), 2)
|
||||
u:add_item(get_gem(ano+2), 2)
|
||||
end
|
||||
|
||||
local sk
|
||||
for sk in skills do
|
||||
u = add_unit(f, position)
|
||||
|
||||
-- anzahl personen berechnen
|
||||
local number = math.floor(units / skillno)
|
||||
units = units - number
|
||||
skillno = skillno - 1
|
||||
u.number = number
|
||||
|
||||
local skill = skills[sk]
|
||||
u:set_skill(skill, 3)
|
||||
|
||||
print("- " .. number .. " x " .. skill)
|
||||
end
|
||||
end
|
||||
|
||||
-- skills that will be given to new units
|
||||
skills = {
|
||||
"sk_roadwork",
|
||||
"sk_alchemy",
|
||||
"sk_crossbow",
|
||||
"sk_mining",
|
||||
"sk_bow",
|
||||
"sk_building",
|
||||
"sk_trade",
|
||||
"sk_forestry",
|
||||
"sk_catapult",
|
||||
"sk_herbalism",
|
||||
"sk_training",
|
||||
"sk_riding",
|
||||
"sk_armorer",
|
||||
"sk_shipcraft",
|
||||
"sk_melee",
|
||||
"sk_sailing",
|
||||
"sk_polearm",
|
||||
"sk_espionage",
|
||||
"sk_quarrying",
|
||||
"sk_tactics",
|
||||
"sk_stealth",
|
||||
"sk_entertainment",
|
||||
"sk_weaponsmithing",
|
||||
"sk_cartmaking",
|
||||
"sk_perception",
|
||||
"sk_taxation",
|
||||
"sk_stamina"
|
||||
}
|
||||
|
||||
function wdw_setup()
|
||||
-- initialize starting equipment for new players
|
||||
add_equipment("magicskillboost", 1)
|
||||
|
||||
init_positions()
|
||||
|
||||
-- Initialize Wächter des Phoenix
|
||||
alliance = add_alliance(11, "Wächter des Phoenix")
|
||||
position = get_position(11)
|
||||
faction = make_faction(position, alliance, 4, "durgan@web.de", "Elfen")
|
||||
faction = make_faction(position, alliance, 4, "Daniel@gedankenwelt.net", "Trolle")
|
||||
faction = make_faction(position, alliance, 4, "rostnicht@web.de", "Dämonen")
|
||||
faction = make_faction(position, alliance, 4, "16419@uni-lueneburg.de", "Insekten")
|
||||
|
||||
-- Initialize Refinius
|
||||
alliance = add_alliance(12, "Refinius")
|
||||
position = get_position(12)
|
||||
faction = make_faction(position, alliance, 5, "wanderameisen@dunklerpfad.de", "Meermenschen")
|
||||
faction = make_faction(position, alliance, 5, "ElunasErben@dunklerpfad.de", "Elfen")
|
||||
faction = make_faction(position, alliance, 5, "miles.tegson@gmx.net", "Zwerge")
|
||||
faction = make_faction(position, alliance, 5, "shannera@shannera.de", "Dämonen")
|
||||
faction = make_faction(position, alliance, 5, "langhaarigerBombenleger@firemail.de", "Trolle")
|
||||
|
||||
-- Initialize Stählerner Bund von Parinor
|
||||
alliance = add_alliance(13, "Stählerner Bund von Parinor")
|
||||
position = get_position(13)
|
||||
faction = make_faction(position, alliance, 5, "ta@sts-gbr.de", "Dämonen")
|
||||
faction = make_faction(position, alliance, 5, "klausnet@gmx.de", "Elfen")
|
||||
faction = make_faction(position, alliance, 5, "r.jerger@gmx.de", "Trolle")
|
||||
faction = make_faction(position, alliance, 5, "christianemmler@t-online.de", "Insekten")
|
||||
faction = make_faction(position, alliance, 5, "DieCherusker@gmx.de", "Orks")
|
||||
|
||||
-- Initialize Ethâra´s Zirkel des Chaos
|
||||
alliance = add_alliance(14, "Ethâra´s Zirkel des Chaos")
|
||||
position = get_position(14)
|
||||
faction = make_faction(position, alliance, 4, "craban@web.de", "Elfen")
|
||||
faction = make_faction(position, alliance, 4, "saressa@celtic-visions.net", "Zwerge")
|
||||
faction = make_faction(position, alliance, 4, "krachon@gmx.de", "Orks")
|
||||
faction = make_faction(position, alliance, 4, "andreas.westhoff@physik3.gwdg.de", "Meermenschen")
|
||||
|
||||
-- Initialize Janustempler
|
||||
alliance = add_alliance(15, "Janustempler")
|
||||
position = get_position(15)
|
||||
faction = make_faction(position, alliance, 4, "alex.goelkel@t-online.de", "Meermenschen")
|
||||
faction = make_faction(position, alliance, 4, "matthias.lendholt@gmx.de", "Elfen")
|
||||
faction = make_faction(position, alliance, 4, "Uwe.Kopf@onlinehome.de", "Orks")
|
||||
faction = make_faction(position, alliance, 4, "Jan.Thaler@gmx.de", "Dämonen")
|
||||
|
||||
-- Initialize Kiddies
|
||||
alliance = add_alliance(17, "Kiddies")
|
||||
position = get_position(17)
|
||||
faction = make_faction(position, alliance, 5, "henning.ewald@t-online.de", "Orks")
|
||||
faction = make_faction(position, alliance, 5, "red@gmx.de", "Meermenschen")
|
||||
faction = make_faction(position, alliance, 5, "Morgon@Morgon.de", "Zwerge")
|
||||
faction = make_faction(position, alliance, 5, "hadmar.lang@wu-wien.ac.at", "Elfen")
|
||||
faction = make_faction(position, alliance, 5, "vinyambar@burningchaos.org", "Dämonen")
|
||||
|
||||
-- Initialize Airbe Druad
|
||||
alliance = add_alliance(18, "Airbe Druad")
|
||||
position = get_position(18)
|
||||
faction = make_faction(position, alliance, 6, "t.lam@gmx.at", "Elfen")
|
||||
faction = make_faction(position, alliance, 6, "Post_der_Trolle@gmx.de", "Dämonen")
|
||||
faction = make_faction(position, alliance, 6, "Mann.Martin@t-online.de", "Meermenschen")
|
||||
faction = make_faction(position, alliance, 6, "thaeberli@freesurf.ch", "Orks")
|
||||
faction = make_faction(position, alliance, 6, "sonja@tzi.de", "Trolle")
|
||||
faction = make_faction(position, alliance, 6, "lothar.juerss@gmx.at", "Zwerge")
|
||||
|
||||
-- Initialize Matula
|
||||
alliance = add_alliance(19, "Matula")
|
||||
position = get_position(19)
|
||||
faction = make_faction(position, alliance, 4, "mserrano@tiscali.de", "Elfen")
|
||||
faction = make_faction(position, alliance, 4, "kerki@aol.com", "Dämonen")
|
||||
faction = make_faction(position, alliance, 4, "Roddiwi@aol.com", "Orks")
|
||||
faction = make_faction(position, alliance, 4, "bauschan@aol.com", "Trolle")
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- main body of the script
|
||||
wdw_setup()
|
43
src/scripts/wdw-standings.lua
Normal file
43
src/scripts/wdw-standings.lua
Normal file
|
@ -0,0 +1,43 @@
|
|||
conditions = { pyramid="Pyramide", gems="Handel", phoenix="Phönix" }
|
||||
|
||||
function log(file, line)
|
||||
print(line)
|
||||
file:write(line .. "\n")
|
||||
end
|
||||
|
||||
function write_standings()
|
||||
print(reportpath .. "/victory.txt")
|
||||
local file = io.open(reportpath .. "/victory.txt", "w")
|
||||
|
||||
log(file, "** Allianzen **")
|
||||
local alliance
|
||||
for alliance in alliances() do
|
||||
local faction
|
||||
log(file, alliance.id .. ": " .. alliance.name)
|
||||
for faction in alliance.factions do
|
||||
log(file, "- " .. faction.name .." (" .. faction.id .. ")")
|
||||
end
|
||||
log (file, "")
|
||||
end
|
||||
|
||||
log(file, "** Erfüllte Siegbedingungen **")
|
||||
local condition
|
||||
for condition in conditions do
|
||||
local none = true
|
||||
log(file, conditions[condition])
|
||||
for alliance in alliances() do
|
||||
if victorycondition(alliance, condition)==1 then
|
||||
log(file, " - " .. alliance.name .. " (" .. alliance.id .. ")")
|
||||
none = false
|
||||
end
|
||||
end
|
||||
if none then
|
||||
log(file, " - Niemand")
|
||||
end
|
||||
end
|
||||
|
||||
file:close()
|
||||
end
|
||||
|
||||
-- main body of script
|
||||
write_standings()
|
Loading…
Reference in a new issue