Skip to content

Commit c94046c

Browse files
committed
Resolved #14533 - Policies from overridden policy branches no longer "stick around" to affect the UI
1 parent cd22db3 commit c94046c

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

core/src/com/unciv/models/ruleset/Ruleset.kt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,28 @@ class Ruleset {
213213
nations.remove(it)
214214
}
215215
nations.putAll(ruleset.nations)
216+
217+
/** We must remove all policies from a policy branch otherwise we have policies that cannot be picked
218+
* but are still considered "available" */
219+
fun removePolicyBranch(policyBranch: PolicyBranch){
220+
policyBranches.remove(policyBranch.name)
221+
for (policy in policyBranch.policies)
222+
policies.remove(policy.name)
223+
}
224+
216225
ruleset.modOptions.policyBranchesToRemove
217226
.flatMap { policyBranchToRemove ->
218-
policyBranches.filter { it.value.matchesFilter(policyBranchToRemove) }.keys
227+
policyBranches.filter { it.value.matchesFilter(policyBranchToRemove) }.values
219228
}.toSet().forEach {
220-
policyBranches.remove(it)
229+
removePolicyBranch(it)
221230
}
231+
232+
val overriddenPolicyBranches = policyBranches
233+
.filter { it.key in ruleset.policyBranches }.map { it.value }
234+
for (policyBranch in overriddenPolicyBranches) removePolicyBranch(policyBranch
235+
)
222236
policyBranches.putAll(ruleset.policyBranches)
237+
223238
policies.putAll(ruleset.policies)
224239

225240
// Remove the policies

0 commit comments

Comments
 (0)