mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-22 10:54:19 -04:00
Merge 1d0c94d2c59ca82174c66ad1e4f2a76cf45c31d5 into d51ef24c205b6b05330b3c4d7ce79c402db44447
This commit is contained in:
commit
ed48e1d880
@ -164,6 +164,23 @@ enum class Countables(
|
|||||||
.map { text.fillPlaceholders(it) }.toSet()
|
.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") {
|
RemainingCivs("Remaining [civFilter] Civilizations") {
|
||||||
override fun eval(parameterText: String, gameContext: GameContext): Int? {
|
override fun eval(parameterText: String, gameContext: GameContext): Int? {
|
||||||
val filter = parameterText.getPlaceholderParameters()[0]
|
val filter = parameterText.getPlaceholderParameters()[0]
|
||||||
|
@ -379,6 +379,8 @@ Allowed values:
|
|||||||
- Example: `Only available <when number of [[Culture] Buildings] is more than [0]>`
|
- Example: `Only available <when number of [[Culture] Buildings] is more than [0]>`
|
||||||
- `Adopted [policyFilter] Policies`
|
- `Adopted [policyFilter] Policies`
|
||||||
- Example: `Only available <when number of [Adopted [Oligarchy] Policies] is more than [0]>`
|
- 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`
|
- `Remaining [civFilter] Civilizations`
|
||||||
- Example: `Only available <when number of [Remaining [City-States] Civilizations] is more than [0]>`
|
- Example: `Only available <when number of [Remaining [City-States] Civilizations] is more than [0]>`
|
||||||
- `Owned [tileFilter] Tiles`
|
- `Owned [tileFilter] Tiles`
|
||||||
|
@ -244,6 +244,16 @@ class CountableTests {
|
|||||||
freePolicies++
|
freePolicies++
|
||||||
adopt(taggedPolicyBranch) // Will be completed as it has no member policies
|
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(
|
val tests = listOf(
|
||||||
"Completed Policy branches" to 2, // Tradition and taggedPolicyBranch
|
"Completed Policy branches" to 2, // Tradition and taggedPolicyBranch
|
||||||
"Adopted [Tradition Complete] Policies" to 1,
|
"Adopted [Tradition Complete] Policies" to 1,
|
||||||
@ -251,6 +261,8 @@ class CountableTests {
|
|||||||
"Adopted [Liberty Complete] Policies" to 0,
|
"Adopted [Liberty Complete] Policies" to 0,
|
||||||
"Adopted [[Liberty] branch] Policies" to 2, // Liberty has only 1 member adopted
|
"Adopted [[Liberty] branch] Policies" to 2, // Liberty has only 1 member adopted
|
||||||
"Adopted [Some marker] Policies" to 1,
|
"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) {
|
for ((test, expected) in tests) {
|
||||||
val actual = Countables.getCountableAmount(test, GameContext(civ))
|
val actual = Countables.getCountableAmount(test, GameContext(civ))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user