Fixed errors when cloning civ that should open policy picker

We should not be using get() functions for serializable fields that we want to clone!
This commit is contained in:
Yair Morgenstern 2023-08-24 10:53:01 +03:00
parent 5bcfcb3e8c
commit 2028c0569b
2 changed files with 7 additions and 3 deletions

View File

@ -30,8 +30,11 @@ class PolicyManager : IsPartOfGameInfoSerialization {
var storedCulture = 0
internal val adoptedPolicies = HashSet<String>()
var numberOfAdoptedPolicies = 0
/** Indicates whether we shoudl *check* if policy is adoptible, and if so open */
var shouldOpenPolicyPicker = false
get() = field && canAdoptPolicy()
fun shouldOpenPolicyPicker() = shouldOpenPolicyPicker && canAdoptPolicy()
/** A [Map] pairing each [PolicyBranch] to its priority ([Int]). */
val priorityMap: Map<PolicyBranch, Int>

View File

@ -54,8 +54,9 @@ enum class NextTurnAction(protected val text: String, val color: Color) {
},
PickPolicy("Pick a policy", Color.VIOLET) {
override fun isChoice(worldScreen: WorldScreen) =
worldScreen.viewingCiv.policies.shouldOpenPolicyPicker ||
worldScreen.viewingCiv.policies.freePolicies > 0 && worldScreen.viewingCiv.policies.canAdoptPolicy()
(worldScreen.viewingCiv.policies.shouldOpenPolicyPicker ||
worldScreen.viewingCiv.policies.freePolicies > 0)
&& worldScreen.viewingCiv.policies.canAdoptPolicy()
override fun action(worldScreen: WorldScreen) {
worldScreen.game.pushScreen(PolicyPickerScreen(worldScreen.selectedCiv, worldScreen.canChangeState))
worldScreen.viewingCiv.policies.shouldOpenPolicyPicker = false