Resolved #455 - add great person point breakdown to city info

This commit is contained in:
Yair Morgenstern 2019-02-16 23:39:03 +02:00
parent 0cd5426440
commit 356f8b6bbd
4 changed files with 63 additions and 22 deletions

View file

@ -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"

View file

@ -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")

View file

@ -122,7 +122,7 @@ class NewGameScreen: PickerScreen(){
newGameOptionsTable.add("{Number of human players}:".tr())
val humanPlayers = SelectBox<Int>(skin)
val humanPlayersArray = Array<Int>()
(1..GameBasics.Nations.size).forEach { humanPlayersArray .add(it) }
(1..GameBasics.Nations.size).forEach { humanPlayersArray.add(it) }
humanPlayers.items = humanPlayersArray
humanPlayers.selected = newGameParameters.numberOfHumanPlayers
newGameOptionsTable.add(humanPlayers).pad(10f).row()

View file

@ -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>()
@ -35,7 +62,7 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS
}
if (!wonders.isEmpty()) {
val wondersExpander = ExpanderTab("Wonders".tr(),skin)
val wondersExpander = ExpanderTab("Wonders".tr(), skin)
for (building in wonders) {
wondersExpander.innerTable.add(ImageGetter.getConstructionImage(building.name).surroundWithCircle(30f))
wondersExpander.innerTable.add(building.name.toLabel()).pad(5f).align(Align.left).row()
@ -44,14 +71,14 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS
}
if (!specialistBuildings.isEmpty()) {
val specialistBuildingsExpander = ExpanderTab("Specialist Buildings".tr(),skin)
val specialistBuildingsExpander = ExpanderTab("Specialist Buildings".tr(), skin)
for (building in specialistBuildings) {
specialistBuildingsExpander.innerTable.add(ImageGetter.getConstructionImage(building.name).surroundWithCircle(30f))
specialistBuildingsExpander.innerTable.add(building.name.toLabel()).pad(5f)
val specialistIcons = Table()
specialistIcons.row().size(20f).pad(5f)
for(stat in building.specialistSlots!!.toHashMap())
for(i in 0 until stat.value.toInt())
for (stat in building.specialistSlots!!.toHashMap())
for (i in 0 until stat.value.toInt())
specialistIcons.add(getSpecialistIcon(stat.key)).size(20f)
specialistBuildingsExpander.innerTable.add(specialistIcons).row()
@ -63,17 +90,13 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS
}
if (!otherBuildings.isEmpty()) {
val buildingsExpanderTab = ExpanderTab("Buildings".tr(),skin)
val buildingsExpanderTab = ExpanderTab("Buildings".tr(), skin)
for (building in otherBuildings) {
buildingsExpanderTab.innerTable.add(ImageGetter.getConstructionImage(building.name).surroundWithCircle(30f))
buildingsExpanderTab.innerTable.add(building.name.toLabel()).pad(5f).row()
}
add(buildingsExpanderTab).row()
}
addStatInfo()
pack()
}
private fun addStatInfo() {