forked from github/server
Weihnachtsevent mit dickem Gnom und Sonnensegeln, jetzt komplett implementiert.
Beinhaltet Partei-Inventory und neuen Befehl CLAIM / BEANSPRUCHEN.
This commit is contained in:
parent
d4da3b1223
commit
080a9a8bba
|
@ -746,6 +746,7 @@ cr_output_unit(FILE * F, const region * r,
|
|||
fputs("1;hero\n", F);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (fval(u, UFL_HUNGER) && (u->faction == f)) {
|
||||
fputs("1;hunger\n", F);
|
||||
}
|
||||
|
@ -753,7 +754,6 @@ cr_output_unit(FILE * F, const region * r,
|
|||
fprintf(F, "%d;Aura\n", get_spellpoints(u));
|
||||
fprintf(F, "%d;Auramax\n", max_spellpoints(u->region,u));
|
||||
}
|
||||
|
||||
/* default commands */
|
||||
fprintf(F, "COMMANDS\n");
|
||||
if (u->lastorder) {
|
||||
|
@ -1085,6 +1085,7 @@ report_computer(FILE * F, faction * f, const faction_list * addresses,
|
|||
const time_t report_time)
|
||||
{
|
||||
int i;
|
||||
item * itm;
|
||||
const char * prefix;
|
||||
region * r;
|
||||
building *b;
|
||||
|
@ -1159,6 +1160,12 @@ report_computer(FILE * F, faction * f, const faction_list * addresses,
|
|||
fprintf(F, "\"%s\";Parteiname\n", f->name);
|
||||
fprintf(F, "\"%s\";email\n", f->email);
|
||||
fprintf(F, "\"%s\";banner\n", f->banner);
|
||||
for (itm=f->items; itm; itm=itm->next) {
|
||||
int in = itm->number;
|
||||
const char * ic = LOC(f->locale, resourcename(itm->type->rtype, in));
|
||||
if (itm==f->items) fputs("GEGENSTAENDE\n", F);
|
||||
fprintf(F, "%d;%s\n", in, add_translation(ic, LOC(f->locale, ic)));
|
||||
}
|
||||
fputs("OPTIONEN\n", F);
|
||||
for (i=0;i!=MAXOPTIONS;++i) {
|
||||
fprintf(F, "%d;%s\n", (f->options&want(i))?1:0, options[i]);
|
||||
|
|
|
@ -3644,6 +3644,38 @@ use_cmd(unit * u, struct order * ord)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
claim_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
const char * t;
|
||||
int n;
|
||||
const item_type * itype;
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
|
||||
t = getstrtoken();
|
||||
n = atoi(t);
|
||||
if (n==0) {
|
||||
n = 1;
|
||||
} else {
|
||||
t = getstrtoken();
|
||||
}
|
||||
itype = finditemtype(t, u->faction->locale);
|
||||
|
||||
if (itype!=NULL) {
|
||||
item ** iclaim = i_find(&u->faction->items, itype);
|
||||
if (iclaim!=NULL) {
|
||||
n = min(n, (*iclaim)->number);
|
||||
i_change(iclaim, itype, -n);
|
||||
i_change(&u->items, itype, n);
|
||||
}
|
||||
} else {
|
||||
cmistake(u, ord, 43, MSG_PRODUCE);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
processorders (void)
|
||||
{
|
||||
|
@ -3666,6 +3698,7 @@ processorders (void)
|
|||
age_factions();
|
||||
|
||||
puts(" - Benutzen");
|
||||
parse(K_CLAIM, claim_cmd, false);
|
||||
parse(K_USE, use_cmd, false);
|
||||
|
||||
puts(" - Kontaktieren, Betreten von Schiffen und Gebäuden (1.Versuch)");
|
||||
|
|
|
@ -2016,7 +2016,7 @@ report(FILE *F, faction * f, const faction_list * addresses,
|
|||
if(dh > 0) centre(F, buf, true);
|
||||
dh = 0;
|
||||
|
||||
if(f->karma > 0) {
|
||||
if (f->karma > 0) {
|
||||
sprintf(buf, "Deine Partei hat %d Karma.", f->karma);
|
||||
centre(F, buf, true);
|
||||
}
|
||||
|
@ -2065,6 +2065,24 @@ report(FILE *F, faction * f, const faction_list * addresses,
|
|||
}
|
||||
#endif
|
||||
|
||||
if (f->items!=NULL) {
|
||||
item * iclaim = f->items;
|
||||
char * edit = buf;
|
||||
strcpy(edit, LOC(f->locale, "claimable"));
|
||||
edit += strlen(edit);
|
||||
while (iclaim!=NULL) {
|
||||
sprintf(edit, "%d %s", iclaim->number,
|
||||
LOC(f->locale, resourcename(iclaim->type->rtype, iclaim->number)));
|
||||
iclaim = iclaim->next;
|
||||
if (iclaim!=NULL) {
|
||||
strcat(edit, ", ");
|
||||
}
|
||||
edit += strlen(edit);
|
||||
}
|
||||
rnl(F);
|
||||
centre(F, buf, true);
|
||||
}
|
||||
|
||||
if (f->age > 1 && f->lastorders != turn) {
|
||||
rnl(F);
|
||||
if (turn - f->lastorders == 1) {
|
||||
|
|
|
@ -406,8 +406,9 @@ const char *keywords[MAXKEYWORDS] =
|
|||
"WERWESEN",
|
||||
"XONTORMIA",
|
||||
"ALLIANZ",
|
||||
"BEANSPRUCHEN",
|
||||
#ifdef HEROES
|
||||
"PROMOTION"
|
||||
"PROMOTION",
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -160,6 +160,7 @@ struct building_type;
|
|||
#define CURSEVIGOURISFLOAT_VERSION 315
|
||||
#define SAVEXMLNAME_VERSION 316
|
||||
#define SAVEALLIANCE_VERSION 317
|
||||
#define CLAIM_VERSION 318
|
||||
|
||||
#define MIN_VERSION ALLIANCES_VERSION
|
||||
#define REGIONOWNERS_VERSION 400
|
||||
|
@ -168,7 +169,7 @@ struct building_type;
|
|||
#ifdef REGIONOWNERS
|
||||
# define RELEASE_VERSION REGIONOWNERS_VERSION
|
||||
#else
|
||||
# define RELEASE_VERSION SAVEALLIANCE_VERSION
|
||||
# define RELEASE_VERSION CLAIM_VERSION
|
||||
#endif
|
||||
|
||||
#if RESOURCE_CONVERSION
|
||||
|
@ -448,6 +449,7 @@ enum {
|
|||
K_WEREWOLF,
|
||||
K_XE,
|
||||
K_ALLIANCE,
|
||||
K_CLAIM,
|
||||
#ifdef HEROES
|
||||
K_PROMOTION,
|
||||
#endif
|
||||
|
|
|
@ -97,6 +97,7 @@ typedef struct faction {
|
|||
struct region * r;
|
||||
struct message_list * msgs;
|
||||
} * battles;
|
||||
struct item * items; /* items this faction can claim */
|
||||
} faction;
|
||||
|
||||
typedef struct faction_list {
|
||||
|
|
|
@ -1578,6 +1578,11 @@ readfaction(FILE * F)
|
|||
freset(f, FFL_OVERRIDE);
|
||||
|
||||
a_read(F, &f->attribs);
|
||||
#if RELEASE_VERSION>=CLAIM_VERSION
|
||||
if (global.data_version>=CLAIM_VERSION) {
|
||||
read_items(F, &f->items);
|
||||
}
|
||||
#endif
|
||||
#ifdef MSG_LEVELS
|
||||
read_msglevels(&f->warnings, F);
|
||||
#else
|
||||
|
@ -1670,6 +1675,10 @@ writefaction(FILE * F, const faction * f)
|
|||
wi(F, f->flags);
|
||||
a_write(F, f->attribs);
|
||||
wnl(F);
|
||||
if (global.data_version>=CLAIM_VERSION) {
|
||||
write_items(F, f->items);
|
||||
wnl(F);
|
||||
}
|
||||
#ifdef MSG_LEVELS
|
||||
write_msglevels(f->warnings, F);
|
||||
#else
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
// kernel includes
|
||||
#include <kernel/alliance.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/item.h>
|
||||
#include <kernel/message.h>
|
||||
#include <kernel/unit.h>
|
||||
|
||||
// util includes
|
||||
|
@ -146,6 +148,24 @@ faction_delete_variable(faction& f, const char *key)
|
|||
return delete_variable(&((&f)->attribs), key);
|
||||
}
|
||||
|
||||
static int
|
||||
faction_additem(faction& f, const char * iname, int number)
|
||||
{
|
||||
const item_type * itype = it_find(iname);
|
||||
if (itype!=NULL) {
|
||||
item * i = i_change(&f.items, itype, number);
|
||||
return i?i->number:0;
|
||||
} // if (itype!=NULL)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void
|
||||
faction_addnotice(faction& f, const char * str)
|
||||
{
|
||||
str = LOC(f.locale, str);
|
||||
ADDMSG(&f.msgs, msg_message("msg_event", "string", str));
|
||||
}
|
||||
|
||||
void
|
||||
bind_faction(lua_State * L)
|
||||
{
|
||||
|
@ -170,6 +190,8 @@ bind_faction(lua_State * L)
|
|||
.def_readwrite("age", &faction::age)
|
||||
.def_readwrite("subscription", &faction::subscription)
|
||||
.def_readwrite("lastturn", &faction::lastorders)
|
||||
.def("add_item", &faction_additem)
|
||||
.def("add_notice", &faction_addnotice)
|
||||
.property("locale", &faction_locale)
|
||||
.property("units", &faction_units, return_stl_iterator)
|
||||
.property("alliance", &faction_getalliance, &faction_setalliance)
|
||||
|
|
|
@ -1848,6 +1848,10 @@
|
|||
<string name="BIETEN">
|
||||
<text locale="de">BIETEN</text>
|
||||
</string>
|
||||
<string name="BEANSPRUCHEN">
|
||||
<text locale="de">BEANSPRUCHEN</text>
|
||||
<text locale="en">CLAIM</text>
|
||||
</string>
|
||||
<string name="BEKLAUEN">
|
||||
<text locale="de">BEKLAUEN</text>
|
||||
</string>
|
||||
|
@ -6003,4 +6007,22 @@
|
|||
</string>
|
||||
</namespace>
|
||||
|
||||
<string name="claimable">
|
||||
<text locale="de">Einheiten können die folgenden Gegenstände beansprucht werden: </text>
|
||||
<text locale="en">Units can claim the following items: </text>
|
||||
</string>
|
||||
|
||||
<string name="santa2004">
|
||||
<text locale="de">'Ho ho ho!' Ein dicker Gnom fliegt auf einem von
|
||||
8 Jungdrachen gezogenen Schlitten durch die Nacht und vermacht Deiner
|
||||
Partei ein Sonnensegel. (Um das Segel einer Einheit zu geben, gib
|
||||
ihr den Befehl 'BEANSPRUCHE 1 Sonnensegel').</text>
|
||||
<text locale="en">'Ho ho ho!' A fat little gnome Gnom on a sled
|
||||
pulled by 8 young dragons flies through the stary night and presents
|
||||
your faction with a solar sail. (To claim this item, one of your units
|
||||
must issue the order 'CLAIM 1 solar sail'
|
||||
Partei ein Sonnensegel. (Um das Segel einer Einheit zu geben, gib
|
||||
ihr den Befehl 'BEANSPRUCHE 1 Sonnensegel').</text>
|
||||
</string>
|
||||
|
||||
</strings>
|
||||
|
|
|
@ -18,6 +18,19 @@ function write_emails()
|
|||
end
|
||||
end
|
||||
|
||||
function run_scripts()
|
||||
scripts = {
|
||||
"xmas2004"
|
||||
}
|
||||
for index in scripts do
|
||||
local script = scriptpath .. "/" .. scripts[index]
|
||||
print("- loading " .. script)
|
||||
if pcall(dofile, script)==0 then
|
||||
print("Could not load " .. script)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function process(orders)
|
||||
file = "" .. get_turn()
|
||||
if read_game(file)~=0 then
|
||||
|
@ -33,12 +46,12 @@ function process(orders)
|
|||
add_equipment("money", 2000 + get_turn() * 10);
|
||||
|
||||
-- run the turn:
|
||||
read_orders(orders)
|
||||
read_orders(orders)
|
||||
plan_monsters()
|
||||
|
||||
-- igjarjuk gets called:
|
||||
-- require("igjarjuk-call.lua")
|
||||
-- call_igjarjuk()
|
||||
-- load scripts:
|
||||
run_scripts()
|
||||
|
||||
u = get_unit(atoi36("50ki"))
|
||||
if u~=nil then
|
||||
u.region:set_flag(14, true)
|
||||
|
@ -46,12 +59,6 @@ function process(orders)
|
|||
--
|
||||
process_orders()
|
||||
|
||||
-- igjarjuk special
|
||||
-- if get_turn() > 374 then
|
||||
-- require("igjarjuk.lua")
|
||||
-- wyrm()
|
||||
-- end
|
||||
|
||||
write_passwords()
|
||||
write_reports()
|
||||
|
||||
|
|
|
@ -13,9 +13,6 @@ function test_sail()
|
|||
orc:add_order("NUMMER EINHEIT orc")
|
||||
orc:add_order("BENENNE EINHEIT Orks")
|
||||
orc:add_order("ZEIGEN \"Sonnensegel\"")
|
||||
|
||||
process_orders()
|
||||
write_reports()
|
||||
end
|
||||
|
||||
function test_movement()
|
||||
|
@ -93,9 +90,6 @@ function test_movement()
|
|||
u2:add_order("NUMMER EINHEIT Last")
|
||||
u2:add_order("BENENNE EINHEIT Verfolger-Verfolger")
|
||||
|
||||
|
||||
process_orders()
|
||||
write_reports()
|
||||
end
|
||||
|
||||
|
||||
|
@ -133,8 +127,6 @@ function test_handler()
|
|||
u:add_order("NUMMER PARTEI eviL")
|
||||
u:add_order(msg)
|
||||
|
||||
process_orders()
|
||||
write_reports()
|
||||
end
|
||||
|
||||
function test_combat()
|
||||
|
@ -169,8 +161,6 @@ function test_combat()
|
|||
u:add_order("KAEMPFE")
|
||||
u:add_order(attack)
|
||||
|
||||
process_orders()
|
||||
write_reports()
|
||||
end
|
||||
|
||||
function test_rewards()
|
||||
|
@ -238,8 +228,6 @@ function test_rewards()
|
|||
end
|
||||
u:add_order("NUMMER PARTEI eviL")
|
||||
|
||||
process_orders()
|
||||
write_reports()
|
||||
end
|
||||
|
||||
function test_give()
|
||||
|
@ -256,16 +244,11 @@ function test_give()
|
|||
u:add_order("GIB TEMP eins ALLES silber")
|
||||
u:add_order("NUMMER PARTEI test")
|
||||
|
||||
process_orders()
|
||||
write_reports()
|
||||
end
|
||||
|
||||
function test_write()
|
||||
read_game("24")
|
||||
read_orders("befehle")
|
||||
process_orders()
|
||||
write_reports()
|
||||
write_game("25")
|
||||
end
|
||||
|
||||
function move_north(u)
|
||||
|
@ -291,7 +274,6 @@ function test_monsters()
|
|||
|
||||
set_brain("braineater", move_north)
|
||||
plan_monsters()
|
||||
process_orders()
|
||||
end
|
||||
|
||||
function test_parser()
|
||||
|
@ -308,10 +290,6 @@ function test_parser()
|
|||
u:add_order("Nummer Partei test")
|
||||
u:add_order("BENENNE PARTEI \"Diese Partei heisst \\\"Enno's Schergen\\\".\"")
|
||||
u:add_order("BENENNE EINHEIT \"Mein Name ist \\\"Enno\\\".\"")
|
||||
|
||||
process_orders()
|
||||
write_reports()
|
||||
write_game("parser")
|
||||
end
|
||||
|
||||
function test_fail()
|
||||
|
@ -322,7 +300,19 @@ function test_fail()
|
|||
print(f)
|
||||
end
|
||||
|
||||
test_sail()
|
||||
function run_scripts()
|
||||
scripts = {
|
||||
"xmas2004.lua"
|
||||
}
|
||||
for index in scripts do
|
||||
local script = scriptpath .. "/" .. scripts[index]
|
||||
print("- loading " .. script)
|
||||
if pcall(dofile, script)==0 then
|
||||
print("Could not load " .. script)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- test_movement()
|
||||
-- test_fail()
|
||||
-- test_handler()
|
||||
|
@ -332,5 +322,8 @@ test_sail()
|
|||
-- test_rewards()
|
||||
-- test_give()
|
||||
-- test_write()
|
||||
-- read_game("test")
|
||||
-- write_game("test")
|
||||
|
||||
test_sail()
|
||||
run_scripts()
|
||||
process_orders()
|
||||
write_reports()
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
function xmas2004()
|
||||
print(get_gamename())
|
||||
if get_gamename() == "Eressea" then
|
||||
if not get_flag("xm04") then
|
||||
print("Es weihnachtet sehr")
|
||||
set_flag("xm04", true)
|
||||
for f in factions() do
|
||||
f:add_item("speedsail", 1)
|
||||
f:add_notice("santa2004")
|
||||
print(f)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
print("Ja, ist denn schon Weihnachten?")
|
||||
xmas2004()
|
Loading…
Reference in New Issue