mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-21 18:36:17 -04:00
Add Adoped Policies by Civilizations
This commit is contained in:
parent
d51ef24c20
commit
1d0c94d2c5
@ -164,6 +164,23 @@ enum class Countables(
|
||||
.map { text.fillPlaceholders(it) }.toSet()
|
||||
},
|
||||
|
||||
FilteredPoliciesByCivs("Adopted [policyFilter] Policies by [civFilter] Civilizations") {
|
||||
override fun eval(parameterText: String, gameContext: GameContext): Int? {
|
||||
val (policyFilter, civFilter) = parameterText.getPlaceholderParameters().takeIf { it.size >= 2 } ?: return null
|
||||
val civilizations = gameContext.gameInfo?.civilizations ?: return null
|
||||
return civilizations
|
||||
.filter { it.isAlive() && it.matchesFilter(civFilter, gameContext) }
|
||||
.sumOf { it.policies.getAdoptedPoliciesMatching(policyFilter, gameContext).size }
|
||||
}
|
||||
override fun getErrorSeverity(parameterText: String, ruleset: Ruleset): UniqueType.UniqueParameterErrorSeverity? {
|
||||
val params = parameterText.getPlaceholderParameters()
|
||||
if (params.size < 2) return UniqueType.UniqueParameterErrorSeverity.RulesetInvariant
|
||||
return UniqueParameterType.PolicyFilter.getErrorSeverity(params[0], ruleset) ?:
|
||||
UniqueParameterType.CivFilter.getErrorSeverity(params[1], ruleset)
|
||||
}
|
||||
override fun getKnownValuesForAutocomplete(ruleset: Ruleset) = setOf<String>()
|
||||
},
|
||||
|
||||
RemainingCivs("Remaining [civFilter] Civilizations") {
|
||||
override fun eval(parameterText: String, gameContext: GameContext): Int? {
|
||||
val filter = parameterText.getPlaceholderParameters()[0]
|
||||
|
@ -379,6 +379,8 @@ Allowed values:
|
||||
- Example: `Only available <when number of [[Culture] Buildings] is more than [0]>`
|
||||
- `Adopted [policyFilter] Policies`
|
||||
- Example: `Only available <when number of [Adopted [Oligarchy] Policies] is more than [0]>`
|
||||
- `Adopted [policyFilter] Policies by [civFilter] Civilizations`
|
||||
- Example: `Only available <when number of [Adopted [Oligarchy] Policies by [City-States] Civilizations] is more than [0]>`
|
||||
- `Remaining [civFilter] Civilizations`
|
||||
- Example: `Only available <when number of [Remaining [City-States] Civilizations] is more than [0]>`
|
||||
- `Owned [tileFilter] Tiles`
|
||||
|
@ -244,6 +244,16 @@ class CountableTests {
|
||||
freePolicies++
|
||||
adopt(taggedPolicyBranch) // Will be completed as it has no member policies
|
||||
}
|
||||
|
||||
// Add a second Civilization
|
||||
val civ2 = game.addCiv()
|
||||
val city2 = game.addCity(civ2, game.tileMap[2,2])
|
||||
civ2.policies.run {
|
||||
freePolicies += 2
|
||||
adopt(getPolicyByName("Tradition"))
|
||||
adopt(getPolicyByName("Oligarchy"))
|
||||
}
|
||||
|
||||
val tests = listOf(
|
||||
"Completed Policy branches" to 2, // Tradition and taggedPolicyBranch
|
||||
"Adopted [Tradition Complete] Policies" to 1,
|
||||
@ -251,6 +261,8 @@ class CountableTests {
|
||||
"Adopted [Liberty Complete] Policies" to 0,
|
||||
"Adopted [[Liberty] branch] Policies" to 2, // Liberty has only 1 member adopted
|
||||
"Adopted [Some marker] Policies" to 1,
|
||||
"Adopted [Some marker] Policies by [All] Civilizations" to 1,
|
||||
"Adopted [Oligarchy] Policies by [All] Civilizations" to 2,
|
||||
)
|
||||
for ((test, expected) in tests) {
|
||||
val actual = Countables.getCountableAmount(test, GameContext(civ))
|
||||
|
Loading…
x
Reference in New Issue
Block a user