From 066c698117c15a2cc22282656b95585972c266c4 Mon Sep 17 00:00:00 2001 From: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com> Date: Thu, 24 Aug 2023 23:10:40 +0200 Subject: [PATCH] Linting of unused new function shouldOpenPolicyPicker() (#9969) --- core/src/com/unciv/logic/city/managers/CityFounder.kt | 2 +- .../com/unciv/logic/civilization/managers/PolicyManager.kt | 5 +++-- .../unciv/ui/screens/worldscreen/status/NextTurnAction.kt | 4 +--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/core/src/com/unciv/logic/city/managers/CityFounder.kt b/core/src/com/unciv/logic/city/managers/CityFounder.kt index e21219b086..1ecf657c20 100644 --- a/core/src/com/unciv/logic/city/managers/CityFounder.kt +++ b/core/src/com/unciv/logic/city/managers/CityFounder.kt @@ -29,7 +29,7 @@ class CityFounder { city.isOriginalCapital = civInfo.citiesCreated == 0 if (city.isOriginalCapital) { civInfo.hasEverOwnedOriginalCapital = true - // if you have some culture before the 1st city is found, you may want to adopt the 1st policy + // if you have some culture before the 1st city is founded, you may want to adopt the 1st policy civInfo.policies.shouldOpenPolicyPicker = true } civInfo.citiesCreated++ diff --git a/core/src/com/unciv/logic/civilization/managers/PolicyManager.kt b/core/src/com/unciv/logic/civilization/managers/PolicyManager.kt index c813934228..11da858117 100644 --- a/core/src/com/unciv/logic/civilization/managers/PolicyManager.kt +++ b/core/src/com/unciv/logic/civilization/managers/PolicyManager.kt @@ -31,10 +31,11 @@ class PolicyManager : IsPartOfGameInfoSerialization { internal val adoptedPolicies = HashSet() var numberOfAdoptedPolicies = 0 - /** Indicates whether we shoudl *check* if policy is adoptible, and if so open */ + /** Indicates whether we should *check* if policy is adoptible, and if so open */ var shouldOpenPolicyPicker = false - fun shouldOpenPolicyPicker() = shouldOpenPolicyPicker && canAdoptPolicy() + /** Used by NextTurnAction.PickPolicy.isChoice */ + fun shouldShowPolicyPicker() = (shouldOpenPolicyPicker || freePolicies > 0) && 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 93283b54d0..d28fdefd06 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/status/NextTurnAction.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/status/NextTurnAction.kt @@ -54,9 +54,7 @@ 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.shouldShowPolicyPicker() override fun action(worldScreen: WorldScreen) { worldScreen.game.pushScreen(PolicyPickerScreen(worldScreen.selectedCiv, worldScreen.canChangeState)) worldScreen.viewingCiv.policies.shouldOpenPolicyPicker = false