forked from github/server
Siegbedingungen mit Namen abfragen in victorycondition(alliance, name)
+ Exportiert nach lua Bedingung Pyramide: + wenn erfüllt, muss in einer Partei (besser in allen) der atribut-key "pyra" gesetzt werden. Bedingung Phönix: + wenn erfüllt, muss in einer Partei (besser in allen) der atribut-key "phnx" gesetzt werden. Bedingung Handel: + Es wird getestet, ob die Allianz alle nötigen Edelsteine hat. Liste der Parteien einer Alianz nach lua exportiert
This commit is contained in:
parent
ff27aed2fb
commit
fd47232a21
|
@ -17,18 +17,22 @@
|
||||||
#include "alliance.h"
|
#include "alliance.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
|
|
||||||
|
#include <attributes/key.h>
|
||||||
|
|
||||||
/* kernel includes */
|
/* kernel includes */
|
||||||
#include <building.h>
|
#include <kernel/building.h>
|
||||||
#include <faction.h>
|
#include <kernel/faction.h>
|
||||||
#include <message.h>
|
#include <kernel/message.h>
|
||||||
#include <region.h>
|
#include <kernel/region.h>
|
||||||
#include <unit.h>
|
#include <kernel/unit.h>
|
||||||
|
#include <kernel/item.h>
|
||||||
|
|
||||||
/* util includes */
|
/* util includes */
|
||||||
#include <umlaut.h>
|
#include <umlaut.h>
|
||||||
#include <base36.h>
|
#include <base36.h>
|
||||||
|
|
||||||
/* libc includes */
|
/* libc includes */
|
||||||
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -276,4 +280,54 @@ alliancevictory(void)
|
||||||
al = al->next;
|
al = al->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
victorycondition(const alliance * al, const char * name)
|
||||||
|
{
|
||||||
|
const char * gems[] = { "opal", "diamond", "zaphire", "topaz", "beryl", "agate", "garnet", "emerald", NULL };
|
||||||
|
if (strcmp(name, "gems")==0) {
|
||||||
|
const char ** igem = gems;
|
||||||
|
|
||||||
|
for (;*igem;++igem) {
|
||||||
|
const struct item_type * itype = it_find(*igem);
|
||||||
|
faction_list * flist = al->members;
|
||||||
|
boolean found = false;
|
||||||
|
|
||||||
|
assert(itype!=NULL);
|
||||||
|
for (;flist && !found;flist=flist->next) {
|
||||||
|
unit * u = flist->data->units;
|
||||||
|
|
||||||
|
for (;u;u=u->nextF) {
|
||||||
|
if (i_get(u->items, itype)>0) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
} else if (strcmp(name, "phoenix")==0) {
|
||||||
|
faction_list * flist = al->members;
|
||||||
|
for (;flist;flist=flist->next) {
|
||||||
|
faction * f = flist->data;
|
||||||
|
if (find_key(f->attribs, atoi36("phnx"))) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
} else if (strcmp(name, "pyramid")==0) {
|
||||||
|
faction_list * flist = al->members;
|
||||||
|
for (;flist;flist=flist->next) {
|
||||||
|
faction * f = flist->data;
|
||||||
|
if (find_key(f->attribs, atoi36("pyra"))) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -44,6 +44,8 @@ extern void setalliance(struct faction * f, alliance * al);
|
||||||
extern void alliancejoin(void);
|
extern void alliancejoin(void);
|
||||||
extern void alliancekick(void);
|
extern void alliancekick(void);
|
||||||
extern void alliancevictory(void);
|
extern void alliancevictory(void);
|
||||||
|
|
||||||
|
extern int victorycondition(const alliance * al, const char * name);
|
||||||
/* execute commands */
|
/* execute commands */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -17,18 +17,22 @@
|
||||||
#include "alliance.h"
|
#include "alliance.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
|
|
||||||
|
#include <attributes/key.h>
|
||||||
|
|
||||||
/* kernel includes */
|
/* kernel includes */
|
||||||
#include <building.h>
|
#include <kernel/building.h>
|
||||||
#include <faction.h>
|
#include <kernel/faction.h>
|
||||||
#include <message.h>
|
#include <kernel/message.h>
|
||||||
#include <region.h>
|
#include <kernel/region.h>
|
||||||
#include <unit.h>
|
#include <kernel/unit.h>
|
||||||
|
#include <kernel/item.h>
|
||||||
|
|
||||||
/* util includes */
|
/* util includes */
|
||||||
#include <umlaut.h>
|
#include <umlaut.h>
|
||||||
#include <base36.h>
|
#include <base36.h>
|
||||||
|
|
||||||
/* libc includes */
|
/* libc includes */
|
||||||
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -276,4 +280,54 @@ alliancevictory(void)
|
||||||
al = al->next;
|
al = al->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
victorycondition(const alliance * al, const char * name)
|
||||||
|
{
|
||||||
|
const char * gems[] = { "opal", "diamond", "zaphire", "topaz", "beryl", "agate", "garnet", "emerald", NULL };
|
||||||
|
if (strcmp(name, "gems")==0) {
|
||||||
|
const char ** igem = gems;
|
||||||
|
|
||||||
|
for (;*igem;++igem) {
|
||||||
|
const struct item_type * itype = it_find(*igem);
|
||||||
|
faction_list * flist = al->members;
|
||||||
|
boolean found = false;
|
||||||
|
|
||||||
|
assert(itype!=NULL);
|
||||||
|
for (;flist && !found;flist=flist->next) {
|
||||||
|
unit * u = flist->data->units;
|
||||||
|
|
||||||
|
for (;u;u=u->nextF) {
|
||||||
|
if (i_get(u->items, itype)>0) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
} else if (strcmp(name, "phoenix")==0) {
|
||||||
|
faction_list * flist = al->members;
|
||||||
|
for (;flist;flist=flist->next) {
|
||||||
|
faction * f = flist->data;
|
||||||
|
if (find_key(f->attribs, atoi36("phnx"))) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
} else if (strcmp(name, "pyramid")==0) {
|
||||||
|
faction_list * flist = al->members;
|
||||||
|
for (;flist;flist=flist->next) {
|
||||||
|
faction * f = flist->data;
|
||||||
|
if (find_key(f->attribs, atoi36("pyra"))) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -44,6 +44,8 @@ extern void setalliance(struct faction * f, alliance * al);
|
||||||
extern void alliancejoin(void);
|
extern void alliancejoin(void);
|
||||||
extern void alliancekick(void);
|
extern void alliancekick(void);
|
||||||
extern void alliancevictory(void);
|
extern void alliancevictory(void);
|
||||||
|
|
||||||
|
extern int victorycondition(const alliance * al, const char * name);
|
||||||
/* execute commands */
|
/* execute commands */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -191,9 +191,6 @@
|
||||||
<File
|
<File
|
||||||
RelativePath=".\event.h">
|
RelativePath=".\event.h">
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\functions.h">
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\goodies.h">
|
RelativePath=".\goodies.h">
|
||||||
</File>
|
</File>
|
||||||
|
@ -224,6 +221,9 @@
|
||||||
<File
|
<File
|
||||||
RelativePath=".\resolve.h">
|
RelativePath=".\resolve.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\script.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\sql.h">
|
RelativePath=".\sql.h">
|
||||||
</File>
|
</File>
|
||||||
|
@ -267,9 +267,6 @@
|
||||||
<File
|
<File
|
||||||
RelativePath=".\event.c">
|
RelativePath=".\event.c">
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\functions.c">
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\goodies.c">
|
RelativePath=".\goodies.c">
|
||||||
</File>
|
</File>
|
||||||
|
@ -297,6 +294,9 @@
|
||||||
<File
|
<File
|
||||||
RelativePath=".\resolve.c">
|
RelativePath=".\resolve.c">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\script.c">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\sql.c">
|
RelativePath=".\sql.c">
|
||||||
</File>
|
</File>
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
// kernel includes
|
// kernel includes
|
||||||
#include <kernel/region.h>
|
#include <kernel/region.h>
|
||||||
|
#include <kernel/faction.h>
|
||||||
#include <modules/alliance.h>
|
#include <modules/alliance.h>
|
||||||
|
|
||||||
// lua includes
|
// lua includes
|
||||||
|
@ -13,6 +14,18 @@
|
||||||
|
|
||||||
using namespace luabind;
|
using namespace luabind;
|
||||||
|
|
||||||
|
class factionlist_iterator {
|
||||||
|
public:
|
||||||
|
static faction_list * next(faction_list * node) { return node->next; }
|
||||||
|
static faction * value(faction_list * node) { return node->data; }
|
||||||
|
};
|
||||||
|
|
||||||
|
static eressea::list<faction, faction_list, factionlist_iterator>
|
||||||
|
alliance_factions(const alliance& al)
|
||||||
|
{
|
||||||
|
return eressea::list<faction, faction_list, factionlist_iterator>(al.members);
|
||||||
|
}
|
||||||
|
|
||||||
static alliance *
|
static alliance *
|
||||||
add_alliance(int id, const char * name)
|
add_alliance(int id, const char * name)
|
||||||
{
|
{
|
||||||
|
@ -31,9 +44,10 @@ bind_alliance(lua_State * L)
|
||||||
def("alliances", &get_alliances, return_stl_iterator),
|
def("alliances", &get_alliances, return_stl_iterator),
|
||||||
def("get_alliance", &findalliance),
|
def("get_alliance", &findalliance),
|
||||||
def("add_alliance", &add_alliance),
|
def("add_alliance", &add_alliance),
|
||||||
|
def("victorycondition", &victorycondition),
|
||||||
class_<struct alliance>("alliance")
|
class_<struct alliance>("alliance")
|
||||||
.def_readonly("name", &alliance::name)
|
.def_readonly("name", &alliance::name)
|
||||||
.def_readonly("id", &alliance::id)
|
.def_readonly("id", &alliance::id)
|
||||||
|
.property("factions", &alliance_factions, return_stl_iterator)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,18 @@
|
||||||
#include <kernel/save.h>
|
#include <kernel/save.h>
|
||||||
#include <kernel/unit.h>
|
#include <kernel/unit.h>
|
||||||
#include <util/language.h>
|
#include <util/language.h>
|
||||||
|
#ifdef ALLIANCES
|
||||||
|
# include <modules/alliance.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
// lua includes
|
// lua includes
|
||||||
#include <lua.hpp>
|
#include <lua.hpp>
|
||||||
#include <luabind/luabind.hpp>
|
#include <luabind/luabind.hpp>
|
||||||
#include <luabind/iterator_policy.hpp>
|
#include <luabind/iterator_policy.hpp>
|
||||||
|
|
||||||
|
// util includes
|
||||||
|
#include <util/base36.h>
|
||||||
|
|
||||||
using namespace luabind;
|
using namespace luabind;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -64,6 +70,8 @@ void
|
||||||
bind_eressea(lua_State * L)
|
bind_eressea(lua_State * L)
|
||||||
{
|
{
|
||||||
module(L)[
|
module(L)[
|
||||||
|
def("atoi36", &atoi36),
|
||||||
|
def("itoa36", &itoa36),
|
||||||
def("read_game", &read_game),
|
def("read_game", &read_game),
|
||||||
def("write_game", &write_game),
|
def("write_game", &write_game),
|
||||||
def("write_passwords", &writepasswd),
|
def("write_passwords", &writepasswd),
|
||||||
|
|
|
@ -76,10 +76,10 @@
|
||||||
#include <item.h>
|
#include <item.h>
|
||||||
|
|
||||||
/* util includes */
|
/* util includes */
|
||||||
#include <rand.h>
|
#include <util/rand.h>
|
||||||
#include <log.h>
|
#include <util/log.h>
|
||||||
#include <sql.h>
|
#include <util/sql.h>
|
||||||
#include <base36.h>
|
#include <util/base36.h>
|
||||||
|
|
||||||
/* lua includes */
|
/* lua includes */
|
||||||
#include "lua/bindings.h"
|
#include "lua/bindings.h"
|
||||||
|
@ -561,7 +561,6 @@ usage(const char * prog, const char * arg)
|
||||||
"-o reportdir : gibt das reportverzeichnis an\n"
|
"-o reportdir : gibt das reportverzeichnis an\n"
|
||||||
"-l logfile : specify an alternative logfile\n"
|
"-l logfile : specify an alternative logfile\n"
|
||||||
"-R : erstellt nur die Reports neu\n"
|
"-R : erstellt nur die Reports neu\n"
|
||||||
"--noeiswald : beruhigt ungemein\n"
|
|
||||||
"--nomsg : keine Messages (RAM sparen)\n"
|
"--nomsg : keine Messages (RAM sparen)\n"
|
||||||
"--nobattle : keine Kämpfe\n"
|
"--nobattle : keine Kämpfe\n"
|
||||||
"--nomonsters : keine monster KI\n"
|
"--nomonsters : keine monster KI\n"
|
||||||
|
@ -657,7 +656,6 @@ read_args(int argc, char **argv, lua_State * luaState)
|
||||||
case 'v':
|
case 'v':
|
||||||
if (i<argc) {
|
if (i<argc) {
|
||||||
orders = argv[++i];
|
orders = argv[++i];
|
||||||
setLuaString(luaState, "orderfile", orders);
|
|
||||||
} else {
|
} else {
|
||||||
return usage(argv[0], argv[i]);
|
return usage(argv[0], argv[i]);
|
||||||
}
|
}
|
||||||
|
@ -701,6 +699,14 @@ read_args(int argc, char **argv, lua_State * luaState)
|
||||||
usage(argv[0], argv[i]);
|
usage(argv[0], argv[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* add some more variables to the lua globals */
|
||||||
|
setLuaString(luaState, "datapath", datapath());
|
||||||
|
setLuaString(luaState, "basepath", basepath());
|
||||||
|
setLuaString(luaState, "reportpath", reportpath());
|
||||||
|
setLuaString(luaState, "resourcepath", resourcepath());
|
||||||
|
setLuaString(luaState, "orderfile", orders);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
<eressea>
|
<eressea>
|
||||||
<include file="messages.xml"></include>
|
|
||||||
|
|
||||||
<include file="vinyambar/de/strings.xml"></include>
|
|
||||||
<include file="vinyambar/wdw-races.xml"></include>
|
|
||||||
<include file="vinyambar/wdw-resources.xml"></include>
|
|
||||||
|
|
||||||
<comment>Localization</comment>
|
<comment>Localization</comment>
|
||||||
|
<comment>Strings MUST always be read first</comment>
|
||||||
|
<include file="vinyambar/de/strings.xml"></include>
|
||||||
<include file="de/strings.xml"></include>
|
<include file="de/strings.xml"></include>
|
||||||
<include file="en/strings.xml"></include>
|
<include file="en/strings.xml"></include>
|
||||||
|
<include file="messages.xml"></include>
|
||||||
|
|
||||||
|
<include file="vinyambar/wdw-races.xml"></include>
|
||||||
|
<include file="vinyambar/wdw-resources.xml"></include>
|
||||||
|
|
||||||
<include file="races.xml"></include>
|
<include file="races.xml"></include>
|
||||||
<include file="resources.xml"></include>
|
<include file="resources.xml"></include>
|
||||||
|
|
|
@ -14,3 +14,126 @@
|
||||||
<text locale="en">scrolls</text>
|
<text locale="en">scrolls</text>
|
||||||
</string>
|
</string>
|
||||||
</strings>
|
</strings>
|
||||||
|
|
||||||
|
<strings>
|
||||||
|
<string name="gem">
|
||||||
|
<text locale="de">Edelstein</text>
|
||||||
|
<text locale="en">gem</text>
|
||||||
|
</string>
|
||||||
|
<string name="gem_p">
|
||||||
|
<text locale="de">Edelsteine</text>
|
||||||
|
<text locale="en">gems</text>
|
||||||
|
</string>
|
||||||
|
</strings>
|
||||||
|
|
||||||
|
<resource name="opal" appearance="gem">
|
||||||
|
<item weight="0"></item>
|
||||||
|
</resource>
|
||||||
|
<strings>
|
||||||
|
<string name="opal">
|
||||||
|
<text locale="de">Opal</text>
|
||||||
|
<text locale="en">opal</text>
|
||||||
|
</string>
|
||||||
|
<string name="opal_p">
|
||||||
|
<text locale="de">Opale</text>
|
||||||
|
<text locale="en">opals</text>
|
||||||
|
</string>
|
||||||
|
</strings>
|
||||||
|
|
||||||
|
<resource name="diamond" appearance="gem">
|
||||||
|
<item weight="0"></item>
|
||||||
|
</resource>
|
||||||
|
<strings>
|
||||||
|
<string name="diamond">
|
||||||
|
<text locale="de">Diamant</text>
|
||||||
|
<text locale="en">diamond</text>
|
||||||
|
</string>
|
||||||
|
<string name="diamond_p">
|
||||||
|
<text locale="de">Diamanten</text>
|
||||||
|
<text locale="en">diamonds</text>
|
||||||
|
</string>
|
||||||
|
</strings>
|
||||||
|
|
||||||
|
<resource name="zaphire" appearance="gem">
|
||||||
|
<item weight="0"></item>
|
||||||
|
</resource>
|
||||||
|
<strings>
|
||||||
|
<string name="zaphire">
|
||||||
|
<text locale="de">Saphir</text>
|
||||||
|
<text locale="en">zaphire</text>
|
||||||
|
</string>
|
||||||
|
<string name="zaphire_p">
|
||||||
|
<text locale="de">Saphire</text>
|
||||||
|
<text locale="en">zaphires</text>
|
||||||
|
</string>
|
||||||
|
</strings>
|
||||||
|
|
||||||
|
<resource name="topaz" appearance="gem">
|
||||||
|
<item weight="0"></item>
|
||||||
|
</resource>
|
||||||
|
<strings>
|
||||||
|
<string name="topaz">
|
||||||
|
<text locale="de">Topas</text>
|
||||||
|
<text locale="en">topaz</text>
|
||||||
|
</string>
|
||||||
|
<string name="topaz_p">
|
||||||
|
<text locale="de">Topase</text>
|
||||||
|
<text locale="en">topazes</text>
|
||||||
|
</string>
|
||||||
|
</strings>
|
||||||
|
|
||||||
|
<resource name="beryl" appearance="gem">
|
||||||
|
<item weight="0"></item>
|
||||||
|
</resource>
|
||||||
|
<strings>
|
||||||
|
<string name="beryl">
|
||||||
|
<text locale="de">Beryll</text>
|
||||||
|
<text locale="en">beryl</text>
|
||||||
|
</string>
|
||||||
|
<string name="beryl_p">
|
||||||
|
<text locale="de">Berylle</text>
|
||||||
|
<text locale="en">beryls</text>
|
||||||
|
</string>
|
||||||
|
</strings>
|
||||||
|
|
||||||
|
<resource name="agate" appearance="gem">
|
||||||
|
<item weight="0"></item>
|
||||||
|
</resource>
|
||||||
|
<strings>
|
||||||
|
<string name="agate">
|
||||||
|
<text locale="de">Achat</text>
|
||||||
|
<text locale="en">agate</text>
|
||||||
|
</string>
|
||||||
|
<string name="agate_p">
|
||||||
|
<text locale="de">Achate</text>
|
||||||
|
<text locale="en">agates</text>
|
||||||
|
</string>
|
||||||
|
</strings>
|
||||||
|
|
||||||
|
<resource name="garnet" appearance="gem">
|
||||||
|
<item weight="0"></item>
|
||||||
|
</resource>
|
||||||
|
<strings>
|
||||||
|
<string name="garnet">
|
||||||
|
<text locale="de">Granat</text>
|
||||||
|
<text locale="en">garnet</text>
|
||||||
|
</string>
|
||||||
|
<string name="garnet_p">
|
||||||
|
<text locale="de">Granate</text>
|
||||||
|
<text locale="en">garnets</text>
|
||||||
|
</string>
|
||||||
|
</strings>
|
||||||
|
|
||||||
|
<resource name="emerald" appearance="gem">
|
||||||
|
<item weight="0"></item>
|
||||||
|
</resource>
|
||||||
|
<strings>
|
||||||
|
<string name="emerald">
|
||||||
|
<text locale="de">Smaragd</text>
|
||||||
|
<text locale="en">emerald</text>
|
||||||
|
</string>
|
||||||
|
<string name="emerald_p">
|
||||||
|
<text locale="de">Smaragde</text>
|
||||||
|
<text locale="en">emeralds</text>
|
||||||
|
</string>
|
||||||
|
</strings>
|
||||||
|
|
Loading…
Reference in New Issue