forked from github/server
neuer Spiel-Parameter unitsperalliance (boolean): Einheitenlimit pro Allianz
This commit is contained in:
parent
91b137fc20
commit
0f9353eaaf
|
@ -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) {
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -1178,6 +1178,15 @@ parse_main(xmlDocPtr doc)
|
||||||
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) {
|
||||||
global.maxunits = atoi((const char*)property);
|
global.maxunits = atoi((const char*)property);
|
||||||
|
|
|
@ -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>
|
||||||
|
|
||||||
|
|
|
@ -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"/>
|
||||||
|
|
Loading…
Reference in New Issue