New cityFilter for cities connected to capital

This commit is contained in:
Yair Morgenstern 2021-02-05 15:34:20 +02:00
parent 1e6c8dacff
commit 84c200bd32
4 changed files with 22 additions and 6 deletions

View File

@ -24,7 +24,7 @@
},
{
"name": "Landed Elite",
"uniques": ["+[10]% growth in capital", "[+2 Food] in capital"],
"uniques": ["+[10]% growth [in capital]", "[+2 Food] [in capital]"],
"requires": ["Legalism"],
"row": 2,
"column": 2
@ -38,14 +38,14 @@
},
{
"name": "Tradition Complete",
"uniques": ["+[15]% growth in all cities","[+2 Food] in all cities"]
"uniques": ["+[15]% growth [in all cities]","[+2 Food] [in all cities]"]
}
]
},
{
"name": "Liberty",
"era": "Ancient era",
"uniques": ["[+1 Culture] in all cities"],
"uniques": ["[+1 Culture] [in all cities]"],
"policies": [
{
"name": "Collective Rule",
@ -61,7 +61,7 @@
},
{
"name": "Republic",
"uniques": ["[+1 Production] in all cities", "+[5]% Production when constructing [Buildings]"],
"uniques": ["[+1 Production] [in all cities]", "+[5]% Production when constructing [Buildings]"],
"requires": ["Collective Rule"],
"row": 2,
"column": 1
@ -75,7 +75,7 @@
},
{
"name": "Meritocracy",
"uniques": ["+1 happiness for every city connected to capital", "Unhappiness from population decreased by [5]%"],
"uniques": ["[+1 Happiness] [in all cities connected to capital]", "Unhappiness from population decreased by [5]%"],
"requires": ["Citizenship"],
"row": 2,
"column": 5

View File

@ -655,6 +655,7 @@ class CityInfo {
filter == "in all coastal cities" && getCenterTile().isCoastalTile() -> true
filter == "in capital" && isCapital() -> true
filter == "in all cities with a world wonder" && cityConstructions.getBuiltBuildings().any { it.isWonder } -> true
filter == "in all cities connected to capital" -> isConnectedToCapital()
else -> false
}
}

View File

@ -159,10 +159,17 @@ class CityStats {
fun getGrowthBonusFromPoliciesAndWonders(): Float {
var bonus = 0f
// This requires more... complex navigation of the local uniques to merge into "+[amount]% growth [cityFilter]"
for (unique in cityInfo.civInfo.getMatchingUniques("+[]% growth in all cities"))
bonus += unique.params[0].toFloat()
// Deprecated as of 3.12.13 -> moved to "+[amount]% growth [in capital]"
if (cityInfo.isCapital()) for (unique in cityInfo.civInfo.getMatchingUniques("+[]% growth in capital"))
bonus += unique.params[0].toFloat()
// "+[amount]% growth [cityFilter]"
for (unique in cityInfo.civInfo.getMatchingUniques("+[]% growth []"))
if (cityInfo.matchesFilter(unique.params[0]))
bonus += unique.params[0].toFloat()
return bonus / 100
}
@ -196,6 +203,7 @@ class CityStats {
newHappinessList["Population"] = -unhappinessFromCitizens * unhappinessModifier
var happinessFromPolicies = 0f
// Deprecated as of 3.12.13 - replaced by "[+1 Happiness] [in all cities connected to capital]"
if (civInfo.hasUnique("+1 happiness for every city connected to capital")
&& cityInfo.isConnectedToCapital())
happinessFromPolicies += 1f
@ -248,11 +256,17 @@ class CityStats {
val stats = Stats()
for (unique in uniques.toList()) { // Should help mitigate getConstructionButtonDTOs concurrency problems.
// Deprecated by 3.12.13 - replaced by "[stats] [cityFilter]"
if (unique.placeholderText == "[] in capital" && cityInfo.isCapital()
|| unique.placeholderText == "[] in all cities"
|| unique.placeholderText == "[] in all cities with a garrison" && cityInfo.getCenterTile().militaryUnit != null)
stats.add(unique.stats)
// "[stats] [cityFilter]"
if (unique.placeholderText == "[] []" && cityInfo.matchesFilter(unique.params[1]))
stats.add(unique.stats)
// "[stats] per [amount] population [cityfilter]"
if (unique.placeholderText=="[] per [] population []" && cityInfo.matchesFilter(unique.params[2])) {
val amountOfEffects = (cityInfo.population.population / unique.params[1].toInt()).toFloat()
@ -418,7 +432,7 @@ class CityStats {
fun update(currentConstruction: IConstruction = cityInfo.cityConstructions.getCurrentConstruction()) {
val citySpecificUniques: Sequence<Unique> = cityInfo.cityConstructions.builtBuildingUniqueMap.getAllUniques()
.filter { it.params.size>0 && it.params.last()=="in this city" }
.filter { it.params.isNotEmpty() && it.params.last()=="in this city" }
// We need to compute Tile yields before happiness
updateBaseStatList()
updateCityHappiness()

View File

@ -216,6 +216,7 @@ object TranslationFileWriter {
|| parameter == "in all coastal cities"
|| parameter == "in capital"
|| parameter == "in all cities with a world wonder"
|| parameter == "in all cities connected to capital"
-> "cityFilter"
else -> "param"
}