Feature #151 ยป 0040-Add-requirement-type-MinCities.patch
| ai/default/daieffects.c | ||
|---|---|---|
|
/* Can always be achieved. */
|
||
|
return TRUE;
|
||
|
case VUT_MINCITIES:
|
||
|
/* We don't WANT to lose cities */
|
||
|
return preq->present;
|
||
|
case VUT_IMPR_FLAG:
|
||
|
/* TODO: Have at least some checks for this. */
|
||
|
break;
|
||
| ai/default/daimilitary.c | ||
|---|---|---|
|
case VUT_PLAYER_STATE:
|
||
|
case VUT_MINCULTURE:
|
||
|
case VUT_MINTECHS:
|
||
|
case VUT_MINCITIES:
|
||
|
case VUT_ORIGINAL_OWNER:
|
||
|
case VUT_ROADFLAG:
|
||
|
case VUT_TERRAIN:
|
||
| common/fc_types.h | ||
|---|---|---|
|
int age;
|
||
|
int form_age;
|
||
|
int min_techs;
|
||
|
int min_cities;
|
||
|
int latitude;
|
||
|
enum topo_flag topo_property;
|
||
| ... | ... | |
|
#define SPECENUM_VALUE56NAME "PlayerState"
|
||
|
#define SPECENUM_VALUE57 VUT_FORM_AGE
|
||
|
#define SPECENUM_VALUE57NAME "FormAge"
|
||
|
#define SPECENUM_VALUE58 VUT_MINCITIES
|
||
|
#define SPECENUM_VALUE58NAME "MinCities"
|
||
|
/* Keep this last. */
|
||
|
#define SPECENUM_COUNT VUT_COUNT
|
||
| common/reqtext.c | ||
|---|---|---|
|
}
|
||
|
break;
|
||
|
case VUT_MINCITIES:
|
||
|
switch (preq->range) {
|
||
|
case REQ_RANGE_PLAYER:
|
||
|
fc_strlcat(buf, prefix, bufsz);
|
||
|
if (preq->present) {
|
||
|
cat_snprintf(buf, bufsz,
|
||
|
_("Requires player to have at least %d cities."),
|
||
|
preq->source.value.min_cities);
|
||
|
} else {
|
||
|
cat_snprintf(buf, bufsz,
|
||
|
_("Prevented when player has at least %d cities."),
|
||
|
preq->source.value.min_cities);
|
||
|
}
|
||
|
return TRUE;
|
||
|
case REQ_RANGE_WORLD:
|
||
|
case REQ_RANGE_LOCAL:
|
||
|
case REQ_RANGE_TILE:
|
||
|
case REQ_RANGE_CADJACENT:
|
||
|
case REQ_RANGE_ADJACENT:
|
||
|
case REQ_RANGE_CITY:
|
||
|
case REQ_RANGE_TRADE_ROUTE:
|
||
|
case REQ_RANGE_CONTINENT:
|
||
|
case REQ_RANGE_TEAM:
|
||
|
case REQ_RANGE_ALLIANCE:
|
||
|
case REQ_RANGE_COUNT:
|
||
|
/* Not supported. */
|
||
|
break;
|
||
|
}
|
||
|
break;
|
||
|
case VUT_TERRAINALTER:
|
||
|
switch (preq->range) {
|
||
|
case REQ_RANGE_TILE:
|
||
| common/requirements.c | ||
|---|---|---|
|
return;
|
||
|
}
|
||
|
break;
|
||
|
case VUT_MINCITIES:
|
||
|
source->value.min_cities = atoi(value);
|
||
|
if (source->value.min_cities > 0) {
|
||
|
return;
|
||
|
}
|
||
|
break;
|
||
|
case VUT_ACTION:
|
||
|
source->value.action = action_by_rule_name(value);
|
||
|
if (source->value.action != NULL) {
|
||
| ... | ... | |
|
case VUT_MINTECHS:
|
||
|
source.value.min_techs = value;
|
||
|
return source;
|
||
|
case VUT_MINCITIES:
|
||
|
source.value.min_cities = value;
|
||
|
return source;
|
||
|
case VUT_ACTION:
|
||
|
source.value.action = action_by_number(value);
|
||
|
if (source.value.action != NULL) {
|
||
| ... | ... | |
|
return source->value.form_age;
|
||
|
case VUT_MINTECHS:
|
||
|
return source->value.min_techs;
|
||
|
case VUT_MINCITIES:
|
||
|
return source->value.min_cities;
|
||
|
case VUT_ACTION:
|
||
|
return action_number(source->value.action);
|
||
|
case VUT_OTYPE:
|
||
| ... | ... | |
|
case VUT_AI_LEVEL:
|
||
|
case VUT_PLAYER_FLAG:
|
||
|
case VUT_PLAYER_STATE:
|
||
|
case VUT_MINCITIES:
|
||
|
req.range = REQ_RANGE_PLAYER;
|
||
|
break;
|
||
|
case VUT_MINYEAR:
|
||
| ... | ... | |
|
case VUT_GOVERNMENT:
|
||
|
case VUT_AI_LEVEL:
|
||
|
case VUT_STYLE:
|
||
|
case VUT_MINCITIES:
|
||
|
invalid = (req.range != REQ_RANGE_PLAYER);
|
||
|
break;
|
||
|
case VUT_MINSIZE:
|
||
| ... | ... | |
|
case VUT_DIPLREL_UNITANY_O:
|
||
|
case VUT_MAXTILEUNITS:
|
||
|
case VUT_MINTECHS:
|
||
|
case VUT_MINCITIES:
|
||
|
case VUT_MINLATITUDE:
|
||
|
case VUT_MAXLATITUDE:
|
||
|
/* Most requirements don't support 'survives'. */
|
||
| ... | ... | |
|
}
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Determine whether a minimum cities count requirement is satisfied in a
|
||
|
given context, ignoring parts of the requirement that can be handled
|
||
|
uniformly for all requirement types.
|
||
|
context and req must not be null, and req must be a mincities requirement
|
||
|
**************************************************************************/
|
||
|
static enum fc_tristate
|
||
|
is_mincities_req_active(const struct civ_map *nmap,
|
||
|
const struct req_context *context,
|
||
|
const struct player *other_player,
|
||
|
const struct requirement *req)
|
||
|
{
|
||
|
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_MINCITIES);
|
||
|
switch (req->range) {
|
||
|
case REQ_RANGE_PLAYER:
|
||
|
if (context->player == NULL) {
|
||
|
return TRI_MAYBE;
|
||
|
} else {
|
||
|
/* "None" does not count */
|
||
|
return BOOL_TO_TRISTATE(
|
||
|
city_list_size(context->player->cities)
|
||
|
>= req->source.value.min_cities
|
||
|
);
|
||
|
}
|
||
|
default:
|
||
|
return TRI_MAYBE;
|
||
|
}
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Determine whether an AI level requirement is satisfied in a given
|
||
|
context, ignoring parts of the requirement that can be handled uniformly
|
||
| ... | ... | |
|
[VUT_MINMOVES] = {is_minmovefrags_req_active, REQUCH_NO},
|
||
|
[VUT_MINSIZE] = {is_minsize_req_active, REQUCH_NO},
|
||
|
[VUT_MINTECHS] = {is_mintechs_req_active, REQUCH_ACT, REQUC_WORLD},
|
||
|
[VUT_MINCITIES] = {is_mincities_req_active, REQUCH_NO},
|
||
|
[VUT_MINVETERAN] = {is_minveteran_req_active, REQUCH_SCRIPTS, REQUC_PRESENT},
|
||
|
[VUT_MINYEAR] = {is_minyear_req_active, REQUCH_HACK, REQUC_PRESENT},
|
||
|
[VUT_NATION] = {is_nation_req_active, REQUCH_HACK, REQUC_NALLY},
|
||
| ... | ... | |
|
case VUT_MINCULTURE:
|
||
|
case VUT_MINFOREIGNPCT:
|
||
|
case VUT_MINTECHS:
|
||
|
case VUT_MINCITIES:
|
||
|
case VUT_NATIONALITY:
|
||
|
case VUT_ORIGINAL_OWNER: /* As long as midgame player creation or civil war possible */
|
||
|
case VUT_DIPLREL:
|
||
| ... | ... | |
|
return psource1->value.form_age == psource2->value.form_age;
|
||
|
case VUT_MINTECHS:
|
||
|
return psource1->value.min_techs == psource2->value.min_techs;
|
||
|
case VUT_MINCITIES:
|
||
|
return psource1->value.min_cities == psource2->value.min_cities;
|
||
|
case VUT_ACTION:
|
||
|
return (action_number(psource1->value.action)
|
||
|
== action_number(psource2->value.action));
|
||
| ... | ... | |
|
case VUT_MINTECHS:
|
||
|
fc_snprintf(buffer, sizeof(buffer), "%d", psource->value.min_techs);
|
||
|
return buffer;
|
||
|
case VUT_MINCITIES:
|
||
|
fc_snprintf(buffer, sizeof(buffer), "%d", psource->value.min_cities);
|
||
|
return buffer;
|
||
|
case VUT_ACTION:
|
||
|
return action_rule_name(psource->value.action);
|
||
| ... | ... | |
|
cat_snprintf(buf, bufsz, _("%d Techs"),
|
||
|
psource->value.min_techs);
|
||
|
return buf;
|
||
|
case VUT_MINCITIES:
|
||
|
cat_snprintf(buf, bufsz, _("%d Cities"),
|
||
|
psource->value.min_cities);
|
||
|
return buf;
|
||
|
case VUT_ACTION:
|
||
|
fc_strlcat(buf, action_name_translation(psource->value.action),
|
||
|
bufsz);
|
||
| doc/README.effects | ||
|---|---|---|
|
Tech: World, Alliance, Team, Player
|
||
|
TechFlag: World, Alliance, Team, Player
|
||
|
MinTechs: World, Player
|
||
|
MinCities: Player
|
||
|
Achievement: World, Alliance, Team, Player
|
||
|
Counter: City
|
||
|
Gov: Player
|
||
| server/cityturn.c | ||
|---|---|---|
|
purge = TRUE;
|
||
|
}
|
||
|
break;
|
||
|
case VUT_MINCITIES:
|
||
|
if (preq->present) {
|
||
|
notify_player(pplayer, city_tile(pcity),
|
||
|
E_CITY_CANTBUILD, ftc_server,
|
||
|
_("%s can't build %s from the worklist; "
|
||
|
"Must own %d cities. Postponing..."),
|
||
|
city_link(pcity),
|
||
|
tgt_name,
|
||
|
preq->source.value.min_cities);
|
||
|
script_server_signal_emit(signal_name, ptarget,
|
||
|
pcity, "need_mincities");
|
||
|
} else {
|
||
|
purge = TRUE;
|
||
|
}
|
||
|
break;
|
||
|
case VUT_MAXTILEUNITS:
|
||
|
if (preq->present) {
|
||
|
notify_player(pplayer, city_tile(pcity),
|
||
| server/ruleset/rssanity.c | ||
|---|---|---|
|
case VUT_OTYPE:
|
||
|
case VUT_SPECIALIST:
|
||
|
case VUT_MINSIZE: /* Breaks nothing, but has no sense either */
|
||
|
case VUT_MINCITIES:
|
||
|
case VUT_MINFOREIGNPCT:
|
||
|
case VUT_MINMOVES: /* Breaks nothing, but has no sense either */
|
||
|
case VUT_MINVETERAN: /* Breaks nothing, but has no sense either */
|
||
| tools/ruledit/univ_value.c | ||
|---|---|---|
|
case VUT_MINTECHS:
|
||
|
src->value.min_techs = 0;
|
||
|
return TRUE;
|
||
|
case VUT_MINCITIES:
|
||
|
src->value.min_cities = 0;
|
||
|
return TRUE;
|
||
|
case VUT_EXTRAFLAG:
|
||
|
src->value.extraflag = EF_NATIVE_TILE;
|
||
|
return TRUE;
|
||
| ... | ... | |
|
case VUT_AGE:
|
||
|
case VUT_FORM_AGE:
|
||
|
case VUT_MINTECHS:
|
||
|
case VUT_MINCITIES:
|
||
|
case VUT_MINLATITUDE:
|
||
|
case VUT_MAXLATITUDE:
|
||
|
/* Requirement types having numerical value */
|
||