From 2028c0569b827a89478c97c09d76c2d82485b771 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 24 Aug 2023 10:53:01 +0300 Subject: [PATCH] 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! --- .../com/unciv/logic/civilization/managers/PolicyManager.kt | 5 ++++- .../unciv/ui/screens/worldscreen/status/NextTurnAction.kt | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/com/unciv/logic/civilization/managers/PolicyManager.kt b/core/src/com/unciv/logic/civilization/managers/PolicyManager.kt index caee82dcb5..c813934228 100644 --- a/core/src/com/unciv/logic/civilization/managers/PolicyManager.kt +++ b/core/src/com/unciv/logic/civilization/managers/PolicyManager.kt @@ -30,8 +30,11 @@ class PolicyManager : IsPartOfGameInfoSerialization { var storedCulture = 0 internal val adoptedPolicies = HashSet() 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 diff --git a/core/src/com/unciv/ui/screens/worldscreen/status/NextTurnAction.kt b/core/src/com/unciv/ui/screens/worldscreen/status/NextTurnAction.kt index a3683671ef..93283b54d0 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/status/NextTurnAction.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/status/NextTurnAction.kt @@ -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