Resolved #908 - added Science overview to overview screen
This commit is contained in:
parent
06d1bd6881
commit
8f0c3f1c02
4 changed files with 39 additions and 22 deletions
|
@ -21,8 +21,8 @@ android {
|
|||
applicationId "com.unciv.app"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 28
|
||||
versionCode 263
|
||||
versionName "2.17.10-patch2"
|
||||
versionCode 264
|
||||
versionName "2.17.11"
|
||||
}
|
||||
|
||||
// Had to add this crap for Travis to build, it wanted to sign the app
|
||||
|
|
|
@ -20,6 +20,7 @@ import com.unciv.models.gamebasics.tech.TechEra
|
|||
import com.unciv.models.gamebasics.tile.ResourceSupplyList
|
||||
import com.unciv.models.gamebasics.tile.ResourceType
|
||||
import com.unciv.models.stats.Stat
|
||||
import com.unciv.models.stats.StatMap
|
||||
import com.unciv.models.stats.Stats
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
@ -138,10 +139,9 @@ class CivilizationInfo {
|
|||
}
|
||||
|
||||
fun getStatMapForNextTurn(): HashMap<String, Stats> {
|
||||
val statMap = HashMap<String,Stats>()
|
||||
val statMap = StatMap()
|
||||
for (city in cities){
|
||||
if(!statMap.containsKey("Cities")) statMap["Cities"]=Stats()
|
||||
statMap["Cities"] = statMap["Cities"]!! + city.cityStats.currentCityStats
|
||||
statMap.add("Cities",city.cityStats.currentCityStats)
|
||||
}
|
||||
|
||||
//City states culture bonus
|
||||
|
@ -150,17 +150,12 @@ class CivilizationInfo {
|
|||
&& otherCiv.getDiplomacyManager(civName).relationshipLevel() >= RelationshipLevel.Friend) {
|
||||
val cultureBonus = Stats()
|
||||
cultureBonus.add(Stat.Culture, 3f * (getEra().ordinal+1))
|
||||
if (statMap.containsKey("City States"))
|
||||
statMap["City States"] = statMap["City States"]!! + cultureBonus
|
||||
else
|
||||
statMap["City States"] = cultureBonus
|
||||
statMap.add("City States",cultureBonus)
|
||||
}
|
||||
}
|
||||
|
||||
for (entry in getHappinessBreakdown()) {
|
||||
if (!statMap.containsKey(entry.key))
|
||||
statMap[entry.key] = Stats()
|
||||
statMap[entry.key]!!.happiness += entry.value
|
||||
statMap.add(entry.key,Stats().apply { happiness=entry.value })
|
||||
}
|
||||
|
||||
statMap["Transportation upkeep"] = Stats().apply { gold=- getTransportationUpkeep().toFloat()}
|
||||
|
@ -168,10 +163,7 @@ class CivilizationInfo {
|
|||
|
||||
if (policies.isAdopted("Mandate Of Heaven")) {
|
||||
val happiness = statMap.values.map { it.happiness }.sum()
|
||||
if(happiness>0) {
|
||||
if (!statMap.containsKey("Policies")) statMap["Policies"] = Stats()
|
||||
statMap["Policies"]!!.culture += happiness / 2
|
||||
}
|
||||
if(happiness>0) statMap.add("Policies",Stats().apply { culture=happiness/2 })
|
||||
}
|
||||
|
||||
// negative gold hurts science
|
||||
|
|
|
@ -87,3 +87,10 @@ open class Stats() {
|
|||
science=hashMap[Stat.Science]!!
|
||||
}
|
||||
}
|
||||
|
||||
class StatMap:LinkedHashMap<String,Stats>(){
|
||||
fun add(source:String,stats:Stats){
|
||||
if(!containsKey(source)) put(source,stats)
|
||||
else put(source, get(source)!!+stats)
|
||||
}
|
||||
}
|
|
@ -44,12 +44,12 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
|||
val setStatsInfoButton = TextButton("Stats".tr(),skin)
|
||||
setStatsInfoButton.onClick {
|
||||
centerTable.clear()
|
||||
centerTable.add(ScrollPane(HorizontalGroup().apply {
|
||||
space(40f)
|
||||
top()
|
||||
addActor(getHappinessTable())
|
||||
addActor(getGoldTable())
|
||||
addActor(getGreatPeopleTable())
|
||||
centerTable.add(ScrollPane(Table().apply {
|
||||
defaults().pad(40f)
|
||||
add(getHappinessTable()).top()
|
||||
add(getGoldTable()).top()
|
||||
add(getScienceTable()).top()
|
||||
add(getGreatPeopleTable()).top()
|
||||
}))
|
||||
centerTable.pack()
|
||||
}
|
||||
|
@ -169,6 +169,24 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
|||
}
|
||||
|
||||
|
||||
private fun getScienceTable(): Table {
|
||||
val scienceTable = Table(skin)
|
||||
scienceTable.defaults().pad(5f)
|
||||
scienceTable.add("Science".toLabel().setFontSize(24)).colspan(2).row()
|
||||
scienceTable.addSeparator()
|
||||
val scienceStats = currentPlayerCivInfo.getStatMapForNextTurn()
|
||||
.filter { it.value.science!=0f }
|
||||
for (entry in scienceStats) {
|
||||
scienceTable.add(entry.key.tr())
|
||||
scienceTable.add(entry.value.science.roundToInt().toString()).row()
|
||||
}
|
||||
scienceTable.add("Total".tr())
|
||||
scienceTable.add(scienceStats.values.map { it.science }.sum().roundToInt().toString())
|
||||
scienceTable.pack()
|
||||
return scienceTable
|
||||
}
|
||||
|
||||
|
||||
private fun getGreatPeopleTable(): Table {
|
||||
val greatPeopleTable = Table(skin)
|
||||
|
||||
|
|
Loading…
Reference in a new issue