mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-18 19:59:47 +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
|
policies.civInfo = this
|
||||||
if (policies.adoptedPolicies.size > 0 && policies.numberOfAdoptedPolicies == 0)
|
if (policies.adoptedPolicies.size > 0 && policies.numberOfAdoptedPolicies == 0)
|
||||||
policies.numberOfAdoptedPolicies = policies.adoptedPolicies.count { !Policy.isBranchCompleteByName(it) }
|
policies.numberOfAdoptedPolicies = policies.adoptedPolicies.count { !Policy.isBranchCompleteByName(it) }
|
||||||
|
policies.setTransients()
|
||||||
|
|
||||||
questManager.civInfo = this
|
questManager.civInfo = this
|
||||||
questManager.setTransients()
|
questManager.setTransients()
|
||||||
|
@ -78,11 +78,6 @@ class PolicyManager : IsPartOfGameInfoSerialization {
|
|||||||
private val branches: Set<PolicyBranch>
|
private val branches: Set<PolicyBranch>
|
||||||
get() = civInfo.gameInfo.ruleSet.policyBranches.values.toSet()
|
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 {
|
fun clone(): PolicyManager {
|
||||||
val toReturn = PolicyManager()
|
val toReturn = PolicyManager()
|
||||||
toReturn.numberOfAdoptedPolicies = numberOfAdoptedPolicies
|
toReturn.numberOfAdoptedPolicies = numberOfAdoptedPolicies
|
||||||
@ -98,6 +93,18 @@ class PolicyManager : IsPartOfGameInfoSerialization {
|
|||||||
@Suppress("MemberVisibilityCanBePrivate")
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
fun getPolicyByName(name: String): Policy = getRulesetPolicies()[name]!!
|
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) {
|
fun addCulture(culture: Int) {
|
||||||
val couldAdoptPolicyBefore = canAdoptPolicy()
|
val couldAdoptPolicyBefore = canAdoptPolicy()
|
||||||
storedCulture += culture
|
storedCulture += culture
|
||||||
@ -177,6 +184,7 @@ class PolicyManager : IsPartOfGameInfoSerialization {
|
|||||||
}
|
}
|
||||||
|
|
||||||
adoptedPolicies.add(policy.name)
|
adoptedPolicies.add(policy.name)
|
||||||
|
addPolicyToTransients(policy)
|
||||||
|
|
||||||
if (!branchCompletion) {
|
if (!branchCompletion) {
|
||||||
val branch = policy.branch
|
val branch = policy.branch
|
||||||
|
Reference in New Issue
Block a user