- filereader.c rewritten since the initial implementation is in the moving van.

- moved some summary functionality (emails, aliases) to Lua code
- made default.lua an include for all the different run-scripts

report.c is the last file that needs some work, everything else should be fine. Most importantly, all the messages are not internationalized, so that means just about no more German in the code. Yay!
This commit is contained in:
Enno Rehling 2007-08-08 07:43:24 +00:00
parent f013ead006
commit 940d236edc
22 changed files with 319 additions and 384 deletions

2
src/build_vs2003.bat Normal file
View File

@ -0,0 +1,2 @@
REM rebuild eressea projects for VC7.1
premake --file premake.lua --target vs2003

View File

@ -498,6 +498,14 @@ report_crtypes(FILE * F, const struct locale* lang)
}
}
static unsigned int
messagehash(const struct message * msg)
{
variant var;
var.v = (void *)msg;
return (unsigned int)var.i;
}
static void
render_messages(FILE * F, faction * f, message_list *msgs)
{
@ -511,7 +519,7 @@ render_messages(FILE * F, faction * f, message_list *msgs)
char nrbuffer[1024*32];
nrbuffer[0] = '\0';
if (nr_render(m->msg, f->locale, nrbuffer, sizeof(nrbuffer), f)>0 && nrbuffer[0]) {
fprintf(F, "MESSAGE %u\n", (unsigned int)m->msg);/*++msgno); */
fprintf(F, "MESSAGE %u\n", messagehash(m->msg));
fprintf(F, "%d;type\n", hash);
fwritestr(F, nrbuffer);
fputs(";rendered\n", F);
@ -520,7 +528,7 @@ render_messages(FILE * F, faction * f, message_list *msgs)
#endif
crbuffer[0] = '\0';
if (cr_render(m->msg, crbuffer, (const void*)f)==0) {
if (!printed) fprintf(F, "MESSAGE %u\n", (unsigned int)m->msg);/*++msgno); */
if (!printed) fprintf(F, "MESSAGE %u\n", messagehash(m->msg));
if (crbuffer[0]) fputs(crbuffer, F);
} else {
log_error(("could not render cr-message %p: %s\n", m->msg, m->msg->type->name));

View File

@ -741,7 +741,7 @@ see_border(const border * b, const faction * f, const region * r)
return cs;
}
const char *
const xmlChar *
trailinto(const region * r, const struct locale * lang)
{
char ref[32];
@ -2525,81 +2525,6 @@ writemonument(void)
}
static void
writeadresses(void)
{
faction *f;
FILE *F;
char zText[MAX_PATH];
sprintf(zText, "%s/adressen", basepath());
F = cfopen(zText, "w");
if (!F) return;
for (f = factions; f; f = f->next) {
if (f->no != MONSTER_FACTION && playerrace(f->race)) {
fprintf(F, "%s:%s:%s\n", factionname(f), f->email, f->banner);
}
}
fclose(F);
}
static void
writenewssubscriptions(void)
{
char zText[MAX_PATH];
FILE *F;
sprintf(zText, "%s/news-subscriptions", basepath());
F = cfopen(zText, "w");
if (!F) return;
#ifdef AT_OPTION
{
faction *f;
for(f=factions; f; f=f->next) {
attrib *a = a_find(f->attribs, &at_option_news);
if(!a) {
fprintf(F, "%s:0\n", f->email);
} else {
fprintf(F, "%s:%d\n", f->email, a->data.i);
}
}
}
#endif
fclose(F);
}
static void
writeforward(void)
{
FILE *forwardFile;
region *r;
faction *f;
unit *u;
{
char zText[MAX_PATH];
sprintf(zText, "%s/aliases", basepath());
forwardFile = cfopen(zText, "w");
if (!forwardFile) return;
}
for (f = factions; f; f = f->next) {
if (f->no != MONSTER_FACTION) {
fprintf(forwardFile,"partei-%s: %s\n", factionid(f), f->email);
}
}
for (r = regions; r; r = r->next) {
for (u = r->units; u; u = u->next) {
if (u->faction->no != MONSTER_FACTION) {
fprintf(forwardFile,"einheit-%s: %s\n", unitid(u), u->faction->email);
}
}
}
fclose(forwardFile);
}
static void
writeturn(void)
{
@ -2790,11 +2715,6 @@ report_summary(summary * s, summary * o, boolean full)
fclose(F);
if (full) {
printf("Schreibe Liste der Adressen (adressen)...\n");
writeadresses();
writenewssubscriptions();
writeforward();
printf("writing date & turn\n");
writeturn();

View File

@ -18,6 +18,10 @@ extern "C" {
extern void report_init(void);
extern void report_cleanup(void);
struct summary;
extern void report_summary(struct summary * n, struct summary * o, boolean full);
extern struct summary * make_summary(void);
#ifdef __cplusplus
}
#endif

View File

@ -44,6 +44,7 @@
/* util includes */
#include <util/attrib.h>
#include <util/base36.h>
#include <util/parser.h>
#include <util/rand.h>
#include <util/rng.h>
@ -63,139 +64,52 @@
void
spy_message(int spy, const unit *u, const unit *target)
{
char buf[4096];
const char *c;
const xmlChar * str = report_kampfstatus(target, u->faction->locale);
/* Infos:
* - Kampfstatus
* - verborgene Gegenstände: Amulette, Ringe, Phiolen, Geld
* - Partei
* - Talentinfo
* - Zaubersprüche
* - Zauberwirkungen
*/
/* mit spy=100 (magische Spionage) soll alles herausgefunden werden */
buf[0]='\0';
if (spy > 99){
/* magische Spionage */
/* Zauberwirkungen */
}
ADDMSG(&u->faction->msgs, msg_message("spyreport", "spy target status", u, target, str));
if (spy > 20) {
sc_mage * m = get_mage(target);
/* bei Magiern Zaubersprüche und Magiegebiet */
if (m) {
spell_list *slist = m->spells;
boolean first = true;
scat("Magiegebiet: ");
scat(LOC(u->faction->locale, magietypen[find_magetype(target)]));
scat(", Sprüche: ");
for (;slist; slist=slist->next) {
spell * sp = slist->data;
if (first) {
first = false;
} else {
scat(", ");
}
scat(spell_name(sp, u->faction->locale));
}
if (first) scat("Keine");
scat(". ");
ADDMSG(&u->faction->msgs, msg_message("spyreport_mage", "target type", target, magietypen[find_magetype(target)]));
}
}
if (spy > 6) {
/* wahre Partei */
scat("Partei '");
scat(factionname(target->faction));
scat("'. ");
} else {
/* ist die Einheit in Spionage nicht gut genug, glaubt sie die
* Parteitarnung */
faction * fv = visible_faction(u->faction,target);
if (fv != target->faction){
scat("Partei '");
scat(factionname(fv));
scat("'. ");
} else if (!fval(target, UFL_PARTEITARNUNG)){
scat("Partei '");
scat(factionname(target->faction));
scat("'. ");
if (fv && fv!=target->faction) {
/* wahre Partei */
ADDMSG(&u->faction->msgs, msg_message("spyreport_faction", "target faction", target, target->faction));
}
}
if (spy > 0) {
int first = 1;
int found = 0;
skill * sv;
char buf[4096];
scat("Talente: ");
buf[0] = 0;
for (sv = target->skills;sv!=target->skills+target->skill_size;++sv) {
if (sv->level>0) {
found++;
if (first == 1) {
first = 0;
} else {
scat(", ");
strncat(buf, ", ", sizeof(buf));
}
scat(skillname(sv->id, u->faction->locale));
scat(" ");
icat(eff_skill(target, sv->id, target->region));
strncat(buf, (const char *)skillname(sv->id, u->faction->locale), sizeof(buf));
strncat(buf, " ", sizeof(buf));
strncat(buf, itoa10(eff_skill(target, sv->id, target->region)), sizeof(buf));
}
}
if (found == 0) {
scat("Keine");
}
scat(". ");
scat("Im Gepäck sind");
{
boolean first = true;
int found = 0;
item * itm;
for (itm=target->items;itm;itm=itm->next) {
if (itm->number>0) {
resource_type * rtype = itm->type->rtype;
++found;
if (first) {
first = false;
scat(": ");
} else {
scat(", ");
if (found) {
ADDMSG(&u->faction->msgs, msg_message("spyreport_skills", "target skills", target, buf));
}
if (itm->number == 1) {
scat("1 ");
scat(locale_string(u->faction->locale, resourcename(rtype, 0)));
} else {
icat(itm->number);
scat(" ");
scat(locale_string(u->faction->locale, resourcename(rtype, NMF_PLURAL)));
if (target->items) {
ADDMSG(&u->faction->msgs, msg_message("spyreport_items", "target items", target, target->items));
}
}
}
if (found == 0) {
scat(" keine verborgenen Gegenstände");
}
scat(". ");
}
}
/* spion ist gleich gut wie Wahrnehmung Opfer */
/* spion ist schlechter als Wahrnehmung Opfer */
{ /* immer */
const xmlChar * str;
scat("Kampfstatus: ");
scat(report_kampfstatus(target, u->faction->locale));
str = locale_string(u->faction->locale, hp_status(target));
if (str && str[0])
sprintf(buf, "%s (%s)", buf, str);
scat(".");
}
ADDMSG(&u->faction->msgs, msg_message("spyreport",
"spy target report", u, target, strdup(buf)));
}
int
@ -299,7 +213,7 @@ int
setstealth_cmd(unit * u, struct order * ord)
{
const xmlChar *s;
char level;
int level;
const race * trace;
init_tokens(ord);
@ -360,7 +274,7 @@ setstealth_cmd(unit * u, struct order * ord)
} else if (findparam(s, u->faction->locale) == P_NOT) {
freset(u, UFL_PARTEITARNUNG);
} else if (findkeyword(s, u->faction->locale) == K_NUMBER) {
const xmlChar *s2 = getstrtoken();
const char *s2 = (const char *)getstrtoken();
int nr = -1;
if (s2) nr = atoi36(s2);
@ -449,7 +363,7 @@ setstealth_cmd(unit * u, struct order * ord)
default:
if (isdigit(s[0])) {
/* Tarnungslevel setzen */
level = (char) atoip(s);
level = atoi((const char *)s);
if (level > effskill(u, SK_STEALTH)) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_lowstealth", ""));
return 0;

View File

@ -103,7 +103,7 @@ groupid(const struct group * g, const struct faction * f)
return buf;
}
const char *
const xmlChar *
report_kampfstatus(const unit * u, const struct locale * lang)
{
static char fsbuf[64];
@ -112,13 +112,13 @@ report_kampfstatus(const unit * u, const struct locale * lang)
"status_rear", "status_defensive",
"status_avoid", "status_flee" };
strcpy(fsbuf, LOC(lang, azstatus[u->status]));
xstrlcpy(fsbuf, LOC(lang, azstatus[u->status]), sizeof(fsbuf));
if (fval(u, UFL_NOAID)) {
strcat(fsbuf, ", ");
strcat(fsbuf, LOC(lang, "status_noaid"));
xstrcat(fsbuf, LOC(lang, "status_noaid"));
}
return fsbuf;
return (xmlChar *)fsbuf;
}
const char *
@ -1443,6 +1443,24 @@ global_report(const char * filename)
}
#endif
void
writeaddresses(void)
{
faction *f;
FILE *F;
char zText[MAX_PATH];
sprintf(zText, "%s/addresses", basepath());
F = cfopen(zText, "w");
if (!F) return;
for (f = factions; f; f = f->next) {
if (f->no != MONSTER_FACTION && playerrace(f->race)) {
fprintf(F, "%s:%s:%s\n", factionname(f), f->email, f->banner);
}
}
fclose(F);
}
int
reports(void)
{

View File

@ -50,10 +50,6 @@ extern int init_reports(void);
extern const struct unit *ucansee(const struct faction *f, const struct unit *u, const struct unit *x);
struct summary;
extern void report_summary(struct summary * n, struct summary * o, boolean full);
extern struct summary * make_summary(void);
int hat_in_region(item_t itm, struct region * r, struct faction * f);
/* für fast_region und neuen CR: */
@ -102,8 +98,9 @@ extern void report_building(FILE *F, const struct region * r, const struct build
extern int bufunit(const struct faction * f, const struct unit * u, int indent, int mode, char * buf, size_t size);
extern const char * reportpath(void);
extern const char * trailinto(const struct region * r, const struct locale * lang);
extern const char * report_kampfstatus(const struct unit * u, const struct locale * lang);
extern const xmlChar * trailinto(const struct region * r, const struct locale * lang);
extern const xmlChar * report_kampfstatus(const struct unit * u, const struct locale * lang);
extern void writeaddresses(void);
extern void reports_init(void);

View File

@ -78,7 +78,6 @@
#include <assert.h>
#define xisdigit(c) (((c) >= '0' && (c) <= '9') || (c) == '-')
#define COMMENT_CHAR ';'
#define ESCAPE_FIX
#define MAXORDERS 256

View File

@ -29,7 +29,7 @@
#include "karma.h"
#include "border.h"
#include "item.h"
#include "movement.h"
#include "move.h"
#include "order.h"
#include "plane.h"
#include "race.h"

View File

@ -1,3 +1,163 @@
#include <config.h>
#include "filereader.h"
#include <util/log.h>
#include <util/unicode.h>
#define COMMENT_CHAR ';'
#define CONTINUE_CHAR '\\'
#define MAXLINE 4096*16
static char lbuf[MAXLINE];
static char fbuf[MAXLINE];
static void
unicode_warning(const char * bp)
{
log_warning(("invalid sequence in UTF-8 string: %s\n", bp));
}
INLINE_FUNCTION int
eatwhite(const char * ptr, size_t * total_size)
{
int ret = 0;
*total_size = 0;
#ifdef USE_UNICODE
while (*ptr) {
wint_t ucs;
size_t size = 0;
ret = unicode_utf8_to_ucs4(&ucs, (const xmlChar*)ptr, &size);
if (ret!=0) break;
if (!iswspace(ucs)) break;
*total_size += size;
ptr += size;
}
#else
*total_size = 0;
while (ptr[*total_size] && isspace(*(unsigned char*)ptr[*total_size])) ++*total_size;
#endif
return ret;
}
const xmlChar *
getbuf(FILE * F, int encoding)
{
boolean cont = false;
char quote = 0;
boolean comment = false;
char * cp = fbuf;
char * tail = lbuf+MAXLINE-2;
tail[1] = '@'; /* if this gets overwritten by fgets then the line was very long. */
do {
const char * bp = fgets(lbuf, MAXLINE, F);
size_t white;
if (bp==NULL) return NULL;
eatwhite(bp, &white); /* decoding errors will get caught later on, don't have to check */
bp += white;
comment = (boolean)(comment && cont);
if (tail[1]==0) {
/* we read he maximum number of bytes! */
if (tail[0]!='\n') {
/* it wasn't enough space to finish the line, eat the rest */
for (;;) {
tail[1] = '@';
bp = fgets(lbuf, MAXLINE, F);
if (bp==NULL) return NULL;
if (tail[1]) {
/* read enough this time to end the line */
break;
}
}
comment = false;
bp = NULL;
} else {
tail[1] = '@';
}
}
cont = false;
while (*bp && cp<fbuf+MAXLINE) {
wint_t ucs;
size_t size;
int ret;
if (*bp==COMMENT_CHAR && !quote) {
/* comment begins. we need to keep going, to look for CONTINUE_CHAR */
comment = true;
++bp;
}
if (*bp=='"' || *bp=='\'') {
if (quote==*bp) {
quote = 0;
if (cp<fbuf+MAXLINE) *cp++ = *bp++;
} else if (!quote) {
quote = *bp++;
if (cp<fbuf+MAXLINE) *cp++ = quote;
}
}
ret = unicode_utf8_to_ucs4(&ucs, (const xmlChar *)bp, &size);
if (ret!=0) {
unicode_warning(bp);
break;
}
if (iswspace(ucs)) {
if (!quote) {
bp+=size;
ret = eatwhite(bp, &size);
if (!comment && *bp && *bp!=COMMENT_CHAR && cp<fbuf+MAXLINE) *(cp++) = ' ';
bp += size;
if (ret!=0) {
unicode_warning(bp);
break;
}
}
else if (!comment) {
if (cp+size<=fbuf+MAXLINE) {
while (size--) {
*(cp++)=*(bp++);
}
} else bp+=size;
} else {
bp+=size;
}
}
else if (iswcntrl(ucs)) {
if (!comment && cp<fbuf+MAXLINE) *(cp++) = '?';
bp+=size;
} else {
if (*bp==CONTINUE_CHAR) {
const char * end;
eatwhite(bp+1, &white);
end = bp+1+white;
if (*end == '\0') {
bp = end;
cont = true;
continue;
}
if (!comment && cp<fbuf+MAXLINE) *cp++ = *bp++;
else ++bp;
} else {
if (!comment && cp+size<=fbuf+MAXLINE) {
while (size--) {
*(cp++)=*(bp++);
}
} else {
bp += size;
}
}
}
}
if (cp==fbuf+MAXLINE) {
--cp;
}
*cp=0;
} while (cont || cp==fbuf);
return (const xmlChar*)fbuf;
}

View File

@ -20,7 +20,7 @@ extern "C" {
#endif
#include <wchar.h>
#define USE_UNICODE
extern int unicode_utf8_to_ucs4(wint_t *ucs4_character, const xmlChar *utf8_string, size_t *length);
#ifdef __cplusplus

View File

@ -12,6 +12,7 @@
#include <gamecode/laws.h>
#include <gamecode/monster.h>
#include <gamecode/creport.h>
#include <gamecode/report.h>
#include <spells/spells.h>
@ -217,6 +218,7 @@ write_summary()
summary * sum_end = make_summary();
report_summary(sum_end, sum_begin, false);
report_summary(sum_end, sum_begin, true);
writeaddresses();
return 0;
}
return -1;

View File

@ -61,7 +61,9 @@
#include <gamecode/items.h>
#include <gamecode/laws.h>
#include <gamecode/creport.h>
#ifdef REPORT_FORMAT_NR
#include <gamecode/report.h>
#endif
#include <gamecode/xmlreport.h>
/* kernel includes */
@ -162,7 +164,7 @@ static int nowrite = 0;
static boolean g_writemap = false;
static boolean g_ignore_errors = false;
static boolean opt_reportonly = false;
static const char * luafile = "default.lua";
static const char * luafile = NULL;
static const char * script_path = "scripts";
struct settings global = {
@ -213,7 +215,9 @@ game_init(void)
init_xmas();
reports_init();
#ifdef REPORT_FORMAT_NR
report_init();
#endif
creport_init();
xmlreport_init();
@ -378,7 +382,9 @@ game_done(void)
}
creport_cleanup();
#ifdef REPORT_FORMAT_NR
report_cleanup();
#endif
calendar_cleanup();
}
#endif
@ -419,7 +425,7 @@ usage(const char * prog, const char * arg)
"-o reportdir : gibt das reportverzeichnis an\n"
"-l path : specify the base script directory\n"
"-C : run in interactive mode\n"
"-e script : main lua script (default: default.lua)\n"
"-e script : main lua script\n"
"-R : erstellt nur die Reports neu\n"
"--lomem : keine Messages (RAM sparen)\n"
"--nobattle : keine Kämpfe\n"

View File

@ -3459,11 +3459,42 @@
<type>
<arg name="spy" type="unit"/>
<arg name="target" type="unit"/>
<arg name="report" type="string"/>
<arg name="status" type="string"/>
</type>
<text locale="de">"$unit($spy) gelang es, Informationen über $unit($target) herauszubekommen: '$report'."</text>
<text locale="fr">"$unit($spy) managed to gather information about $unit($target): '$report'."</text>
<text locale="en">"$unit($spy) managed to gather information about $unit($target): '$report'."</text>
<text locale="de">"$unit($spy) gelang es, Informationen über $unit($target) ($status) herauszubekommen."</text>
<text locale="en">"$unit($spy) managed to gather information about $unit($target)."</text>
</message>
<message name="spyreport_mage" section="events">
<type>
<arg name="target" type="unit"/>
<arg name="type" type="string"/>
</type>
<text locale="de">"$unit($target) ist ein $type-Magier."</text>
<text locale="en">"$unit($target) is a $type-magician"</text>
</message>
<message name="spyreport_skills" section="events">
<type>
<arg name="target" type="unit"/>
<arg name="skills" type="string"/>
</type>
<text locale="de">"$unit($target) beherrscht $skills."</text>
<text locale="en">"$unit($target) has the skills $skills"</text>
</message>
<message name="spyreport_items" section="events">
<type>
<arg name="target" type="unit"/>
<arg name="items" type="items"/>
</type>
<text locale="de">"In Gepäck von $unit($target) sind $resources($items)."</text>
<text locale="en">"$unit($target) carries $resources($items)"</text>
</message>
<message name="spyreport_faction" section="events">
<type>
<arg name="target" type="unit"/>
<arg name="faction" type="faction"/>
</type>
<text locale="de">"$unit($target) gehört der Partei $faction($faction) an."</text>
<text locale="en">"$unit($target) belongs to $faction($faction)."</text>
</message>
<message name="spydetect" section="events">
<type>

View File

@ -1,13 +1,4 @@
function loadscript(name)
local script = scriptpath .. "/" .. name
print("- loading " .. script)
if pcall(dofile, script)==0 then
print("Could not load " .. script)
end
end
function write_emails()
local locales = { "de", "en" }
function write_emails(locales)
local files = {}
local key
local locale
@ -27,62 +18,29 @@ function write_emails()
end
end
function process(orders)
-- initialize starting equipment for new players
equipment_setitem("new_faction", "conquesttoken", "1");
equipment_setitem("new_faction", "log", "30");
equipment_setitem("new_faction", "stone", "30");
equipment_setitem("new_faction", "money", "4200");
function write_aliases()
local file
local key
local locale
file = "" .. get_turn()
if read_game(file)~=0 then
print("could not read game")
return -1
file = io.open(basepath .. "/aliases." .. locale, "w")
local faction
for faction in factions() do
local unit
file:write("partei-" .. itoa36(faction.id) .. ": " .. faction.email .. "\n")
for unit in f.units do
file:write("einheit-" .. itoa36(unit.id) .. ": " .. faction.email .. "\n")
end
end
init_summary()
-- run the turn:
read_orders(orders)
-- create new monsters:
spawn_dragons()
spawn_undead()
spawn_braineaters(0.25)
plan_monsters()
process_orders()
-- post-turn updates:
update_guards()
update_scores()
-- use newfactions file to place out new players
autoseed(basepath .. "/newfactions", true)
file:close()
end
function write_files(locales)
write_passwords()
write_reports()
write_emails()
write_emails(locales)
write_aliases()
write_summary()
file = "" .. get_turn()
if write_game(file)~=0 then
print("could not write game")
return -1
end
end
--
-- main body of script
--
-- orderfile: contains the name of the orders.
if orderfile==nil then
print "you must specify an orderfile"
else
loadscript("spells.lua")
loadscript("extensions.lua")
process(orderfile)
end

View File

@ -1,3 +1,6 @@
-- the locales that this gameworld supports.
local locales = { "de", "en" }
function loadscript(name)
local script = scriptpath .. "/" .. name
print("- loading " .. script)
@ -26,7 +29,7 @@ function run_scripts()
"spells.lua",
"extensions.lua",
"familiars.lua",
"write_emails.lua",
"default.lua",
"eressea/eternath.lua",
"eressea/wedding-jadee.lua",
"eressea/ponnuki.lua",
@ -96,10 +99,7 @@ function process(orders)
-- use newfactions file to place out new players
autoseed(basepath .. "/newfactions", false)
write_passwords()
write_reports()
write_emails()
write_summary()
write_files(locales)
file = "" .. get_turn()
if write_game(file)~=0 then

View File

@ -1,5 +1,8 @@
local locales = { "de", "en" }
function run_scripts()
scripts = {
"default.lua",
"spells.lua",
"extensions.lua",
"familiars.lua",
@ -15,26 +18,6 @@ function run_scripts()
end
end
function write_emails()
local locales = { "de", "en" }
local files = {}
local key
for key in locales do
local locale = locales[key]
files[locale] = io.open(basepath .. "/emails." .. locale, "w")
end
local faction
for faction in factions() do
-- print(faction.id .. " - " .. faction.locale)
files[faction.locale]:write(faction.email .. "\n")
end
for key in files do
files[key]:close()
end
end
function refresh_pool()
for f in factions do
f:add_item("money", 50)
@ -56,10 +39,7 @@ function process(orders)
plan_monsters()
process_orders()
write_passwords()
write_reports()
write_emails()
write_files(locales)
file = "" .. get_turn()
if write_game(file)~=0 then

View File

@ -1,5 +1,8 @@
local locales = { "de", "en" }
function run_scripts()
scripts = {
"default.lua",
"spells.lua",
"extensions.lua",
"familiars.lua",
@ -15,26 +18,6 @@ function run_scripts()
end
end
function write_emails()
local locales = { "de", "en" }
local files = {}
local key
for key in locales do
local locale = locales[key]
files[locale] = io.open(basepath .. "/emails." .. locale, "w")
end
local faction
for faction in factions() do
-- print(faction.id .. " - " .. faction.locale)
files[faction.locale]:write(faction.email .. "\n")
end
for key in files do
files[key]:close()
end
end
function refresh_pool()
for f in factions() do
f:add_item("money", 50)
@ -58,10 +41,7 @@ function process(orders)
refresh_pool()
write_passwords()
write_reports()
write_emails()
write_files(locales)
file = "" .. get_turn()
if write_game(file)~=0 then

View File

@ -1,3 +1,6 @@
-- the locales that this gameworld supports.
local locales = { "de", "en" }
function loadscript(name)
local script = scriptpath .. "/" .. name
print("- loading " .. script)
@ -6,26 +9,6 @@ function loadscript(name)
end
end
function write_emails()
local locales = { "de", "en" }
local files = {}
local key
for key in locales do
local locale = locales[key]
files[locale] = io.open(basepath .. "/emails." .. locale, "w")
end
local faction
for faction in factions() do
-- print(faction.id .. " - " .. faction.locale)
files[faction.locale]:write(faction.email .. "\n")
end
for key in files do
files[key]:close()
end
end
function update_resources()
-- remaining contents of region pool rots
-- wood falls from trees
@ -83,10 +66,7 @@ function process(orders)
-- use newfactions file to place out new players
autoseed(basepath .. "/newfactions", true)
write_passwords()
write_reports()
write_emails()
write_summary()
write_files(locales)
file = "" .. get_turn()
if write_game(file)~=0 then
@ -104,7 +84,7 @@ end
if orderfile==nil then
print "you must specify an orderfile"
else
-- loadscript("spells.lua")
loadscript("default.lua")
loadscript("extensions.lua")
loadscript("kingdoms/extensions.lua")
process(orderfile)

View File

@ -8,10 +8,10 @@ end
function run_scripts()
scripts = {
"default.lua",
"spells.lua",
"extensions.lua",
"familiars.lua",
"write_emails.lua"
"familiars.lua"
}
for index, name in pairs(scripts) do
loadscript(name)
@ -58,10 +58,7 @@ function process(orders)
-- use newfactions file to place out new players
autoseed(basepath .. "/newfactions", false)
write_passwords()
write_reports()
write_emails()
write_summary()
write_files(locales)
file = "" .. get_turn()
if write_game(file)~=0 then

View File

@ -1,3 +1,6 @@
-- the locales that this gameworld supports.
local locales = { "de", "en" }
function process(orders)
-- read game and orders
local turnfile = "" .. get_turn()
@ -30,11 +33,7 @@ function process(orders)
update_guards()
update_scores()
-- write out the initial reports (no need to run a turn)
write_passwords()
write_reports()
write_emails()
write_summary()
write_files(locales)
-- siegbedingungen ausgeben
write_standings()
@ -54,10 +53,10 @@ end
print("- Running wdw-run.lua")
scripts = {
"default.lua",
"spells.lua",
"extensions.lua",
"familiars.lua",
"write_emails.lua",
"wdw/sphinx.lua",
"wdw/phoenix.lua",
"wdw/standings.lua"

View File

@ -1,20 +0,0 @@
function write_emails()
local locales = { "de", "en" }
local files = {}
local key
for key, locale in pairs(locales) do
files[locale] = io.open(basepath .. "/emails." .. locale, "w")
end
local faction
for faction in factions() do
-- print(faction.id .. " - " .. faction.locale)
files[faction.locale]:write(faction.email .. "\n")
end
for key, file in pairs(files) do
file:close()
end
end