mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 06:16:37 -04:00
Resolved #455 - add great person point breakdown to city info
This commit is contained in:
parent
0cd5426440
commit
356f8b6bbd
@ -795,6 +795,10 @@
|
||||
Italian:"La resistenza dura per altri [numberOfTurns] turni"
|
||||
}
|
||||
|
||||
"[greatPerson] points":{ // e.g "Great Scientist points"
|
||||
|
||||
}
|
||||
|
||||
// Tech picker
|
||||
"Pick a tech":{
|
||||
Italian:"Scegli una tecnologia"
|
||||
|
@ -134,24 +134,38 @@ class CityInfo {
|
||||
|
||||
fun getBuildingUniques(): List<String> = cityConstructions.getBuiltBuildings().flatMap { it.uniques }
|
||||
|
||||
fun getGreatPersonPoints(): Stats {
|
||||
var greatPersonPoints = population.specialists.times(3f)
|
||||
fun getGreatPersonMap():HashMap<String,Stats>{
|
||||
val stats = HashMap<String,Stats>()
|
||||
if(population.specialists.toString()!="")
|
||||
stats["Specialists"] = population.specialists.times(3f)
|
||||
|
||||
val buildingStats = Stats()
|
||||
for (building in cityConstructions.getBuiltBuildings())
|
||||
if (building.greatPersonPoints != null)
|
||||
greatPersonPoints.add(building.greatPersonPoints!!)
|
||||
buildingStats.add(building.greatPersonPoints!!)
|
||||
if(buildingStats.toString()!="")
|
||||
stats["Buildings"] = buildingStats
|
||||
|
||||
for(entry in stats){
|
||||
if(civInfo.getNation().unique=="Receive free Great Scientist when you discover Writing, Earn Great Scientists 50% faster")
|
||||
entry.value.science *= 1.5f
|
||||
if (civInfo.policies.isAdopted("Entrepreneurship"))
|
||||
entry.value.gold *= 1.25f
|
||||
|
||||
if (civInfo.getBuildingUniques().contains("+33% great person generation in all cities"))
|
||||
greatPersonPoints = greatPersonPoints.times(1.33f)
|
||||
if (civInfo.policies.isAdopted("Entrepreneurship"))
|
||||
greatPersonPoints.gold *= 1.25f
|
||||
stats[entry.key] = stats[entry.key]!!.times(1.33f)
|
||||
if (civInfo.policies.isAdopted("Freedom"))
|
||||
greatPersonPoints = greatPersonPoints.times(1.25f)
|
||||
stats[entry.key] = stats[entry.key]!!.times(1.25f)
|
||||
}
|
||||
|
||||
if(civInfo.getNation().unique=="Receive free Great Scientist when you discover Writing, Earn Great Scientists 50% faster")
|
||||
greatPersonPoints.science *= 1.5f
|
||||
return stats
|
||||
}
|
||||
|
||||
return greatPersonPoints
|
||||
fun getGreatPersonPoints(): Stats {
|
||||
val stats=Stats()
|
||||
for(entry in getGreatPersonMap().values)
|
||||
stats.add(entry)
|
||||
return stats
|
||||
}
|
||||
|
||||
fun isCapital() = cityConstructions.isBuilt("Palace")
|
||||
|
@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.*
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.logic.city.CityInfo
|
||||
import com.unciv.logic.civilization.GreatPersonManager
|
||||
import com.unciv.models.gamebasics.Building
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.models.stats.Stat
|
||||
@ -22,6 +23,32 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS
|
||||
internal fun update() {
|
||||
clear()
|
||||
val cityInfo = cityScreen.city
|
||||
|
||||
addBuildingInfo(cityInfo)
|
||||
|
||||
addStatInfo()
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
pack()
|
||||
}
|
||||
|
||||
private fun addBuildingInfo(cityInfo: CityInfo) {
|
||||
val wonders = mutableListOf<Building>()
|
||||
val specialistBuildings = mutableListOf<Building>()
|
||||
val otherBuildings = mutableListOf<Building>()
|
||||
@ -70,10 +97,6 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS
|
||||
}
|
||||
add(buildingsExpanderTab).row()
|
||||
}
|
||||
|
||||
addStatInfo()
|
||||
|
||||
pack()
|
||||
}
|
||||
|
||||
private fun addStatInfo() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user