diff --git a/src/Jamrules b/src/Jamrules index 2707f2919..5a0cd982c 100644 --- a/src/Jamrules +++ b/src/Jamrules @@ -34,7 +34,11 @@ CCFLAGS += -Wwrite-strings ; # this require the latet luabind from CVS -C++FLAGS += -DHAVE_LUABIND_B7 ; +if ! $(LUABIND) { + LUABIND = "B7" ; +} + +C++FLAGS += -DHAVE_LUABIND_$(LUABIND) ; if $(HOST) = "hamunaptra" { XMLHDRS = /homes2/info-f/enno/software/hamunaptra/include/libxml2 ; } else { diff --git a/src/eressea/lua/building.cpp b/src/eressea/lua/building.cpp index 4131bc49c..9b4fe1e5b 100644 --- a/src/eressea/lua/building.cpp +++ b/src/eressea/lua/building.cpp @@ -177,7 +177,7 @@ bind_building(lua_State * L) .property("info", &building_getinfo, &building_setinfo) .property("units", &building_units, return_stl_iterator) .property("region", &building_getregion, &building_setregion) - .def("type", &building_gettype) + .property("type", &building_gettype) .def_readonly("id", &building::no) .def_readwrite("size", &building::size) .def("add_action", &building_addaction) diff --git a/src/eressea/lua/region.cpp b/src/eressea/lua/region.cpp index 8921ef701..48a4142c8 100644 --- a/src/eressea/lua/region.cpp +++ b/src/eressea/lua/region.cpp @@ -4,6 +4,7 @@ // kernel includes #include +#include #include #include #include @@ -106,6 +107,15 @@ region_setflag(region& r, int bit, bool set) else r.flags &= ~(1<name[0]; +} + + void bind_ship(lua_State * L) { @@ -54,6 +60,7 @@ bind_ship(lua_State * L) class_("ship") .def(self == ship()) .def(tostring(self)) + .property("type", &ship_gettype) .def_readonly("name", &ship::name) .def_readonly("region", &ship::region) .def_readonly("id", &ship::no) diff --git a/src/res/hse-05-01.xml b/src/res/hse-05-01.xml index 3e1be774c..2ded0e534 100644 --- a/src/res/hse-05-01.xml +++ b/src/res/hse-05-01.xml @@ -27,7 +27,7 @@ - + @@ -45,8 +45,8 @@ - hse-server@eressea.upb.de - hse-server@eressea.upb.de + hse-server@eressea.de + hse-server@eressea.de ERESSEA BEFEHLE diff --git a/src/scripts/gates.lua b/src/scripts/gates.lua index 1b6cc998b..24c026e58 100644 --- a/src/scripts/gates.lua +++ b/src/scripts/gates.lua @@ -11,16 +11,11 @@ function gate_units(b, maxsize) local size = maxsize local units = {} local u - local first = true for u in b.units do - if first then - first = false - else - if u.number<=size and u.weight<=u.capacity then - units[u] = u - size = size - u.number - end + if u.number<=size and u.weight<=u.capacity then + units[u] = u + size = size - u.number end end return units diff --git a/src/scripts/hse05-01.lua b/src/scripts/hse05-01.lua index 2fc02c028..c2344fa54 100644 --- a/src/scripts/hse05-01.lua +++ b/src/scripts/hse05-01.lua @@ -1,7 +1,7 @@ function run_scripts() scripts = { "hse05-portals.lua", - "hse05-grails.lua" + "hse05-stats.lua" } for index in scripts do local script = scriptpath .. "/" .. scripts[index] @@ -57,7 +57,7 @@ function process(orders) return -1 end - write_grails("grails.txt") + write_stats("grails.txt") end diff --git a/src/scripts/hse05-buildings.lua b/src/scripts/hse05-buildings.lua new file mode 100644 index 000000000..1d7aab6bf --- /dev/null +++ b/src/scripts/hse05-buildings.lua @@ -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 0 then - if grails[f] == nil then - grails[f] = u:get_item("grail") - else - grails[f] = grails[f] + u:get_item("grail") - end + for u in f.units do + if u:get_item("grail") > 0 then + if grails[f.id] == nil then + grails[f.id] = u:get_item("grail") + else + grails[f.id] = grails[f.id] + u:get_item("grail") end end end end - local file = io.open(reportpath .. "/" .. filename, "w") file:write("Parteien mit mehr oder weniger als einem Gral:\n") - for k, v in grails do - if v ~= 1 then + + for k in factions() do + v = 0 + if grails[k.id] ~= nil then + v = grails[k.id] + end + if v~= 1 then file:write("- " .. v .. " Grale: " .. k.name .. " (" .. itoa36(k.id) .. ")\n") end end - file:close() end diff --git a/src/scripts/hse05-portals.lua b/src/scripts/hse05-portals.lua index 857ea36f5..b8d4badae 100644 --- a/src/scripts/hse05-portals.lua +++ b/src/scripts/hse05-portals.lua @@ -5,10 +5,11 @@ end buildings = {} function portal_exchange(b1, param) - b2 = buildings[param] - if buildings[param] == nil then - buildings[param] = b1 + id = buildings[param] + if id == nil then + buildings[param] = b1.id else + b2 = get_building(id) u1 = gate_units(b1, 100) u2 = gate_units(b2, 100) gate_travel(b1, u2) diff --git a/src/scripts/hse05-spoils.lua b/src/scripts/hse05-spoils.lua new file mode 100644 index 000000000..f17e6448f --- /dev/null +++ b/src/scripts/hse05-spoils.lua @@ -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 diff --git a/src/scripts/hse05-stats.lua b/src/scripts/hse05-stats.lua new file mode 100644 index 000000000..32a012628 --- /dev/null +++ b/src/scripts/hse05-stats.lua @@ -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