mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 05:46:43 -04:00
Added percentage bonuses to city stats drilldown
Fixed happiness drilldown display in city screen
This commit is contained in:
parent
973c1693c8
commit
80dd4c759b
@ -21,8 +21,8 @@ android {
|
|||||||
applicationId "com.unciv.app"
|
applicationId "com.unciv.app"
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode 205
|
versionCode 206
|
||||||
versionName "2.13.5"
|
versionName "2.13.6"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Had to add this crap for Travis to build, it wanted to sign the app
|
// Had to add this crap for Travis to build, it wanted to sign the app
|
||||||
|
@ -163,7 +163,7 @@ class CityStats {
|
|||||||
if (civInfo.policies.isAdopted("Meritocracy"))
|
if (civInfo.policies.isAdopted("Meritocracy"))
|
||||||
unhappinessFromCitizens *= 0.95f
|
unhappinessFromCitizens *= 0.95f
|
||||||
|
|
||||||
newHappinessList ["Population"] = -unhappinessFromCitizens * unhappinessModifier
|
newHappinessList["Population"] = -unhappinessFromCitizens * unhappinessModifier
|
||||||
|
|
||||||
var happinessFromPolicies = 0f
|
var happinessFromPolicies = 0f
|
||||||
if (civInfo.policies.isAdopted("Aristocracy"))
|
if (civInfo.policies.isAdopted("Aristocracy"))
|
||||||
@ -318,7 +318,6 @@ class CityStats {
|
|||||||
val newStatPercentBonusList = LinkedHashMap<String,Stats>()
|
val newStatPercentBonusList = LinkedHashMap<String,Stats>()
|
||||||
newStatPercentBonusList["Golden Age"]=getStatPercentBonusesFromGoldenAge(cityInfo.civInfo.goldenAges.isGoldenAge())
|
newStatPercentBonusList["Golden Age"]=getStatPercentBonusesFromGoldenAge(cityInfo.civInfo.goldenAges.isGoldenAge())
|
||||||
newStatPercentBonusList["Policies"]=getStatPercentBonusesFromPolicies(civInfo.policies.adoptedPolicies, cityInfo.cityConstructions)
|
newStatPercentBonusList["Policies"]=getStatPercentBonusesFromPolicies(civInfo.policies.adoptedPolicies, cityInfo.cityConstructions)
|
||||||
// from wonders - Culture in all cities increased by 25%
|
|
||||||
newStatPercentBonusList["Buildings"]=getStatPercentBonusesFromBuildings()
|
newStatPercentBonusList["Buildings"]=getStatPercentBonusesFromBuildings()
|
||||||
newStatPercentBonusList["Railroad"]=getStatPercentBonusesFromRailroad()
|
newStatPercentBonusList["Railroad"]=getStatPercentBonusesFromRailroad()
|
||||||
newStatPercentBonusList["Marble"]=getStatPercentBonusesFromMarble()
|
newStatPercentBonusList["Marble"]=getStatPercentBonusesFromMarble()
|
||||||
|
@ -12,7 +12,6 @@ import com.unciv.models.stats.Stats
|
|||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.collections.HashMap
|
|
||||||
|
|
||||||
|
|
||||||
class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseScreen.skin) {
|
class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseScreen.skin) {
|
||||||
@ -28,26 +27,12 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS
|
|||||||
|
|
||||||
addStatInfo()
|
addStatInfo()
|
||||||
|
|
||||||
val greatPersonPoints = cityInfo.getGreatPersonMap()
|
addGreatPersonPointInfo(cityInfo)
|
||||||
val statToGreatPerson = GreatPersonManager().statToGreatPersonMapping
|
|
||||||
for(stat in Stat.values()){
|
|
||||||
if(!statToGreatPerson.containsKey(stat)) continue
|
|
||||||
val expanderName = "["+statToGreatPerson[stat]!!+"] points"
|
|
||||||
val expanderTab = ExpanderTab(expanderName.tr(),skin)
|
|
||||||
expanderTab.innerTable.defaults().pad(3f)
|
|
||||||
for(entry in greatPersonPoints){
|
|
||||||
val value = entry.value.toHashMap()[stat]!!
|
|
||||||
if(value==0f) continue
|
|
||||||
expanderTab.innerTable.add(entry.key.toLabel())
|
|
||||||
expanderTab.innerTable.add(DecimalFormat("0.#").format(value).toLabel()).row()
|
|
||||||
}
|
|
||||||
if(expanderTab.innerTable.hasChildren())
|
|
||||||
add(expanderTab).row()
|
|
||||||
}
|
|
||||||
|
|
||||||
pack()
|
pack()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun addBuildingInfo(cityInfo: CityInfo) {
|
private fun addBuildingInfo(cityInfo: CityInfo) {
|
||||||
val wonders = mutableListOf<Building>()
|
val wonders = mutableListOf<Building>()
|
||||||
val specialistBuildings = mutableListOf<Building>()
|
val specialistBuildings = mutableListOf<Building>()
|
||||||
@ -102,35 +87,57 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS
|
|||||||
private fun addStatInfo() {
|
private fun addStatInfo() {
|
||||||
val cityStats = cityScreen.city.cityStats
|
val cityStats = cityScreen.city.cityStats
|
||||||
val unifiedStatList = LinkedHashMap<String, Stats>(cityStats.baseStatList)
|
val unifiedStatList = LinkedHashMap<String, Stats>(cityStats.baseStatList)
|
||||||
for(entry in cityStats.happinessList.filter { it.value!=0f }){
|
|
||||||
if(!unifiedStatList.containsKey(entry.key)) unifiedStatList[entry.key]= Stats()
|
for(stats in unifiedStatList.values) stats.happiness=0f
|
||||||
|
|
||||||
|
|
||||||
|
// add happiness to stat list
|
||||||
|
for(entry in cityStats.getCityHappiness().filter { it.value!=0f }){
|
||||||
|
if(!unifiedStatList.containsKey(entry.key))
|
||||||
|
unifiedStatList[entry.key]= Stats()
|
||||||
unifiedStatList[entry.key]!!.happiness=entry.value
|
unifiedStatList[entry.key]!!.happiness=entry.value
|
||||||
}
|
}
|
||||||
|
|
||||||
val statToCauses = HashMap<Stat,HashMap<String,Float>>()
|
for(stat in Stat.values()){
|
||||||
for(stat in Stat.values()) statToCauses[stat] = hashMapOf()
|
val expander = ExpanderTab(stat.name.tr(),skin)
|
||||||
|
|
||||||
for(cause in unifiedStatList) {
|
|
||||||
val statHashmap = cause.value.toHashMap()
|
|
||||||
for (statEntry in statHashmap.filter { it.value != 0f })
|
|
||||||
statToCauses[statEntry.key]!![cause.key] = statEntry.value
|
|
||||||
}
|
|
||||||
|
|
||||||
for(stat in statToCauses){
|
|
||||||
val expander = ExpanderTab(stat.key.name.tr(),skin)
|
|
||||||
expander.innerTable.defaults().pad(2f)
|
expander.innerTable.defaults().pad(2f)
|
||||||
|
|
||||||
for(entry in stat.value) {
|
for(entry in unifiedStatList) {
|
||||||
|
val specificStatValue = entry.value.toHashMap()[stat]!!
|
||||||
|
if(specificStatValue==0f) continue
|
||||||
expander.innerTable.add(entry.key.toLabel())
|
expander.innerTable.add(entry.key.toLabel())
|
||||||
expander.innerTable.add(DecimalFormat("0.#").format(entry.value).toLabel()).row()
|
expander.innerTable.add(DecimalFormat("0.#").format(specificStatValue).toLabel()).row()
|
||||||
}
|
}
|
||||||
if(stat.value.isNotEmpty()){
|
for(entry in cityStats.statPercentBonusList){
|
||||||
expander.innerTable.add("Total".toLabel())
|
val specificStatValue = entry.value.toHashMap()[stat]!!
|
||||||
expander.innerTable.add(DecimalFormat("0.#").format(stat.value.values.sum()).toLabel())
|
if(specificStatValue==0f) continue
|
||||||
add(expander).row()
|
expander.innerTable.add(entry.key.toLabel())
|
||||||
|
val decimal = DecimalFormat("0.#").format(specificStatValue)
|
||||||
|
expander.innerTable.add("+$decimal%".toLabel()).row()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
if(expander.innerTable.hasChildren())
|
||||||
|
add(expander).row()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun addGreatPersonPointInfo(cityInfo: CityInfo) {
|
||||||
|
val greatPersonPoints = cityInfo.getGreatPersonMap()
|
||||||
|
val statToGreatPerson = GreatPersonManager().statToGreatPersonMapping
|
||||||
|
for (stat in Stat.values()) {
|
||||||
|
if (!statToGreatPerson.containsKey(stat)) continue
|
||||||
|
val expanderName = "[" + statToGreatPerson[stat]!! + "] points"
|
||||||
|
val expanderTab = ExpanderTab(expanderName.tr(), skin)
|
||||||
|
expanderTab.innerTable.defaults().pad(3f)
|
||||||
|
for (entry in greatPersonPoints) {
|
||||||
|
val value = entry.value.toHashMap()[stat]!!
|
||||||
|
if (value == 0f) continue
|
||||||
|
expanderTab.innerTable.add(entry.key.toLabel())
|
||||||
|
expanderTab.innerTable.add(DecimalFormat("0.#").format(value).toLabel()).row()
|
||||||
|
}
|
||||||
|
if (expanderTab.innerTable.hasChildren())
|
||||||
|
add(expanderTab).row()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addSpecialistAllocation(skin: Skin, cityInfo: CityInfo) {
|
private fun addSpecialistAllocation(skin: Skin, cityInfo: CityInfo) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user