neuer Spiel-Parameter unitsperalliance (boolean): Einheitenlimit pro Allianz

This commit is contained in:
Christian Schlittchen 2005-05-20 09:08:39 +00:00
parent 91b137fc20
commit 0f9353eaaf
5 changed files with 86 additions and 7 deletions

View File

@ -3356,7 +3356,49 @@ ageing(void)
static int static int
maxunits(faction *f) maxunits(faction *f)
{ {
return (int) (global.maxunits * (1 + 0.4 * fspecial(f, FS_ADMINISTRATOR))); if(global.unitsperalliance == true) {
faction *f2;
float mult = 1.0;
for(f2 = factions; f2; f2 = f2->next) {
if(f2->alliance == f->alliance) {
mult += 0.4 * fspecial(f2, FS_ADMINISTRATOR);
}
}
return (int) (global.maxunits * mult);
}
return (int) (global.maxunits *
(1 + 0.4 * fspecial(f, FS_ADMINISTRATOR)));
}
static boolean
checkunitnumber(faction *f)
{
if(global.unitsperalliance == true) {
faction *f2;
int unitsinalliance = 0;
for(f2 = factions; f2; f2 = f2->next) {
if(f->alliance == f2->alliance) {
unitsinalliance += f2->no_units;
}
}
/* if unitsperalliance is true, maxunits returns the
number of units allowed in an alliance */
if(unitsinalliance >= maxunits(f)) {
return false;
} else {
return true;
}
}
if(f->no_units >= maxunits(f)) {
return false;
}
return true;
} }
@ -3381,13 +3423,18 @@ new_units (void)
if (getparam(u->faction->locale) == P_TEMP) { if (getparam(u->faction->locale) == P_TEMP) {
char * name; char * name;
int g, alias; int g, alias;
int mu = maxunits(u->faction);
order ** newordersp; order ** newordersp;
if(u->faction->no_units >= mu) { if(checkunitnumber(u->faction) == false) {
sprintf(buf, "Eine Partei darf aus nicht mehr als %d " if(global.unitsperalliance == false) {
"Einheiten bestehen.", mu); ADDMSG(&u->faction->msgs, msg_message("too_many_units_in_faction",
mistake(u, makeord, buf, MSG_PRODUCE); "command unit region allowed",
getcommand(makeord), u, r, maxunits(u->faction)));
} else {
ADDMSG(&u->faction->msgs, msg_message("too_many_units_in_alliance",
"command unit region allowed",
getcommand(makeord), u, r, maxunits(u->faction)));
}
ordp = &makeord->next; ordp = &makeord->next;
while (*ordp) { while (*ordp) {

View File

@ -1156,6 +1156,7 @@ extern const struct race * new_race[];
typedef struct settings { typedef struct settings {
const char *gamename; const char *gamename;
const char *welcomepath; const char *welcomepath;
boolean unitsperalliance;
unsigned int maxunits; unsigned int maxunits;
struct attrib *attribs; struct attrib *attribs;
unsigned int data_version; unsigned int data_version;

View File

@ -1177,6 +1177,15 @@ parse_main(xmlDocPtr doc)
global.welcomepath = strdup((const char*)property); global.welcomepath = strdup((const char*)property);
xmlFree(property); xmlFree(property);
} }
global.unitsperalliance = false;
property = xmlGetProp(node, BAD_CAST "unitsperalliance");
if (property!=NULL) {
if(!strcmp(property, "yes")) {
global.unitsperalliance = true;
}
xmlFree(property);
}
property = xmlGetProp(node, BAD_CAST "units"); property = xmlGetProp(node, BAD_CAST "units");
if (property!=NULL) { if (property!=NULL) {

View File

@ -6186,5 +6186,27 @@
<text locale="en">"$unit($unit) sends the plague on $region($region)."</text> <text locale="en">"$unit($unit) sends the plague on $region($region)."</text>
</message> </message>
<message name="too_many_units_in_faction" section="errors">
<type>
<arg name="command" type="order"/>
<arg name="region" type="region"/>
<arg name="unit" type="unit"/>
<arg name="allowed" type="int"/>
</type>
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - Eine Partei darf aus nicht mehr als $int($allowed) Einheiten bestehen."</text>
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - A faction may not consist of more than $int($allowed) units."</text>
</message>
<message name="too_many_units_in_alliance" section="errors">
<type>
<arg name="command" type="order"/>
<arg name="region" type="region"/>
<arg name="unit" type="unit"/>
<arg name="allowed" type="int"/>
</type>
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - Eine Allianz darf aus nicht mehr als $int($allowed) Einheiten bestehen."</text>
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - An alliance may not consist of more than $int($allowed) units."</text>
</message>
</messages> </messages>

View File

@ -14,7 +14,7 @@
<xi:include href="buildings.xml"/> <xi:include href="buildings.xml"/>
<xi:include href="equipment.xml"/> <xi:include href="equipment.xml"/>
<game name="Wettstreit der Weisen" units="250" welcome="vinyambar"> <game name="Wettstreit der Weisen" unitsperalliance="yes" units="1000" welcome="vinyambar">
<comment>Game specific</comment> <comment>Game specific</comment>
<order name="ARBEITEN" disable="yes"/> <order name="ARBEITEN" disable="yes"/>
<order name="MEINUNG" disable="yes"/> <order name="MEINUNG" disable="yes"/>