mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-15 10:18:26 +07:00
Fix policy uniques not being applied (#7404)
This commit is contained in:

committed by
GitHub

parent
43da7ee3cd
commit
aab49e7295
@ -810,6 +810,7 @@ class CivilizationInfo : IsPartOfGameInfoSerialization {
|
||||
policies.civInfo = this
|
||||
if (policies.adoptedPolicies.size > 0 && policies.numberOfAdoptedPolicies == 0)
|
||||
policies.numberOfAdoptedPolicies = policies.adoptedPolicies.count { !Policy.isBranchCompleteByName(it) }
|
||||
policies.setTransients()
|
||||
|
||||
questManager.civInfo = this
|
||||
questManager.setTransients()
|
||||
|
@ -78,11 +78,6 @@ class PolicyManager : IsPartOfGameInfoSerialization {
|
||||
private val branches: Set<PolicyBranch>
|
||||
get() = civInfo.gameInfo.ruleSet.policyBranches.values.toSet()
|
||||
|
||||
// Only instantiate a single value for all policy managers
|
||||
companion object {
|
||||
private val turnCountRegex by lazy { Regex("for \\[[0-9]*\\] turns") }
|
||||
}
|
||||
|
||||
fun clone(): PolicyManager {
|
||||
val toReturn = PolicyManager()
|
||||
toReturn.numberOfAdoptedPolicies = numberOfAdoptedPolicies
|
||||
@ -98,6 +93,18 @@ class PolicyManager : IsPartOfGameInfoSerialization {
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
fun getPolicyByName(name: String): Policy = getRulesetPolicies()[name]!!
|
||||
|
||||
fun setTransients() {
|
||||
for (policyName in adoptedPolicies) addPolicyToTransients(
|
||||
getPolicyByName(policyName)
|
||||
)
|
||||
}
|
||||
|
||||
private fun addPolicyToTransients(policy: Policy) {
|
||||
for (unique in policy.uniqueObjects) {
|
||||
policyUniques.addUnique(unique)
|
||||
}
|
||||
}
|
||||
|
||||
fun addCulture(culture: Int) {
|
||||
val couldAdoptPolicyBefore = canAdoptPolicy()
|
||||
storedCulture += culture
|
||||
@ -177,6 +184,7 @@ class PolicyManager : IsPartOfGameInfoSerialization {
|
||||
}
|
||||
|
||||
adoptedPolicies.add(policy.name)
|
||||
addPolicyToTransients(policy)
|
||||
|
||||
if (!branchCompletion) {
|
||||
val branch = policy.branch
|
||||
|
Reference in New Issue
Block a user