mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-07 14:02:48 +07:00
Civilopedia help now shows correct text
Sped up pollicy-related actions
This commit is contained in:
parent
8268c0c561
commit
8d2edfefc7
@ -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 {
|
||||
|
@ -120,7 +120,7 @@ class CityStats {
|
||||
private val isCapital: Boolean
|
||||
get() = cityInfo.civInfo.capital === cityInfo
|
||||
|
||||
private fun getStatsFromSpecialists(specialists: Stats, policies: List<String>): Stats {
|
||||
private fun getStatsFromSpecialists(specialists: Stats, policies: HashSet<String>): Stats {
|
||||
val stats = Stats()
|
||||
|
||||
// Specialists
|
||||
@ -135,7 +135,7 @@ class CityStats {
|
||||
return stats
|
||||
}
|
||||
|
||||
private fun getStatsFromPolicies(adoptedPolicies: List<String>): Stats {
|
||||
private fun getStatsFromPolicies(adoptedPolicies: HashSet<String>): 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<String>, cityConstructions: CityConstructions): Stats {
|
||||
private fun getStatPercentBonusesFromPolicies(policies: HashSet<String>, cityConstructions: CityConstructions): Stats {
|
||||
val stats = Stats()
|
||||
|
||||
if (policies.contains("Collective Rule") && isCapital
|
||||
|
@ -3,8 +3,8 @@ package com.unciv.logic.city
|
||||
import com.unciv.models.stats.INamed
|
||||
|
||||
interface IConstruction : INamed {
|
||||
fun getProductionCost(adoptedPolicies: List<String>): Int
|
||||
fun getGoldCost(adoptedPolicies: List<String>): Int
|
||||
fun getProductionCost(adoptedPolicies: HashSet<String>): Int
|
||||
fun getGoldCost(adoptedPolicies: HashSet<String>): Int
|
||||
fun isBuildable(construction: CityConstructions): Boolean
|
||||
fun postBuildEvent(construction: CityConstructions) // Yes I'm hilarious.
|
||||
}
|
||||
|
@ -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<String>()
|
||||
internal val adoptedPolicies = HashSet<String>()
|
||||
var shouldOpenPolicyPicker = false
|
||||
|
||||
// from https://forums.civfanatics.com/threads/the-number-crunching-thread.389702/
|
||||
@ -30,7 +30,7 @@ class PolicyManager {
|
||||
}
|
||||
|
||||
|
||||
fun getAdoptedPolicies(): List<String> = adoptedPolicies
|
||||
fun getAdoptedPolicies(): HashSet<String> = adoptedPolicies
|
||||
|
||||
fun isAdopted(policyName: String): Boolean = adoptedPolicies.contains(policyName)
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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<String>): Stats {
|
||||
fun getStats(adoptedPolicies: HashSet<String>): 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>): String {
|
||||
fun getDescription(forBuildingPickerScreen: Boolean, adoptedPolicies: HashSet<String>): 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<String>): Int {
|
||||
override fun getProductionCost(adoptedPolicies: HashSet<String>): Int {
|
||||
return if (!isWonder && culture != 0f && adoptedPolicies.contains("Piety")) (cost * 0.85).toInt()
|
||||
else cost
|
||||
}
|
||||
|
||||
override fun getGoldCost(adoptedPolicies: List<String>): Int {
|
||||
override fun getGoldCost(adoptedPolicies: HashSet<String>): 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
|
||||
|
@ -27,11 +27,11 @@ class Unit : INamed, IConstruction {
|
||||
}
|
||||
|
||||
|
||||
override fun getProductionCost(adoptedPolicies: List<String>): Int {
|
||||
override fun getProductionCost(adoptedPolicies: HashSet<String>): Int {
|
||||
return cost
|
||||
}
|
||||
|
||||
override fun getGoldCost(adoptedPolicies: List<String>): Int {
|
||||
override fun getGoldCost(adoptedPolicies: HashSet<String>): Int {
|
||||
return (Math.pow((30 * cost).toDouble(), 0.75) * (1 + hurryCostModifier / 100) / 10).toInt() * 10
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user