diff --git a/android/build.gradle b/android/build.gradle index 80329e1c..e88caa2f 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -21,8 +21,8 @@ android { applicationId "com.unciv.game" minSdkVersion 14 targetSdkVersion 26 - versionCode 43 - versionName "2.0.0" + versionCode 44 + versionName "2.0.1" } buildTypes { release { diff --git a/core/src/com/unciv/logic/city/CityStats.kt b/core/src/com/unciv/logic/city/CityStats.kt index d9c6c9f3..c3636936 100644 --- a/core/src/com/unciv/logic/city/CityStats.kt +++ b/core/src/com/unciv/logic/city/CityStats.kt @@ -120,7 +120,7 @@ class CityStats { private val isCapital: Boolean get() = cityInfo.civInfo.capital === cityInfo - private fun getStatsFromSpecialists(specialists: Stats, policies: List): Stats { + private fun getStatsFromSpecialists(specialists: Stats, policies: HashSet): Stats { val stats = Stats() // Specialists @@ -135,7 +135,7 @@ class CityStats { return stats } - private fun getStatsFromPolicies(adoptedPolicies: List): Stats { + private fun getStatsFromPolicies(adoptedPolicies: HashSet): Stats { val stats = Stats() if (adoptedPolicies.contains("Tradition") && isCapital) stats.culture += 3f @@ -163,7 +163,7 @@ class CityStats { return stats } - private fun getStatPercentBonusesFromPolicies(policies: List, cityConstructions: CityConstructions): Stats { + private fun getStatPercentBonusesFromPolicies(policies: HashSet, cityConstructions: CityConstructions): Stats { val stats = Stats() if (policies.contains("Collective Rule") && isCapital diff --git a/core/src/com/unciv/logic/city/IConstruction.kt b/core/src/com/unciv/logic/city/IConstruction.kt index 733acb08..2f3f6896 100644 --- a/core/src/com/unciv/logic/city/IConstruction.kt +++ b/core/src/com/unciv/logic/city/IConstruction.kt @@ -3,8 +3,8 @@ package com.unciv.logic.city import com.unciv.models.stats.INamed interface IConstruction : INamed { - fun getProductionCost(adoptedPolicies: List): Int - fun getGoldCost(adoptedPolicies: List): Int + fun getProductionCost(adoptedPolicies: HashSet): Int + fun getGoldCost(adoptedPolicies: HashSet): Int fun isBuildable(construction: CityConstructions): Boolean fun postBuildEvent(construction: CityConstructions) // Yes I'm hilarious. } diff --git a/core/src/com/unciv/logic/civilization/PolicyManager.kt b/core/src/com/unciv/logic/civilization/PolicyManager.kt index a967869a..7dd2a4c3 100644 --- a/core/src/com/unciv/logic/civilization/PolicyManager.kt +++ b/core/src/com/unciv/logic/civilization/PolicyManager.kt @@ -1,8 +1,8 @@ package com.unciv.logic.civilization +import com.unciv.UnCivGame import com.unciv.models.gamebasics.GameBasics import com.unciv.models.gamebasics.Policy -import com.unciv.UnCivGame import com.unciv.ui.pickerscreens.GreatPersonPickerScreen @@ -13,7 +13,7 @@ class PolicyManager { var freePolicies = 0 var storedCulture = 0 - internal val adoptedPolicies = ArrayList() + internal val adoptedPolicies = HashSet() var shouldOpenPolicyPicker = false // from https://forums.civfanatics.com/threads/the-number-crunching-thread.389702/ @@ -30,7 +30,7 @@ class PolicyManager { } - fun getAdoptedPolicies(): List = adoptedPolicies + fun getAdoptedPolicies(): HashSet = adoptedPolicies fun isAdopted(policyName: String): Boolean = adoptedPolicies.contains(policyName) diff --git a/core/src/com/unciv/models/gamebasics/BasicHelp.kt b/core/src/com/unciv/models/gamebasics/BasicHelp.kt index db96e51d..72dcc218 100644 --- a/core/src/com/unciv/models/gamebasics/BasicHelp.kt +++ b/core/src/com/unciv/models/gamebasics/BasicHelp.kt @@ -5,4 +5,5 @@ import com.unciv.models.stats.INamed class BasicHelp : ICivilopedia, INamed { override lateinit var name: String override val description: String = "" + override fun toString() = name } diff --git a/core/src/com/unciv/models/gamebasics/Building.kt b/core/src/com/unciv/models/gamebasics/Building.kt index eefdaac6..879d1260 100644 --- a/core/src/com/unciv/models/gamebasics/Building.kt +++ b/core/src/com/unciv/models/gamebasics/Building.kt @@ -12,7 +12,7 @@ import com.unciv.ui.pickerscreens.PolicyPickerScreen class Building : NamedStats(), IConstruction, ICivilopedia { private lateinit var baseDescription: String override val description: String - get() = getDescription(false, listOf()) + get() = getDescription(false, hashSetOf()) var requiredTech: String? = null @@ -45,18 +45,18 @@ class Building : NamedStats(), IConstruction, ICivilopedia { fun getRequiredTech(): Technology = GameBasics.Technologies[requiredTech]!! - fun getStats(adoptedPolicies: List): Stats { + fun getStats(adoptedPolicies: HashSet): Stats { val stats = this.clone() - if (adoptedPolicies.contains("Organized Religion") && listOf("Monument", "Temple", "Monastery").contains(name)) + if (adoptedPolicies.contains("Organized Religion") && hashSetOf("Monument", "Temple", "Monastery").contains(name)) stats.happiness += 1 - if (adoptedPolicies.contains("Free Religion") && listOf("Monument", "Temple", "Monastery").contains(name)) + if (adoptedPolicies.contains("Free Religion") && hashSetOf("Monument", "Temple", "Monastery").contains(name)) stats.culture += 1f - if (adoptedPolicies.contains("Entrepreneurship") && listOf("Mint", "Market", "Bank", "Stock Market").contains(name)) + if (adoptedPolicies.contains("Entrepreneurship") && hashSetOf("Mint", "Market", "Bank", "Stock Market").contains(name)) stats.science += 1f - if (adoptedPolicies.contains("Humanism") && listOf("University", "Observatory", "Public School").contains(name)) + if (adoptedPolicies.contains("Humanism") && hashSetOf("University", "Observatory", "Public School").contains(name)) stats.science += 1f if (adoptedPolicies.contains("Theocracy") && name == "Temple") @@ -79,7 +79,7 @@ class Building : NamedStats(), IConstruction, ICivilopedia { } - fun getDescription(forBuildingPickerScreen: Boolean, adoptedPolicies: List): String { + fun getDescription(forBuildingPickerScreen: Boolean, adoptedPolicies: HashSet): String { val stats = getStats(adoptedPolicies) val stringBuilder = StringBuilder() if (!forBuildingPickerScreen) stringBuilder.appendln("Cost: $cost") @@ -118,12 +118,12 @@ class Building : NamedStats(), IConstruction, ICivilopedia { return stringBuilder.toString() } - override fun getProductionCost(adoptedPolicies: List): Int { + override fun getProductionCost(adoptedPolicies: HashSet): Int { return if (!isWonder && culture != 0f && adoptedPolicies.contains("Piety")) (cost * 0.85).toInt() else cost } - override fun getGoldCost(adoptedPolicies: List): Int { + override fun getGoldCost(adoptedPolicies: HashSet): Int { var cost = Math.pow((30 * getProductionCost(adoptedPolicies)).toDouble(), 0.75) * (1 + hurryCostModifier / 100) if (adoptedPolicies.contains("Mercantilism")) cost *= 0.75 if (adoptedPolicies.contains("Patronage")) cost *= 0.5 diff --git a/core/src/com/unciv/models/gamebasics/Unit.kt b/core/src/com/unciv/models/gamebasics/Unit.kt index de0abf4a..972d18ba 100644 --- a/core/src/com/unciv/models/gamebasics/Unit.kt +++ b/core/src/com/unciv/models/gamebasics/Unit.kt @@ -27,11 +27,11 @@ class Unit : INamed, IConstruction { } - override fun getProductionCost(adoptedPolicies: List): Int { + override fun getProductionCost(adoptedPolicies: HashSet): Int { return cost } - override fun getGoldCost(adoptedPolicies: List): Int { + override fun getGoldCost(adoptedPolicies: HashSet): Int { return (Math.pow((30 * cost).toDouble(), 0.75) * (1 + hurryCostModifier / 100) / 10).toInt() * 10 } diff --git a/core/src/com/unciv/ui/pickerscreens/PolicyPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/PolicyPickerScreen.kt index c5682d0b..125cd955 100644 --- a/core/src/com/unciv/ui/pickerscreens/PolicyPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/PolicyPickerScreen.kt @@ -100,10 +100,11 @@ class PolicyPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen( if (civInfo.policies.isAdopted(policy.name)) { // existing toReturn.color = Color.GREEN - } else if (!civInfo.policies.getAdoptedPolicies().containsAll(policy.requires!!)) + } else if (!civInfo.policies. + getAdoptedPolicies().containsAll(policy.requires!!)) // non-available { - toReturn.color = Color.GRAY + toReturn.disable() } toReturn.addClickListener { pickPolicy(policy) } toReturn.pack() diff --git a/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt b/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt index 1737d7af..7cf11478 100644 --- a/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt +++ b/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt @@ -8,14 +8,11 @@ import com.badlogic.gdx.graphics.g2d.Batch import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.scenes.scene2d.Stage import com.badlogic.gdx.scenes.scene2d.Touchable -import com.badlogic.gdx.scenes.scene2d.ui.Label -import com.badlogic.gdx.scenes.scene2d.ui.Skin -import com.badlogic.gdx.scenes.scene2d.ui.Table -import com.badlogic.gdx.scenes.scene2d.ui.TextButton +import com.badlogic.gdx.scenes.scene2d.ui.* import com.badlogic.gdx.utils.Align import com.badlogic.gdx.utils.viewport.ExtendViewport -import com.unciv.models.gamebasics.GameBasics import com.unciv.UnCivGame +import com.unciv.models.gamebasics.GameBasics import com.unciv.ui.cityscreen.addClickListener open class CameraStageBaseScreen : Screen { @@ -97,11 +94,11 @@ open class CameraStageBaseScreen : Screen { } -fun TextButton.disable(){ +fun Button.disable(){ touchable= Touchable.disabled color= Color.GRAY } -fun TextButton.enable() { +fun Button.enable() { color = Color.WHITE touchable = Touchable.enabled }