forked from github/server
HSE-specific changes and LUA extensions donw during the game
This commit is contained in:
parent
b32890df96
commit
d46c0a9d46
|
@ -34,7 +34,11 @@ CCFLAGS += -Wwrite-strings
|
||||||
;
|
;
|
||||||
|
|
||||||
# this require the latet luabind from CVS
|
# this require the latet luabind from CVS
|
||||||
C++FLAGS += -DHAVE_LUABIND_B7 ;
|
if ! $(LUABIND) {
|
||||||
|
LUABIND = "B7" ;
|
||||||
|
}
|
||||||
|
|
||||||
|
C++FLAGS += -DHAVE_LUABIND_$(LUABIND) ;
|
||||||
if $(HOST) = "hamunaptra" {
|
if $(HOST) = "hamunaptra" {
|
||||||
XMLHDRS = /homes2/info-f/enno/software/hamunaptra/include/libxml2 ;
|
XMLHDRS = /homes2/info-f/enno/software/hamunaptra/include/libxml2 ;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -177,7 +177,7 @@ bind_building(lua_State * L)
|
||||||
.property("info", &building_getinfo, &building_setinfo)
|
.property("info", &building_getinfo, &building_setinfo)
|
||||||
.property("units", &building_units, return_stl_iterator)
|
.property("units", &building_units, return_stl_iterator)
|
||||||
.property("region", &building_getregion, &building_setregion)
|
.property("region", &building_getregion, &building_setregion)
|
||||||
.def("type", &building_gettype)
|
.property("type", &building_gettype)
|
||||||
.def_readonly("id", &building::no)
|
.def_readonly("id", &building::no)
|
||||||
.def_readwrite("size", &building::size)
|
.def_readwrite("size", &building::size)
|
||||||
.def("add_action", &building_addaction)
|
.def("add_action", &building_addaction)
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
// kernel includes
|
// kernel includes
|
||||||
#include <kernel/building.h>
|
#include <kernel/building.h>
|
||||||
|
#include <kernel/item.h>
|
||||||
#include <kernel/plane.h>
|
#include <kernel/plane.h>
|
||||||
#include <kernel/region.h>
|
#include <kernel/region.h>
|
||||||
#include <kernel/ship.h>
|
#include <kernel/ship.h>
|
||||||
|
@ -106,6 +107,15 @@ region_setflag(region& r, int bit, bool set)
|
||||||
else r.flags &= ~(1<<bit);
|
else r.flags &= ~(1<<bit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
region_getresource(const region& r, const char * type)
|
||||||
|
{
|
||||||
|
const resource_type * rtype = rt_find(type);
|
||||||
|
if (rtype==rt_find("money")) return rmoney(&r);
|
||||||
|
if (rtype==rt_find("peasant")) return rpeasants(&r);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
region_setroad(region& r, int dir, lua_Number size)
|
region_setroad(region& r, int dir, lua_Number size)
|
||||||
{
|
{
|
||||||
|
@ -249,6 +259,7 @@ bind_region(lua_State * L)
|
||||||
.def("set_road", ®ion_setroad)
|
.def("set_road", ®ion_setroad)
|
||||||
|
|
||||||
.def("next", ®ion_next)
|
.def("next", ®ion_next)
|
||||||
|
.def("get_resource", ®ion_getresource)
|
||||||
.def_readonly("x", ®ion::x)
|
.def_readonly("x", ®ion::x)
|
||||||
.def_readonly("y", ®ion::y)
|
.def_readonly("y", ®ion::y)
|
||||||
.def_readwrite("age", ®ion::age)
|
.def_readwrite("age", ®ion::age)
|
||||||
|
|
|
@ -44,6 +44,12 @@ add_ship(const char * sname, region& r)
|
||||||
return sh;
|
return sh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
ship_gettype(const ship& s) {
|
||||||
|
return s.type->name[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
bind_ship(lua_State * L)
|
bind_ship(lua_State * L)
|
||||||
{
|
{
|
||||||
|
@ -54,6 +60,7 @@ bind_ship(lua_State * L)
|
||||||
class_<struct ship>("ship")
|
class_<struct ship>("ship")
|
||||||
.def(self == ship())
|
.def(self == ship())
|
||||||
.def(tostring(self))
|
.def(tostring(self))
|
||||||
|
.property("type", &ship_gettype)
|
||||||
.def_readonly("name", &ship::name)
|
.def_readonly("name", &ship::name)
|
||||||
.def_readonly("region", &ship::region)
|
.def_readonly("region", &ship::region)
|
||||||
.def_readonly("id", &ship::no)
|
.def_readonly("id", &ship::no)
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
<order name="MAGIEGEBIET" disable="yes"/>
|
<order name="MAGIEGEBIET" disable="yes"/>
|
||||||
<param name="entertain.base" value="15"/>
|
<param name="entertain.base" value="15"/>
|
||||||
<param name="entertain.perlevel" value="5"/>
|
<param name="entertain.perlevel" value="5"/>
|
||||||
<param name="nmr.timeout" value="9999"/>
|
<param name="nmr.timeout" value="20"/>
|
||||||
<param name="nmr.removenewbie" value="0"/>
|
<param name="nmr.removenewbie" value="0"/>
|
||||||
<param name="GiveRestriction" value="3"/>
|
<param name="GiveRestriction" value="3"/>
|
||||||
<param name="NewbieImmunity" value="4"/>
|
<param name="NewbieImmunity" value="4"/>
|
||||||
|
@ -45,8 +45,8 @@
|
||||||
<xi:include href="eressea/temple.xml"/>
|
<xi:include href="eressea/temple.xml"/>
|
||||||
<strings>
|
<strings>
|
||||||
<string name="mailto">
|
<string name="mailto">
|
||||||
<text locale="de">hse-server@eressea.upb.de</text>
|
<text locale="de">hse-server@eressea.de</text>
|
||||||
<text locale="en">hse-server@eressea.upb.de</text>
|
<text locale="en">hse-server@eressea.de</text>
|
||||||
</string>
|
</string>
|
||||||
<string name="mailcmd">
|
<string name="mailcmd">
|
||||||
<text locale="de">ERESSEA BEFEHLE</text>
|
<text locale="de">ERESSEA BEFEHLE</text>
|
||||||
|
|
|
@ -11,17 +11,12 @@ function gate_units(b, maxsize)
|
||||||
local size = maxsize
|
local size = maxsize
|
||||||
local units = {}
|
local units = {}
|
||||||
local u
|
local u
|
||||||
local first = true
|
|
||||||
|
|
||||||
for u in b.units do
|
for u in b.units do
|
||||||
if first then
|
|
||||||
first = false
|
|
||||||
else
|
|
||||||
if u.number<=size and u.weight<=u.capacity then
|
if u.number<=size and u.weight<=u.capacity then
|
||||||
units[u] = u
|
units[u] = u
|
||||||
size = size - u.number
|
size = size - u.number
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
return units
|
return units
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
function run_scripts()
|
function run_scripts()
|
||||||
scripts = {
|
scripts = {
|
||||||
"hse05-portals.lua",
|
"hse05-portals.lua",
|
||||||
"hse05-grails.lua"
|
"hse05-stats.lua"
|
||||||
}
|
}
|
||||||
for index in scripts do
|
for index in scripts do
|
||||||
local script = scriptpath .. "/" .. scripts[index]
|
local script = scriptpath .. "/" .. scripts[index]
|
||||||
|
@ -57,7 +57,7 @@ function process(orders)
|
||||||
return -1
|
return -1
|
||||||
end
|
end
|
||||||
|
|
||||||
write_grails("grails.txt")
|
write_stats("grails.txt")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
function write_buildings(file)
|
||||||
|
types = { "sawmill", "quarry", "mine", "lighthouse", "castle", "monument" }
|
||||||
|
for index, tname in types do
|
||||||
|
count = 0
|
||||||
|
best = nil
|
||||||
|
for r in regions() do
|
||||||
|
for b in r.buildings do
|
||||||
|
if b.type == tname then
|
||||||
|
count = count + 1
|
||||||
|
if best == nil then
|
||||||
|
best = b
|
||||||
|
else
|
||||||
|
if best.size<b.size then
|
||||||
|
best = b
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if best ~= nil then
|
||||||
|
file:write("\n" .. count .. " x " .. get_string("de", best.type) .. "\n")
|
||||||
|
file:write("- " .. fname(best) .. ", Groesse " .. best.size .. "\n")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,25 +1,26 @@
|
||||||
function write_grails(filename)
|
function write_grails(file)
|
||||||
grails = {}
|
grails = {}
|
||||||
for f in factions() do
|
for f in factions() do
|
||||||
if f.id ~= 0 then
|
|
||||||
for u in f.units do
|
for u in f.units do
|
||||||
if u:get_item("grail") > 0 then
|
if u:get_item("grail") > 0 then
|
||||||
if grails[f] == nil then
|
if grails[f.id] == nil then
|
||||||
grails[f] = u:get_item("grail")
|
grails[f.id] = u:get_item("grail")
|
||||||
else
|
else
|
||||||
grails[f] = grails[f] + u:get_item("grail")
|
grails[f.id] = grails[f.id] + u:get_item("grail")
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local file = io.open(reportpath .. "/" .. filename, "w")
|
|
||||||
file:write("Parteien mit mehr oder weniger als einem Gral:\n")
|
file:write("Parteien mit mehr oder weniger als einem Gral:\n")
|
||||||
for k, v in grails do
|
|
||||||
|
for k in factions() do
|
||||||
|
v = 0
|
||||||
|
if grails[k.id] ~= nil then
|
||||||
|
v = grails[k.id]
|
||||||
|
end
|
||||||
if v~= 1 then
|
if v~= 1 then
|
||||||
file:write("- " .. v .. " Grale: " .. k.name .. " (" .. itoa36(k.id) .. ")\n")
|
file:write("- " .. v .. " Grale: " .. k.name .. " (" .. itoa36(k.id) .. ")\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
file:close()
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,10 +5,11 @@ end
|
||||||
buildings = {}
|
buildings = {}
|
||||||
|
|
||||||
function portal_exchange(b1, param)
|
function portal_exchange(b1, param)
|
||||||
b2 = buildings[param]
|
id = buildings[param]
|
||||||
if buildings[param] == nil then
|
if id == nil then
|
||||||
buildings[param] = b1
|
buildings[param] = b1.id
|
||||||
else
|
else
|
||||||
|
b2 = get_building(id)
|
||||||
u1 = gate_units(b1, 100)
|
u1 = gate_units(b1, 100)
|
||||||
u2 = gate_units(b2, 100)
|
u2 = gate_units(b2, 100)
|
||||||
gate_travel(b1, u2)
|
gate_travel(b1, u2)
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
function fname(f)
|
||||||
|
return f.name .. " (" .. itoa36(f.id) .. ")"
|
||||||
|
end
|
||||||
|
|
||||||
|
function write_spoils(file)
|
||||||
|
items = { "elfspoil", "demonspoil", "goblinspoil", "dwarfspoil", "halflingspoil", "humanspoil", "aquarianspoil", "insectspoil", "catspoil", "orcspoil", "trollspoil" }
|
||||||
|
for index, iname in items do
|
||||||
|
printed = false
|
||||||
|
for f in factions() do
|
||||||
|
trophies = 0
|
||||||
|
for u in f.units do
|
||||||
|
if u:get_item(iname) > 0 then
|
||||||
|
trophies = trophies + u:get_item(iname)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if trophies > 0 then
|
||||||
|
if not printed then
|
||||||
|
file:write(get_string("de", iname .. "_p") .. "\n")
|
||||||
|
printed=true
|
||||||
|
end
|
||||||
|
if trophies == 1 then
|
||||||
|
istr = get_string("de", iname)
|
||||||
|
else
|
||||||
|
istr = get_string("de", iname .. "_p")
|
||||||
|
end
|
||||||
|
file:write("- " .. trophies .. " " .. istr .. ": " .. fname(f) .. "\n")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,15 @@
|
||||||
|
dofile(scriptpath .. "/hse05-grails.lua")
|
||||||
|
dofile(scriptpath .. "/hse05-spoils.lua")
|
||||||
|
dofile(scriptpath .. "/hse05-buildings.lua")
|
||||||
|
|
||||||
|
function write_stats(filename)
|
||||||
|
local file = io.open(reportpath .. "/" .. filename, "w")
|
||||||
|
print("grails")
|
||||||
|
write_grails(file)
|
||||||
|
file:write("\n")
|
||||||
|
print("spoils")
|
||||||
|
write_spoils(file)
|
||||||
|
print("buildings")
|
||||||
|
write_buildings(file)
|
||||||
|
file:close()
|
||||||
|
end
|
Loading…
Reference in New Issue