Fixed great person point generation
Added great person points to civ overview
This commit is contained in:
parent
0a0b664dfe
commit
42e6ab1c65
5 changed files with 60 additions and 21 deletions
|
@ -21,8 +21,8 @@ android {
|
|||
applicationId "com.unciv.game"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 26
|
||||
versionCode 158
|
||||
versionName "2.9.10"
|
||||
versionCode 159
|
||||
versionName "2.10.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
|
|
@ -100,8 +100,8 @@ class PopulationManager {
|
|||
val maxSpecialists = getMaxSpecialists().toHashMap()
|
||||
val specialistsHashmap = specialists.toHashMap()
|
||||
for(entry in maxSpecialists)
|
||||
if(specialistsHashmap[entry.key]!!>entry.value)
|
||||
specialists.add(entry.key,specialistsHashmap[entry.key]!!-maxSpecialists[entry.key]!!)
|
||||
if(specialistsHashmap[entry.key]!! > entry.value)
|
||||
specialists.add(entry.key,specialistsHashmap[entry.key]!! - maxSpecialists[entry.key]!!)
|
||||
}
|
||||
|
||||
fun getMaxSpecialists(): Stats {
|
||||
|
|
|
@ -296,11 +296,12 @@ class CivilizationInfo {
|
|||
|
||||
gold += nextTurnStats.gold.toInt()
|
||||
|
||||
if (cities.size > 0) tech.nextTurn(nextTurnStats.science.toInt())
|
||||
if (cities.isNotEmpty()) tech.nextTurn(nextTurnStats.science.toInt())
|
||||
|
||||
greatPeople.addGreatPersonPoints(getGreatPersonPointsForNextTurn())
|
||||
|
||||
for (city in cities.toList()) { // a city can be removed while iterating (if it's being razed) so we need to iterate over a copy
|
||||
city.endTurn()
|
||||
greatPeople.addGreatPersonPoints(city.getGreatPersonPoints())
|
||||
}
|
||||
|
||||
val greatPerson = greatPeople.getNewGreatPerson()
|
||||
|
@ -313,6 +314,12 @@ class CivilizationInfo {
|
|||
diplomacy.values.forEach{it.nextTurn()}
|
||||
}
|
||||
|
||||
fun getGreatPersonPointsForNextTurn(): Stats {
|
||||
val stats = Stats()
|
||||
for (city in cities) stats.add(city.getGreatPersonPoints())
|
||||
return stats
|
||||
}
|
||||
|
||||
fun startTurn(){
|
||||
getViewableTiles() // adds explored tiles so that the units will be able to perform automated actions better
|
||||
setCitiesConnectedToCapitalTransients()
|
||||
|
|
|
@ -1,12 +1,20 @@
|
|||
package com.unciv.logic.civilization
|
||||
|
||||
import com.unciv.models.stats.Stat
|
||||
import com.unciv.models.stats.Stats
|
||||
|
||||
class GreatPersonManager {
|
||||
private var pointsForNextGreatPerson = 100
|
||||
private var greatPersonPoints = Stats()
|
||||
var pointsForNextGreatPerson = 100
|
||||
var greatPersonPoints = Stats()
|
||||
var freeGreatPeople=0
|
||||
|
||||
val statToGreatPersonMapping = HashMap<Stat,String>().apply {
|
||||
put(Stat.Science,"Great Scientist")
|
||||
put(Stat.Production,"Great Engineer")
|
||||
put(Stat.Gold, "Great Merchant")
|
||||
put(Stat.Culture, "Great Artist")
|
||||
}
|
||||
|
||||
fun clone(): GreatPersonManager {
|
||||
val toReturn = GreatPersonManager()
|
||||
toReturn.freeGreatPeople=freeGreatPeople
|
||||
|
@ -17,22 +25,19 @@ class GreatPersonManager {
|
|||
|
||||
fun getNewGreatPerson(): String? {
|
||||
var greatPerson: String? = null
|
||||
when {
|
||||
greatPersonPoints.science > pointsForNextGreatPerson -> greatPerson = "Great Scientist"
|
||||
greatPersonPoints.production > pointsForNextGreatPerson -> greatPerson = "Great Engineer"
|
||||
greatPersonPoints.culture > pointsForNextGreatPerson -> greatPerson = "Great Artist"
|
||||
greatPersonPoints.gold > pointsForNextGreatPerson -> greatPerson = "Great Merchant"
|
||||
}
|
||||
|
||||
if (greatPerson != null) {
|
||||
greatPersonPoints.science -= pointsForNextGreatPerson.toFloat()
|
||||
pointsForNextGreatPerson *= 2
|
||||
val greatPersonPointsHashmap = greatPersonPoints.toHashMap()
|
||||
for(entry in statToGreatPersonMapping){
|
||||
if(greatPersonPointsHashmap[entry.key]!!>pointsForNextGreatPerson){
|
||||
greatPersonPoints.add(entry.key,-pointsForNextGreatPerson.toFloat())
|
||||
pointsForNextGreatPerson*=2
|
||||
return entry.value
|
||||
}
|
||||
}
|
||||
return greatPerson
|
||||
}
|
||||
|
||||
fun addGreatPersonPoints(greatPersonPoints: Stats) {
|
||||
greatPersonPoints.add(greatPersonPoints)
|
||||
fun addGreatPersonPoints(greatPersonPointsForTurn: Stats) {
|
||||
greatPersonPoints.add(greatPersonPointsForTurn)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -40,7 +40,8 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
|||
setStatsInfoButton.onClick {
|
||||
centerTable.clear()
|
||||
centerTable.add(getHappinessTable())
|
||||
centerTable.add(getGoldTable())
|
||||
centerTable.add(getGoldTable()).row()
|
||||
centerTable.add(getGreatPeopleTable())
|
||||
centerTable.pack()
|
||||
centerTable.center(stage)
|
||||
}
|
||||
|
@ -135,6 +136,32 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
|||
return goldTable
|
||||
}
|
||||
|
||||
|
||||
private fun getGreatPeopleTable(): Table {
|
||||
val greatPeopleTable = Table(skin)
|
||||
|
||||
val greatPersonPoints = civInfo.greatPeople.greatPersonPoints.toHashMap()
|
||||
val greatPersonPointsPerTurn = civInfo.getGreatPersonPointsForNextTurn().toHashMap()
|
||||
val pointsToGreatPerson = civInfo.greatPeople.pointsForNextGreatPerson
|
||||
|
||||
greatPeopleTable.defaults().pad(5f)
|
||||
greatPeopleTable.add(Label("Great person points".tr(), skin).setFontSize(24)).colspan(3).row()
|
||||
greatPeopleTable.add()
|
||||
greatPeopleTable.add("Current points")
|
||||
greatPeopleTable.add("Points per turn").row()
|
||||
|
||||
val mapping = civInfo.greatPeople.statToGreatPersonMapping
|
||||
for(entry in mapping){
|
||||
greatPeopleTable.add(entry.value)
|
||||
greatPeopleTable.add(greatPersonPoints[entry.key]!!.toInt().toString()+"/"+pointsToGreatPerson)
|
||||
greatPeopleTable.add(greatPersonPointsPerTurn[entry.key]!!.toInt().toString()).row()
|
||||
}
|
||||
greatPeopleTable.pack()
|
||||
return greatPeopleTable
|
||||
}
|
||||
|
||||
|
||||
|
||||
private fun getCityInfoTable(): Table {
|
||||
val iconSize = 20f//if you set this too low, there is a chance that the tables will be misaligned
|
||||
val padding = 5f
|
||||
|
|
Loading…
Reference in a new issue