Filters for requirements
Posted: Thu Feb 14, 2019 8:07 pm
A step to make requirements mechanism in rulesets more flexible: for requirements that test or count several objects, make filters that are requirement vectors for the entities to take into account. For example, design "Wall Street" small wonder that can be built only with 5 banks at the player, as in CivIII:
For "World"/"Alliance"/etc. ranged requirements, the filters should filter by players; for "Player"/"Continent"/"Traderoute" ranges, by cities; for "City" ranged, by citizens/buildings/etc. by context; terrain requirements with "Local" range should iterate by extras and/or tiles, and MaxUnitsOnTile, by units. This enhancement of the mechanics should be more or less understandable for the AI (like, 'we are interested in growing our treasury; aha, effect_wall_street gives us a good bonus, we want it; then we want to build Wall Street; then we need to fulfill the requirement, but we have only 2 cities that pass the filter; aha, what we need in a city is to build there a Bank; then build banks in 5 - 2 = 3 cities')
Code: Select all
;Somewhere, e.g. in game.ruleset or effects.ruleset
[filter_bank]
name = "f_bank"
reqs =
{ "type", "name", "range"
"Building", "Bank", "City"
}
;buildings.ruleset
[building_wall_street]
name = _("Wall Street")
genus = "SmallWonder"
reqs =
{ "type", "name", "range", "filter"
"MinCities", 5, "Player", "f_bank" ; with no filter, number of ALL player cities would be compared to 5
}
;(for CivIII compatibility, we also need an effect of treasury
; growing MAX(pplayer->economic.gold/20, 50) per turn with it)