Add ability to remove policies with ModOptions (#13548)

* Add ability to remove policies with ModOptions

* Remove policies from the branches too

* Clean docs
This commit is contained in:
Rob Loach 2025-07-03 03:59:08 -04:00 committed by GitHub
parent 834239774a
commit 11b53f6cdc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 0 deletions

View File

@ -14,6 +14,7 @@ class ModOptions : IHasUniques {
var unitsToRemove = HashSet<String>()
var nationsToRemove = HashSet<String>()
var policyBranchesToRemove = HashSet<String>()
var policiesToRemove = HashSet<String>()
val constants = ModConstants()
var unitset: String? = null
var tileset: String? = null

View File

@ -211,6 +211,22 @@ class Ruleset {
}
policyBranches.putAll(ruleset.policyBranches)
policies.putAll(ruleset.policies)
// Remove the policies
ruleset.modOptions.policiesToRemove
.flatMap { policyToRemove ->
policies.filter { it.value.matchesFilter(policyToRemove) }.keys
}.toSet().forEach {
policies.remove(it)
}
// Remove the policies if they exist in the policy branches too
for (policyToRemove in ruleset.modOptions.policiesToRemove) {
for (branch in policyBranches.values) {
branch.policies.removeAll { it.matchesFilter(policyToRemove) }
}
}
quests.putAll(ruleset.quests)
religions.addAll(ruleset.religions)
ruinRewards.putAll(ruleset.ruinRewards)

View File

@ -174,6 +174,7 @@ The file can have the following attributes, not including the values Unciv sets
| unitsToRemove | List | empty | List of [Units](4-Unit-related-JSON-files.md#unitsjson) or [unitFilter](../../Unique-parameters#baseunitfilter) to remove (isBaseRuleset=false only) |
| nationsToRemove | List | empty | List of [Nations](2-Civilization-related-JSON-files.md#nationsjson) or [nationFilter](../../Unique-parameters#nationfilter) to remove (isBaseRuleset=false only) |
| policyBranchesToRemove | List | empty | List of [Policy Branches](2-Civilization-related-JSON-files.md#policyjson) to remove (isBaseRuleset=false only) |
| policiesToRemove | List | empty | List of [Policies](2-Civilization-related-JSON-files.md#policiesjson) to remove (isBaseRuleset=false only) |
| constants | Object | empty | See [ModConstants](#modconstants) |
| tileset | String | empty | Only applicable for base rulesets |
| unitset | String | empty | Only applicable for base rulesets |