Implemented holy warriors follower belief (#5411)

* Implemented holy warriors follower belief

* Minor fixes

* Likely fixed the tests

* Made someTroglodyte happy :)

* Removed stray println's

* Implemented requested changes
This commit is contained in:
Xander Lenstra 2021-10-16 19:25:38 +02:00 committed by GitHub
parent de0c1161f6
commit 551e6e1d54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 84 additions and 43 deletions

View File

@ -151,7 +151,11 @@
"type": "Follower", "type": "Follower",
"uniques": ["[+2 Production] <if this city has at least [1] specialists>"] "uniques": ["[+2 Production] <if this city has at least [1] specialists>"]
}, },
// ToDo: Holy Warriors (I have to look up the faith costs for these sometime) {
"name": "Holy Warriors",
"type": "Follower",
"uniques": ["May buy [{Military} {Land}] units with [Faith] for [2] times their normal Production cost <before the [Industrial era]>"]
},
{ {
"name": "Liturgical Drama", "name": "Liturgical Drama",
"type": "Follower", "type": "Follower",

View File

@ -267,7 +267,7 @@
{ {
"name": "Commerce Complete", "name": "Commerce Complete",
"uniques": ["[+1 Gold] from every [Trading post]", "Double gold from Great Merchant trade missions", "uniques": ["[+1 Gold] from every [Trading post]", "Double gold from Great Merchant trade missions",
"May buy [Great Merchant] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] starting from the [Industrial era] at an increasing price ([500])" "May buy [Great Merchant] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] at an increasing price ([500]) <starting from the [Industrial era]>"
] ]
} }
] ]
@ -314,7 +314,7 @@
{ {
"name": "Rationalism Complete", "name": "Rationalism Complete",
"uniques": ["[2] Free Technologies", "uniques": ["[2] Free Technologies",
"May buy [Great Scientist] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] starting from the [Industrial era] at an increasing price ([500])" "May buy [Great Scientist] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] at an increasing price ([500]) <starting from the [Industrial era]>"
] ]
} }
] ]
@ -359,7 +359,7 @@
{ {
"name": "Freedom Complete", "name": "Freedom Complete",
"uniques": ["+[100]% yield from every [Great Improvement]", "Golden Age length increased by [50]%", "uniques": ["+[100]% yield from every [Great Improvement]", "Golden Age length increased by [50]%",
"May buy [Great Artist] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] starting from the [Industrial era] at an increasing price ([500])" "May buy [Great Artist] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] at an increasing price ([500]) <starting from the [Industrial era]>"
] ]
} }
] ]
@ -407,8 +407,8 @@
{ {
"name": "Autocracy Complete", "name": "Autocracy Complete",
"uniques": ["+[25]% attack strength to all [Military] units for [50] turns", "uniques": ["+[25]% attack strength to all [Military] units for [50] turns",
"May buy [Great General] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] starting from the [Industrial era] at an increasing price ([500])", "May buy [Great General] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] at an increasing price ([500]) <starting from the [Industrial era]>",
"May buy [Great Admiral] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] starting from the [Industrial era] at an increasing price ([500])" "May buy [Great Admiral] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] at an increasing price ([500]) <starting from the [Industrial era]>"
] ]
} }
] ]
@ -453,7 +453,7 @@
{ {
"name": "Order Complete", "name": "Order Complete",
"uniques": ["[+2 Food, +2 Production, +2 Science, +2 Gold, +2 Culture] [in all cities]", "uniques": ["[+2 Food, +2 Production, +2 Science, +2 Gold, +2 Culture] [in all cities]",
"May buy [Great Engineer] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] starting from the [Industrial era] at an increasing price ([500])" "May buy [Great Engineer] units for [1000] [Faith] [in all cities in which the majority religion is a major religion] at an increasing price ([500]) <starting from the [Industrial era]>"
] ]
} }
] ]

View File

@ -507,7 +507,6 @@ Check extension mods based on vanilla =
Checking mods for errors... = Checking mods for errors... =
Show experimental world wrap for maps = Show experimental world wrap for maps =
HIGHLY EXPERIMENTAL - YOU HAVE BEEN WARNED! = HIGHLY EXPERIMENTAL - YOU HAVE BEEN WARNED! =
HIGHLY EXPERIMENTAL - UPDATES WILL BREAK SAVES! =
Enable portrait orientation = Enable portrait orientation =
Generate translation files = Generate translation files =
Translation files are generated successfully. = Translation files are generated successfully. =

