server/src/bind_faction.c

575 lines
16 KiB
C
Raw Normal View History

2010-08-08 10:06:34 +02:00
/* vi: set ts=2:
+-------------------+
| | Enno Rehling <enno@eressea.de>
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
| (c) 1998 - 2008 | Katja Zedel <katze@felidae.kn-bremen.de>
| | Henning Peters <faroul@beyond.kn-bremen.de>
+-------------------+
This program may not be used, modified or distributed
without prior permission by the authors of Eressea.
*/
#include <platform.h>
#include <kernel/types.h>
2010-08-08 10:06:34 +02:00
#include "bind_faction.h"
#include "bind_unit.h"
#include "bindings.h"
#include <kernel/alliance.h>
#include <kernel/faction.h>
2010-08-08 10:06:34 +02:00
#include <kernel/config.h>
#include <kernel/unit.h>
#include <kernel/item.h>
#include <kernel/faction.h>
#include <kernel/plane.h>
#include <kernel/race.h>
#include <kernel/region.h>
#include <kernel/spellbook.h>
2010-08-08 10:06:34 +02:00
#include <util/language.h>
#include <util/log.h>
#include <quicklist.h>
2010-08-08 10:06:34 +02:00
#include <tolua.h>
#include <string.h>
2010-08-08 10:06:34 +02:00
2011-03-07 08:02:35 +01:00
int tolua_factionlist_next(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction **faction_ptr = (faction **) lua_touserdata(L, lua_upvalueindex(1));
faction *f = *faction_ptr;
2010-08-08 10:06:34 +02:00
if (f != NULL) {
2011-03-07 08:02:35 +01:00
tolua_pushusertype(L, (void *)f, TOLUA_CAST "faction");
2010-08-08 10:06:34 +02:00
*faction_ptr = f->next;
return 1;
2011-03-07 08:02:35 +01:00
} else
return 0; /* no more values to return */
2010-08-08 10:06:34 +02:00
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_get_units(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
unit **unit_ptr = (unit **) lua_newuserdata(L, sizeof(unit *));
2010-08-08 10:06:34 +02:00
luaL_getmetatable(L, TOLUA_CAST "unit");
lua_setmetatable(L, -2);
*unit_ptr = self->units;
lua_pushcclosure(L, tolua_unitlist_nextf, 1);
return 1;
}
2011-03-07 08:02:35 +01:00
int tolua_faction_add_item(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
const char *iname = tolua_tostring(L, 2, 0);
2010-08-08 10:06:34 +02:00
int number = (int)tolua_tonumber(L, 3, 0);
int result = -1;
2011-03-07 08:02:35 +01:00
if (iname != NULL) {
const resource_type *rtype = rt_find(iname);
if (rtype && rtype->itype) {
item *i = i_change(&self->items, rtype->itype, number);
2011-03-07 08:02:35 +01:00
result = i ? i->number : 0;
2011-03-07 17:26:50 +01:00
} /* if (itype!=NULL) */
2010-08-08 10:06:34 +02:00
}
lua_pushnumber(L, result);
return 1;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_get_maxheroes(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number) maxheroes(self));
2010-08-08 10:06:34 +02:00
return 1;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_get_heroes(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number) countheroes(self));
2010-08-08 10:06:34 +02:00
return 1;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_get_score(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number) self->score);
2010-08-08 10:06:34 +02:00
return 1;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_get_id(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number) self->no);
2010-08-08 10:06:34 +02:00
return 1;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_set_id(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
2010-08-08 10:06:34 +02:00
int id = (int)tolua_tonumber(L, 2, 0);
2011-03-07 08:02:35 +01:00
if (findfaction(id) == NULL) {
2010-08-08 10:06:34 +02:00
renumber_faction(self, id);
lua_pushboolean(L, 1);
} else {
lua_pushboolean(L, 0);
}
return 1;
}
static int tolua_faction_get_magic(lua_State * L)
{
faction *self = (faction *) tolua_tousertype(L, 1, 0);
lua_pushstring(L, magic_school[self->magiegebiet]);
return 1;
}
static int tolua_faction_set_magic(lua_State * L)
{
faction *self = (faction *) tolua_tousertype(L, 1, 0);
const char *type = tolua_tostring(L, 2, 0);
int mtype;
for (mtype = 0; mtype != MAXMAGIETYP; ++mtype) {
if (strcmp(magic_school[mtype], type) == 0) {
self->magiegebiet = (magic_t)mtype;
break;
}
}
return 0;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_get_age(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number) self->age);
2010-08-08 10:06:34 +02:00
return 1;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_set_age(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
2010-08-08 10:06:34 +02:00
int age = (int)tolua_tonumber(L, 2, 0);
self->age = age;
return 0;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_get_flags(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number) self->flags);
2010-08-08 10:06:34 +02:00
return 1;
}
2013-02-24 02:23:47 +01:00
static int tolua_faction_set_flags(lua_State * L)
{
faction *self = (faction *) tolua_tousertype(L, 1, 0);
int flags = (int)tolua_tonumber(L, 2, self->flags);
self->flags = flags;
return 1;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_get_options(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number) self->options);
2010-08-08 10:06:34 +02:00
return 1;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_set_options(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
2010-08-08 10:06:34 +02:00
int options = (int)tolua_tonumber(L, 2, self->options);
self->options = options;
return 1;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_get_lastturn(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number) self->lastorders);
2010-08-08 10:06:34 +02:00
return 1;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_set_lastturn(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
2010-08-08 10:06:34 +02:00
if (self) {
self->lastorders = (int)tolua_tonumber(L, 2, self->lastorders);
}
return 0;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_renumber(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
2010-08-08 10:06:34 +02:00
int no = (int)tolua_tonumber(L, 2, 0);
renumber_faction(self, no);
return 0;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_get_objects(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
tolua_pushusertype(L, (void *)&self->attribs, TOLUA_CAST "hashtable");
2010-08-08 10:06:34 +02:00
return 1;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_get_policy(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
faction *other = (faction *) tolua_tousertype(L, 2, 0);
const char *policy = tolua_tostring(L, 3, 0);
2010-08-08 10:06:34 +02:00
int result = 0, mode;
2011-03-07 08:02:35 +01:00
for (mode = 0; helpmodes[mode].name != NULL; ++mode) {
if (strcmp(policy, helpmodes[mode].name) == 0) {
2010-08-08 10:06:34 +02:00
result = get_alliance(self, other) & mode;
break;
}
}
2011-03-07 08:02:35 +01:00
tolua_pushnumber(L, (lua_Number) result);
2010-08-08 10:06:34 +02:00
return 1;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_set_policy(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
faction *other = (faction *) tolua_tousertype(L, 2, 0);
const char *policy = tolua_tostring(L, 3, 0);
2010-08-08 10:06:34 +02:00
int value = tolua_toboolean(L, 4, 0);
int mode;
2011-03-07 08:02:35 +01:00
for (mode = 0; helpmodes[mode].name != NULL; ++mode) {
if (strcmp(policy, helpmodes[mode].name) == 0) {
2010-08-08 10:06:34 +02:00
if (value) {
2011-03-07 08:02:35 +01:00
set_alliance(self, other, get_alliance(self,
other) | helpmodes[mode].status);
2010-08-08 10:06:34 +02:00
} else {
2011-03-07 08:02:35 +01:00
set_alliance(self, other, get_alliance(self,
other) & ~helpmodes[mode].status);
2010-08-08 10:06:34 +02:00
}
break;
}
}
return 0;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_normalize(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *f = (faction *) tolua_tousertype(L, 1, 0);
region *r = (region *) tolua_tousertype(L, 2, 0);
2010-08-08 10:06:34 +02:00
if (r) {
2011-03-07 08:02:35 +01:00
plane *pl = rplane(r);
2010-08-08 10:06:34 +02:00
int nx = r->x, ny = r->y;
pnormalize(&nx, &ny, pl);
adjust_coordinates(f, &nx, &ny, pl, r);
2011-03-07 08:02:35 +01:00
tolua_pushnumber(L, (lua_Number) nx);
tolua_pushnumber(L, (lua_Number) ny);
2010-08-08 10:06:34 +02:00
return 2;
}
return 0;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_set_origin(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *f = (faction *) tolua_tousertype(L, 1, 0);
region *r = (region *) tolua_tousertype(L, 2, 0);
plane *pl = rplane(r);
int id = pl ? pl->id : 0;
2010-08-08 10:06:34 +02:00
set_ursprung(f, id, r->x - plane_center_x(pl), r->y - plane_center_y(pl));
return 0;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_get_origin(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
ursprung *origin = self->ursprung;
2010-08-08 10:06:34 +02:00
int x, y;
2011-03-07 08:02:35 +01:00
while (origin != NULL && origin->id != 0) {
2010-08-08 10:06:34 +02:00
origin = origin->next;
}
if (origin) {
x = origin->x;
y = origin->y;
} else {
x = 0;
y = 0;
}
2011-03-07 08:02:35 +01:00
tolua_pushnumber(L, (lua_Number) x);
tolua_pushnumber(L, (lua_Number) y);
2010-08-08 10:06:34 +02:00
return 2;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_destroy(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *f = (faction *) tolua_tousertype(L, 1, 0);
2010-08-08 10:06:34 +02:00
destroyfaction(f);
return 0;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_create(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
const char *email = tolua_tostring(L, 1, 0);
const char *racename = tolua_tostring(L, 2, 0);
const char *lang = tolua_tostring(L, 3, 0);
struct locale *loc = get_locale(lang);
2011-03-07 08:02:35 +01:00
faction *f = NULL;
const struct race *frace = rc_find(racename);
if (frace != NULL) {
2010-08-08 10:06:34 +02:00
f = addfaction(email, NULL, frace, loc, 0);
}
if (!f) {
log_error("faction.create(%s, %s, %s)\n", email, racename, lang);
2010-08-08 10:06:34 +02:00
}
tolua_pushusertype(L, f, TOLUA_CAST "faction");
return 1;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_get_password(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
2010-08-08 10:06:34 +02:00
tolua_pushstring(L, faction_getpassword(self));
return 1;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_set_password(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
2010-08-08 10:06:34 +02:00
faction_setpassword(self, tolua_tostring(L, 2, 0));
return 0;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_get_email(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
2010-08-08 10:06:34 +02:00
tolua_pushstring(L, faction_getemail(self));
return 1;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_set_email(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
2010-08-08 10:06:34 +02:00
faction_setemail(self, tolua_tostring(L, 2, 0));
return 0;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_get_locale(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
2010-08-08 10:06:34 +02:00
tolua_pushstring(L, locale_name(self->locale));
return 1;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_set_locale(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
const char *name = tolua_tostring(L, 2, 0);
const struct locale *loc = get_locale(name);
if (loc) {
self->locale = loc;
}
else {
tolua_pushstring(L, "invalid locale");
return 1;
}
2010-08-08 10:06:34 +02:00
return 0;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_get_race(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
tolua_pushstring(L, self->race->_name);
2010-08-08 10:06:34 +02:00
return 1;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_set_race(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
const char *name = tolua_tostring(L, 2, 0);
const race *rc = rc_find(name);
2011-03-07 08:02:35 +01:00
if (rc != NULL) {
2010-08-08 10:06:34 +02:00
self->race = rc;
}
return 0;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_get_name(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
2010-08-08 10:06:34 +02:00
tolua_pushstring(L, faction_getname(self));
return 1;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_set_name(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
2010-08-08 10:06:34 +02:00
faction_setname(self, tolua_tostring(L, 2, 0));
return 0;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_get_uid(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *f = (faction *) tolua_tousertype(L, 1, 0);
2010-08-08 10:06:34 +02:00
tolua_pushnumber(L, f->subscription);
return 1;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_set_uid(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *f = (faction *) tolua_tousertype(L, 1, 0);
2010-08-08 10:06:34 +02:00
f->subscription = (int)tolua_tonumber(L, 2, 0);
return 0;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_get_info(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
2010-08-08 10:06:34 +02:00
tolua_pushstring(L, faction_getbanner(self));
return 1;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_set_info(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
2010-08-08 10:06:34 +02:00
faction_setbanner(self, tolua_tostring(L, 2, 0));
return 0;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_get_alliance(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
2010-08-08 10:06:34 +02:00
tolua_pushusertype(L, f_get_alliance(self), TOLUA_CAST "alliance");
return 1;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_set_alliance(lua_State * L)
2010-08-08 10:06:34 +02:00
{
struct faction *self = (struct faction *)tolua_tousertype(L, 1, 0);
struct alliance *alli = (struct alliance *) tolua_tousertype(L, 2, 0);
2010-08-08 10:06:34 +02:00
setalliance(self, alli);
return 0;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_get_items(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
item **item_ptr = (item **) lua_newuserdata(L, sizeof(item *));
2010-08-08 10:06:34 +02:00
luaL_getmetatable(L, TOLUA_CAST "item");
lua_setmetatable(L, -2);
*item_ptr = self->items;
lua_pushcclosure(L, tolua_itemlist_next, 1);
return 1;
}
2011-03-07 08:02:35 +01:00
static int tolua_faction_tostring(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
2010-08-08 10:06:34 +02:00
lua_pushstring(L, factionname(self));
return 1;
}
#ifdef TODO /* these usertypes are undefined */
2011-03-07 08:02:35 +01:00
static int tolua_faction_get_spells(lua_State * L)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
faction *self = (faction *) tolua_tousertype(L, 1, 0);
return tolua_quicklist_push(L, "spellbook", "spellbook_entry", self->spellbook->spells);
2010-08-08 10:06:34 +02:00
}
#endif
2010-08-08 10:06:34 +02:00
2011-03-07 08:02:35 +01:00
void tolua_faction_open(lua_State * L)
2010-08-08 10:06:34 +02:00
{
/* register user types */
tolua_usertype(L, TOLUA_CAST "faction");
tolua_usertype(L, TOLUA_CAST "faction_list");
tolua_module(L, NULL, 0);
tolua_beginmodule(L, NULL);
{
2011-03-07 08:02:35 +01:00
tolua_cclass(L, TOLUA_CAST "faction", TOLUA_CAST "faction", TOLUA_CAST "",
NULL);
2010-08-08 10:06:34 +02:00
tolua_beginmodule(L, TOLUA_CAST "faction");
{
tolua_function(L, TOLUA_CAST "__tostring", tolua_faction_tostring);
2011-03-07 08:02:35 +01:00
tolua_variable(L, TOLUA_CAST "id", tolua_faction_get_id,
tolua_faction_set_id);
tolua_variable(L, TOLUA_CAST "uid", &tolua_faction_get_uid,
&tolua_faction_set_uid);
tolua_variable(L, TOLUA_CAST "name", &tolua_faction_get_name,
&tolua_faction_set_name);
tolua_variable(L, TOLUA_CAST "info", &tolua_faction_get_info,
&tolua_faction_set_info);
2010-08-08 10:06:34 +02:00
tolua_variable(L, TOLUA_CAST "units", tolua_faction_get_units, NULL);
tolua_variable(L, TOLUA_CAST "heroes", tolua_faction_get_heroes, NULL);
#ifdef TODO
2010-08-08 10:06:34 +02:00
tolua_variable(L, TOLUA_CAST "spells", tolua_faction_get_spells, 0);
#endif
2011-03-07 08:02:35 +01:00
tolua_variable(L, TOLUA_CAST "maxheroes", tolua_faction_get_maxheroes,
NULL);
tolua_variable(L, TOLUA_CAST "password", tolua_faction_get_password,
tolua_faction_set_password);
tolua_variable(L, TOLUA_CAST "email", tolua_faction_get_email,
tolua_faction_set_email);
tolua_variable(L, TOLUA_CAST "locale", tolua_faction_get_locale,
tolua_faction_set_locale);
tolua_variable(L, TOLUA_CAST "race", tolua_faction_get_race,
tolua_faction_set_race);
tolua_variable(L, TOLUA_CAST "alliance", tolua_faction_get_alliance,
tolua_faction_set_alliance);
2010-08-08 10:06:34 +02:00
tolua_variable(L, TOLUA_CAST "score", tolua_faction_get_score, NULL);
tolua_variable(L, TOLUA_CAST "magic", &tolua_faction_get_magic,
tolua_faction_set_magic);
2011-03-07 08:02:35 +01:00
tolua_variable(L, TOLUA_CAST "age", tolua_faction_get_age,
tolua_faction_set_age);
tolua_variable(L, TOLUA_CAST "options", tolua_faction_get_options,
tolua_faction_set_options);
2013-02-24 02:23:47 +01:00
tolua_variable(L, TOLUA_CAST "flags", tolua_faction_get_flags, tolua_faction_set_flags);
2011-03-07 08:02:35 +01:00
tolua_variable(L, TOLUA_CAST "lastturn", tolua_faction_get_lastturn,
tolua_faction_set_lastturn);
2010-08-08 10:06:34 +02:00
tolua_function(L, TOLUA_CAST "set_policy", &tolua_faction_set_policy);
tolua_function(L, TOLUA_CAST "get_policy", &tolua_faction_get_policy);
tolua_function(L, TOLUA_CAST "get_origin", &tolua_faction_get_origin);
tolua_function(L, TOLUA_CAST "set_origin", &tolua_faction_set_origin);
tolua_function(L, TOLUA_CAST "normalize", &tolua_faction_normalize);
tolua_function(L, TOLUA_CAST "add_item", tolua_faction_add_item);
tolua_variable(L, TOLUA_CAST "items", tolua_faction_get_items, NULL);
tolua_function(L, TOLUA_CAST "renumber", &tolua_faction_renumber);
tolua_function(L, TOLUA_CAST "create", &tolua_faction_create);
tolua_function(L, TOLUA_CAST "destroy", &tolua_faction_destroy);
#ifdef TODO
2011-03-07 08:02:35 +01:00
def("faction_origin", &faction_getorigin,
pure_out_value(_2) + pure_out_value(_3)),.def_readwrite("subscription",
&faction::subscription)
2010-08-08 10:06:34 +02:00
2011-03-07 08:02:35 +01:00
.property("x", &faction_getorigin_x, &faction_setorigin_x)
.property("y", &faction_getorigin_y, &faction_setorigin_y)
2010-08-08 10:06:34 +02:00
2011-03-07 08:02:35 +01:00
.def("add_notice", &faction_addnotice)
2010-08-08 10:06:34 +02:00
#endif
2011-03-07 08:02:35 +01:00
tolua_variable(L, TOLUA_CAST "objects", tolua_faction_get_objects,
NULL);
2010-08-08 10:06:34 +02:00
}
tolua_endmodule(L);
}
tolua_endmodule(L);
}