View File

@ -150,6 +150,8 @@ object ChooseBeliefsAutomation {
// This is something completely different from the original, but I have no idea // This is something completely different from the original, but I have no idea
// what happens over there // what happens over there
else civInfo.statsForNextTurn[Stat.valueOf(unique.params[1])] * 10f / civInfo.getEra().baseUnitBuyCost else civInfo.statsForNextTurn[Stat.valueOf(unique.params[1])] * 10f / civInfo.getEra().baseUnitBuyCost
UniqueType.BuyUnitsByProductionCost.placeholderText ->
15f * if (civInfo.victoryType() == VictoryType.Domination) 2f else 1f
"when a city adopts this religion for the first time (modified by game speed)" -> // Modified by personality "when a city adopts this religion for the first time (modified by game speed)" -> // Modified by personality
unique.stats.values.sum() * 10f unique.stats.values.sum() * 10f
"When spreading religion to a city, gain [] times the amount of followers of other religions as []" -> "When spreading religion to a city, gain [] times the amount of followers of other religions as []" ->
@ -160,7 +162,7 @@ object ChooseBeliefsAutomation {
unique.params[0].toInt() / 7f unique.params[0].toInt() / 7f
"[] for each global city following this religion" -> "[] for each global city following this religion" ->
50f / unique.stats.values.sum() 50f / unique.stats.values.sum()
"whenever a Great Person is expended" -> UniqueType.StatsSpendingGreatPeople.placeholderText ->
unique.stats.values.sum() / 2f unique.stats.values.sum() / 2f
"[]% Natural religion spread to []" -> "[]% Natural religion spread to []" ->
unique.params[0].toFloat() / 4f unique.params[0].toFloat() / 4f

View File

@ -716,18 +716,10 @@ class CityInfo {
// Finds matching uniques provided from both local and non-local sources. // Finds matching uniques provided from both local and non-local sources.
fun getMatchingUniques( fun getMatchingUniques(
uniqueType: UniqueType, uniqueType: UniqueType,
// We might have this cached to avoid concurrency problems. If we don't, just get it directly
localUniques: Sequence<Unique> = getLocalMatchingUniques(uniqueType),
stateForConditionals: StateForConditionals? = null, stateForConditionals: StateForConditionals? = null,
): Sequence<Unique> { ): Sequence<Unique> {
// The localUniques might not be filtered when passed as a parameter, so we filter it anyway
// The time loss shouldn't be that large I don't think
return civInfo.getMatchingUniques(uniqueType, stateForConditionals, this) + return civInfo.getMatchingUniques(uniqueType, stateForConditionals, this) +
localUniques.filter { getLocalMatchingUniques(uniqueType, stateForConditionals)
it.isOfType(uniqueType)
&& it.conditionalsApply(stateForConditionals)
&& it.params.none { param -> param == "in other cities" }
}
} }
// Matching uniques provided by sources in the city itself // Matching uniques provided by sources in the city itself

View File

@ -349,7 +349,7 @@ class MapUnit {
visibilityRange += (getMatchingUniques(UniqueType.Sight, StateForConditionals(civInfo = civInfo, unit = this)) visibilityRange += (getMatchingUniques(UniqueType.Sight, StateForConditionals(civInfo = civInfo, unit = this))
+ civInfo.getMatchingUniques(UniqueType.Sight, StateForConditionals(civInfo = civInfo, unit = this)) + civInfo.getMatchingUniques(UniqueType.Sight, StateForConditionals(civInfo = civInfo, unit = this))
).sumOf { it.params[0].toInt() } ).sumOf { it.params[0].toInt() }
// Deprecated since 3.17.5 // Deprecated since 3.17.5
for (unique in getMatchingUniques(UniqueType.SightUnits)) for (unique in getMatchingUniques(UniqueType.SightUnits))
if (matchesFilter(unique.params[1])) if (matchesFilter(unique.params[1]))
@ -1051,6 +1051,7 @@ class MapUnit {
if (filter.contains('{')) // multiple types at once - AND logic. Looks like:"{Military} {Land}" if (filter.contains('{')) // multiple types at once - AND logic. Looks like:"{Military} {Land}"
return filter.removePrefix("{").removeSuffix("}").split("} {") return filter.removePrefix("{").removeSuffix("}").split("} {")
.all { matchesFilter(it) } .all { matchesFilter(it) }
return when (filter) { return when (filter) {
// todo: unit filters should be adjectives, fitting "[filterType] units" // todo: unit filters should be adjectives, fitting "[filterType] units"
// This means converting "wounded units" to "Wounded", "Barbarians" to "Barbarian" // This means converting "wounded units" to "Wounded", "Barbarians" to "Barbarian"

View File

@ -564,7 +564,10 @@ class Ruleset {
} }
for (nation in nations.values) { for (nation in nations.values) {
checkUniques(nation, lines, UniqueType.UniqueComplianceErrorSeverity.RulesetSpecific) checkUniques(nation, lines, UniqueType.UniqueComplianceErrorSeverity.RulesetSpecific)
if (nation.favoredReligion != null && nation.favoredReligion !in religions)
lines += "${nation.name} has ${nation.favoredReligion} as their favored religion, which does not exist!"
} }
for (policy in policies.values) { for (policy in policies.values) {
if (policy.requires != null) if (policy.requires != null)
for (prereq in policy.requires!!) for (prereq in policy.requires!!)

View File

@ -51,6 +51,12 @@ class Unique(val text: String, val sourceObjectType: UniqueTarget? = null, val s
state.civInfo != null && state.civInfo.statsForNextTurn.happiness >= 0 state.civInfo != null && state.civInfo.statsForNextTurn.happiness >= 0
UniqueType.ConditionalGoldenAge -> UniqueType.ConditionalGoldenAge ->
state.civInfo != null && state.civInfo.goldenAges.isGoldenAge() state.civInfo != null && state.civInfo.goldenAges.isGoldenAge()
UniqueType.ConditionalBeforeEra ->
state.civInfo != null && state.civInfo.getEraNumber() < state.civInfo.gameInfo.ruleSet.eras[condition.params[0]]!!.eraNumber
UniqueType.ConditionalStartingFromEra ->
state.civInfo != null && state.civInfo.getEraNumber() >= state.civInfo.gameInfo.ruleSet.eras[condition.params[0]]!!.eraNumber
UniqueType.ConditionalDuringEra ->
state.civInfo != null && state.civInfo.getEraNumber() == state.civInfo.gameInfo.ruleSet.eras[condition.params[0]]!!.eraNumber
UniqueType.ConditionalSpecialistCount -> UniqueType.ConditionalSpecialistCount ->
state.cityInfo != null && state.cityInfo.population.getNumberOfSpecialists() >= condition.params[0].toInt() state.cityInfo != null && state.cityInfo.population.getNumberOfSpecialists() >= condition.params[0].toInt()

View File

@ -77,6 +77,8 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) {
StatsFromSpecialistDeprecated("[stats] from every specialist", UniqueTarget.Global), StatsFromSpecialistDeprecated("[stats] from every specialist", UniqueTarget.Global),
StatsPerPopulation("[stats] per [amount] population [cityFilter]", UniqueTarget.Global), StatsPerPopulation("[stats] per [amount] population [cityFilter]", UniqueTarget.Global),
StatsSpendingGreatPeople("[stats] whenever a Great Person is expended", UniqueTarget.Global),
/////// City-State related uniques /////// City-State related uniques
@ -104,10 +106,8 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) {
@Deprecated("As of 3.16.16", ReplaceWith("[amount]% maintenance costs for [mapUnitFilter] units"), DeprecationLevel.WARNING) @Deprecated("As of 3.16.16", ReplaceWith("[amount]% maintenance costs for [mapUnitFilter] units"), DeprecationLevel.WARNING)
DecreasedUnitMaintenanceCostsGlobally("-[amount]% unit upkeep costs", UniqueTarget.Global), DecreasedUnitMaintenanceCostsGlobally("-[amount]% unit upkeep costs", UniqueTarget.Global),
ConsumesResources("Consumes [amount] [resource]", ConsumesResources("Consumes [amount] [resource]", UniqueTarget.Improvement, UniqueTarget.Building, UniqueTarget.Unit),
UniqueTarget.Improvement, UniqueTarget.Building, UniqueTarget.Unit), ProvidesResources("Provides [amount] [resource]", UniqueTarget.Improvement, UniqueTarget.Building),
ProvidesResources("Provides [amount] [resource]",
UniqueTarget.Improvement, UniqueTarget.Building),
GrowthPercentBonus("[amount]% growth [cityFilter]", UniqueTarget.Global, UniqueTarget.FollowerBelief), GrowthPercentBonus("[amount]% growth [cityFilter]", UniqueTarget.Global, UniqueTarget.FollowerBelief),
@Deprecated("As of 3.16.14", ReplaceWith("[amount]% growth [cityFilter]"), DeprecationLevel.WARNING) @Deprecated("As of 3.16.14", ReplaceWith("[amount]% growth [cityFilter]"), DeprecationLevel.WARNING)
@ -122,6 +122,11 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) {
FreeExtraBeliefs("May choose [amount] additional [beliefType] beliefs when [foundingOrEnhancing] a religion", UniqueTarget.Global), FreeExtraBeliefs("May choose [amount] additional [beliefType] beliefs when [foundingOrEnhancing] a religion", UniqueTarget.Global),
FreeExtraAnyBeliefs("May choose [amount] additional belief(s) of any type when [foundingOrEnhancing] a religion", UniqueTarget.Global), FreeExtraAnyBeliefs("May choose [amount] additional belief(s) of any type when [foundingOrEnhancing] a religion", UniqueTarget.Global),
BuyUnitsIncreasingCost("May buy [baseUnitFilter] units for [amount] [stat] [cityFilter] at an increasing price ([amount])", UniqueTarget.Global),
@Deprecated("As of 3.17.9", ReplaceWith ("May buy [baseUnitFilter] units for [amount] [stat] [cityFilter] at an increasing price ([amount]) <starting from the [era]>"))
BuyUnitsIncreasingCostEra("May buy [baseUnitFilter] units for [amount] [stat] [cityFilter] starting from the [era] at an increasing price ([amount])", UniqueTarget.Global),
BuyUnitsByProductionCost("May buy [baseUnitFilter] units with [stat] for [amount] times their normal Production cost", UniqueTarget.FollowerBelief, UniqueTarget.Global),
MayanGainGreatPerson("Receive a free Great Person at the end of every [comment] (every 394 years), after researching [tech]. Each bonus person can only be chosen once.", UniqueTarget.Nation), MayanGainGreatPerson("Receive a free Great Person at the end of every [comment] (every 394 years), after researching [tech]. Each bonus person can only be chosen once.", UniqueTarget.Nation),
MayanCalendarDisplay("Once The Long Count activates, the year on the world screen displays as the traditional Mayan Long Count.", UniqueTarget.Nation), MayanCalendarDisplay("Once The Long Count activates, the year on the world screen displays as the traditional Mayan Long Count.", UniqueTarget.Nation),
@ -213,7 +218,7 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) {
HiddenWithoutReligion("Hidden when religion is disabled", UniqueTarget.Unit, UniqueTarget.Building, UniqueTarget.Ruins), HiddenWithoutReligion("Hidden when religion is disabled", UniqueTarget.Unit, UniqueTarget.Building, UniqueTarget.Ruins),
//////////////////////////////////////// TERRAIN UNIQUES //////////////////////////////////////// ///////////////////////////////////////// TILE UNIQUES /////////////////////////////////////////
NaturalWonderNeighborCount("Must be adjacent to [amount] [simpleTerrain] tiles", UniqueTarget.Terrain), NaturalWonderNeighborCount("Must be adjacent to [amount] [simpleTerrain] tiles", UniqueTarget.Terrain),
@ -245,6 +250,10 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) {
ConditionalNotWar("when not at war", UniqueTarget.Conditional), ConditionalNotWar("when not at war", UniqueTarget.Conditional),
ConditionalHappy("while the empire is happy", UniqueTarget.Conditional), ConditionalHappy("while the empire is happy", UniqueTarget.Conditional),
ConditionalGoldenAge("during a Golden Age", UniqueTarget.Conditional), ConditionalGoldenAge("during a Golden Age", UniqueTarget.Conditional),
ConditionalDuringEra("during the [era]", UniqueTarget.Conditional),
ConditionalBeforeEra("before the [era]", UniqueTarget.Conditional),
ConditionalStartingFromEra("starting from the [era]", UniqueTarget.Conditional),
// city conditionals // city conditionals
ConditionalSpecialistCount("if this city has at least [amount] specialists", UniqueTarget.Conditional), ConditionalSpecialistCount("if this city has at least [amount] specialists", UniqueTarget.Conditional),
@ -265,6 +274,7 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) {
///////////////////////////////////////// TRIGGERED ONE-TIME ///////////////////////////////////////// ///////////////////////////////////////// TRIGGERED ONE-TIME /////////////////////////////////////////
OneTimeFreeUnit("Free [baseUnitFilter] appears", UniqueTarget.Global), // used in Policies, Buildings OneTimeFreeUnit("Free [baseUnitFilter] appears", UniqueTarget.Global), // used in Policies, Buildings
OneTimeAmountFreeUnits("[amount] free [baseUnitFilter] units appear", UniqueTarget.Global), // used in Buildings OneTimeAmountFreeUnits("[amount] free [baseUnitFilter] units appear", UniqueTarget.Global), // used in Buildings
OneTimeFreeUnitRuins("Free [baseUnitFilter] found in the ruins", UniqueTarget.Ruins), // Differs from "Free [] appears" in that it spawns near the ruins instead of in a city OneTimeFreeUnitRuins("Free [baseUnitFilter] found in the ruins", UniqueTarget.Ruins), // Differs from "Free [] appears" in that it spawns near the ruins instead of in a city

View File

@ -6,6 +6,7 @@ import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.logic.map.MapUnit import com.unciv.logic.map.MapUnit
import com.unciv.models.ruleset.Ruleset import com.unciv.models.ruleset.Ruleset
import com.unciv.models.ruleset.RulesetObject import com.unciv.models.ruleset.RulesetObject
import com.unciv.models.ruleset.unique.StateForConditionals
import com.unciv.models.ruleset.unique.UniqueTarget import com.unciv.models.ruleset.unique.UniqueTarget
import com.unciv.models.ruleset.unique.UniqueType import com.unciv.models.ruleset.unique.UniqueType
import com.unciv.models.stats.Stat import com.unciv.models.stats.Stat
@ -250,7 +251,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
override fun canBePurchasedWithStat(cityInfo: CityInfo?, stat: Stat): Boolean { override fun canBePurchasedWithStat(cityInfo: CityInfo?, stat: Stat): Boolean {
// May buy [unitFilter] units for [amount] [Stat] [cityFilter] starting from the [eraName] at an increasing price ([amount]) // May buy [unitFilter] units for [amount] [Stat] [cityFilter] starting from the [eraName] at an increasing price ([amount])
if (cityInfo != null && cityInfo.civInfo.getMatchingUniques("May buy [] units for [] [] [] starting from the [] at an increasing price ([])") if (cityInfo != null && cityInfo.getMatchingUniques("May buy [] units for [] [] [] starting from the [] at an increasing price ([])")
.any { .any {
matchesFilter(it.params[0]) matchesFilter(it.params[0])
&& cityInfo.matchesFilter(it.params[3]) && cityInfo.matchesFilter(it.params[3])
@ -260,13 +261,22 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
) return true ) return true
// May buy [unitFilter] units for [amount] [Stat] [cityFilter] at an increasing price ([amount]) // May buy [unitFilter] units for [amount] [Stat] [cityFilter] at an increasing price ([amount])
if (cityInfo != null && cityInfo.civInfo.getMatchingUniques("May buy [] units for [] [] [] at an increasing price ([])") if (cityInfo != null && cityInfo.getMatchingUniques("May buy [] units for [] [] [] at an increasing price ([])")
.any { .any {
matchesFilter(it.params[0]) matchesFilter(it.params[0])
&& cityInfo.matchesFilter(it.params[3]) && cityInfo.matchesFilter(it.params[3])
&& it.params[2] == stat.name && it.params[2] == stat.name
} }
) return true ) return true
if (cityInfo != null && cityInfo.getMatchingUniques(
UniqueType.BuyUnitsByProductionCost,
stateForConditionals = StateForConditionals(civInfo = cityInfo.civInfo, cityInfo = cityInfo)
).any {
matchesFilter(it.params[0])
&& it.params[1] == stat.name
}
) return true
return super.canBePurchasedWithStat(cityInfo, stat) return super.canBePurchasedWithStat(cityInfo, stat)
} }
@ -277,24 +287,26 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
override fun getBaseBuyCost(cityInfo: CityInfo, stat: Stat): Int? { override fun getBaseBuyCost(cityInfo: CityInfo, stat: Stat): Int? {
if (stat == Stat.Gold) return getBaseGoldCost(cityInfo.civInfo).toInt() if (stat == Stat.Gold) return getBaseGoldCost(cityInfo.civInfo).toInt()
val conditionalState = StateForConditionals(civInfo = cityInfo.civInfo, cityInfo = cityInfo)
return ( return (
sequenceOf(super.getBaseBuyCost(cityInfo, stat)).filterNotNull() sequenceOf(super.getBaseBuyCost(cityInfo, stat)).filterNotNull()
// May buy [unitFilter] units for [amount] [Stat] starting from the [eraName] at an increasing price ([amount]) // Deprecated since 3.17.9
+ (cityInfo.civInfo.getMatchingUniques("May buy [] units for [] [] [] starting from the [] at an increasing price ([])") + (cityInfo.getMatchingUniques(UniqueType.BuyUnitsIncreasingCostEra, conditionalState)
.filter { .filter {
matchesFilter(it.params[0]) matchesFilter(it.params[0])
&& cityInfo.matchesFilter(it.params[3]) && cityInfo.matchesFilter(it.params[3])
&& cityInfo.civInfo.getEraNumber() >= ruleset.eras[it.params[4]]!!.eraNumber && cityInfo.civInfo.getEraNumber() >= ruleset.eras[it.params[4]]!!.eraNumber
&& it.params[2] == stat.name && it.params[2] == stat.name
}.map { }.map {
getCostForConstructionsIncreasingInPrice( getCostForConstructionsIncreasingInPrice(
it.params[1].toInt(), it.params[1].toInt(),
it.params[5].toInt(), it.params[5].toInt(),
cityInfo.civInfo.civConstructions.boughtItemsWithIncreasingPrice[name] ?: 0 cityInfo.civInfo.civConstructions.boughtItemsWithIncreasingPrice[name] ?: 0
) )
} }
) )
+ (cityInfo.civInfo.getMatchingUniques("May buy [] units for [] [] [] at an increasing price ([])") //
+ (cityInfo.getMatchingUniques(UniqueType.BuyUnitsIncreasingCost, conditionalState)
.filter { .filter {
matchesFilter(it.params[0]) matchesFilter(it.params[0])
&& cityInfo.matchesFilter(it.params[3]) && cityInfo.matchesFilter(it.params[3])
@ -307,6 +319,15 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
) )
} }
) )
+ (cityInfo.getMatchingUniques(
UniqueType.BuyUnitsByProductionCost, conditionalState
).filter {
it.params[1] == stat.name
&& matchesFilter(it.params[0])
}.map {
getProductionCost(cityInfo.civInfo) * it.params[2].toInt()
}
)
).minOrNull() ).minOrNull()
} }
@ -493,6 +514,9 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
} }
fun matchesFilter(filter: String): Boolean { fun matchesFilter(filter: String): Boolean {
if (filter.contains('{')) // multiple types at once - AND logic. Looks like:"{Military} {Land}"
return filter.removePrefix("{").removeSuffix("}").split("} {")
.all { matchesFilter(it) }
return when (filter) { return when (filter) {
unitType -> true unitType -> true

View File

@ -213,7 +213,7 @@ class Translations : LinkedHashMap<String, TranslationEntry>(){
// Whenever this string is changed, it should also be changed in the translation files! // Whenever this string is changed, it should also be changed in the translation files!
// It is mostly used as the template for translating the order of conditionals // It is mostly used as the template for translating the order of conditionals
const val englishConditionalOrderingString = const val englishConditionalOrderingString =
"<for [mapUnitFilter] units> <vs cities> <vs [mapUnitFilter] units> <when fighting in [tileFilter] tiles> <when attacking> <when defending> <if this city has at least [amount] specialists> <when at war> <when not at war> <while the empire is happy> <during a Golden Age>" "<for [mapUnitFilter] units> <vs cities> <vs [mapUnitFilter] units> <when fighting in [tileFilter] tiles> <when attacking> <when defending> <if this city has at least [amount] specialists> <when at war> <when not at war> <while the empire is happy> <during a Golden Age> <during the [era]> <before the [era]> <starting from the [era]>"
const val conditionalUniqueOrderString = "ConditionalsPlacement" const val conditionalUniqueOrderString = "ConditionalsPlacement"
const val shouldCapitalizeString = "StartWithCapitalLetter" const val shouldCapitalizeString = "StartWithCapitalLetter"
} }