mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-18 19:59:47 +07:00
Fixed great person point generation
Added great person points to civ overview
This commit is contained in:
@ -21,8 +21,8 @@ android {
|
|||||||
applicationId "com.unciv.game"
|
applicationId "com.unciv.game"
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 26
|
targetSdkVersion 26
|
||||||
versionCode 158
|
versionCode 159
|
||||||
versionName "2.9.10"
|
versionName "2.10.0"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
|
@ -100,8 +100,8 @@ class PopulationManager {
|
|||||||
val maxSpecialists = getMaxSpecialists().toHashMap()
|
val maxSpecialists = getMaxSpecialists().toHashMap()
|
||||||
val specialistsHashmap = specialists.toHashMap()
|
val specialistsHashmap = specialists.toHashMap()
|
||||||
for(entry in maxSpecialists)
|
for(entry in maxSpecialists)
|
||||||
if(specialistsHashmap[entry.key]!!>entry.value)
|
if(specialistsHashmap[entry.key]!! > entry.value)
|
||||||
specialists.add(entry.key,specialistsHashmap[entry.key]!!-maxSpecialists[entry.key]!!)
|
specialists.add(entry.key,specialistsHashmap[entry.key]!! - maxSpecialists[entry.key]!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getMaxSpecialists(): Stats {
|
fun getMaxSpecialists(): Stats {
|
||||||
|
@ -296,11 +296,12 @@ class CivilizationInfo {
|
|||||||
|
|
||||||
gold += nextTurnStats.gold.toInt()
|
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
|
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()
|
city.endTurn()
|
||||||
greatPeople.addGreatPersonPoints(city.getGreatPersonPoints())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val greatPerson = greatPeople.getNewGreatPerson()
|
val greatPerson = greatPeople.getNewGreatPerson()
|
||||||
@ -313,6 +314,12 @@ class CivilizationInfo {
|
|||||||
diplomacy.values.forEach{it.nextTurn()}
|
diplomacy.values.forEach{it.nextTurn()}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getGreatPersonPointsForNextTurn(): Stats {
|
||||||
|
val stats = Stats()
|
||||||
|
for (city in cities) stats.add(city.getGreatPersonPoints())
|
||||||
|
return stats
|
||||||
|
}
|
||||||
|
|
||||||
fun startTurn(){
|
fun startTurn(){
|
||||||
getViewableTiles() // adds explored tiles so that the units will be able to perform automated actions better
|
getViewableTiles() // adds explored tiles so that the units will be able to perform automated actions better
|
||||||
setCitiesConnectedToCapitalTransients()
|
setCitiesConnectedToCapitalTransients()
|
||||||
|
@ -1,12 +1,20 @@
|
|||||||
package com.unciv.logic.civilization
|
package com.unciv.logic.civilization
|
||||||
|
|
||||||
|
import com.unciv.models.stats.Stat
|
||||||
import com.unciv.models.stats.Stats
|
import com.unciv.models.stats.Stats
|
||||||
|
|
||||||
class GreatPersonManager {
|
class GreatPersonManager {
|
||||||
private var pointsForNextGreatPerson = 100
|
var pointsForNextGreatPerson = 100
|
||||||
private var greatPersonPoints = Stats()
|
var greatPersonPoints = Stats()
|
||||||
var freeGreatPeople=0
|
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 {
|
fun clone(): GreatPersonManager {
|
||||||
val toReturn = GreatPersonManager()
|
val toReturn = GreatPersonManager()
|
||||||
toReturn.freeGreatPeople=freeGreatPeople
|
toReturn.freeGreatPeople=freeGreatPeople
|
||||||
@ -17,22 +25,19 @@ class GreatPersonManager {
|
|||||||
|
|
||||||
fun getNewGreatPerson(): String? {
|
fun getNewGreatPerson(): String? {
|
||||||
var greatPerson: String? = null
|
var greatPerson: String? = null
|
||||||
when {
|
val greatPersonPointsHashmap = greatPersonPoints.toHashMap()
|
||||||
greatPersonPoints.science > pointsForNextGreatPerson -> greatPerson = "Great Scientist"
|
for(entry in statToGreatPersonMapping){
|
||||||
greatPersonPoints.production > pointsForNextGreatPerson -> greatPerson = "Great Engineer"
|
if(greatPersonPointsHashmap[entry.key]!!>pointsForNextGreatPerson){
|
||||||
greatPersonPoints.culture > pointsForNextGreatPerson -> greatPerson = "Great Artist"
|
greatPersonPoints.add(entry.key,-pointsForNextGreatPerson.toFloat())
|
||||||
greatPersonPoints.gold > pointsForNextGreatPerson -> greatPerson = "Great Merchant"
|
pointsForNextGreatPerson*=2
|
||||||
}
|
return entry.value
|
||||||
|
}
|
||||||
if (greatPerson != null) {
|
|
||||||
greatPersonPoints.science -= pointsForNextGreatPerson.toFloat()
|
|
||||||
pointsForNextGreatPerson *= 2
|
|
||||||
}
|
}
|
||||||
return greatPerson
|
return greatPerson
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addGreatPersonPoints(greatPersonPoints: Stats) {
|
fun addGreatPersonPoints(greatPersonPointsForTurn: Stats) {
|
||||||
greatPersonPoints.add(greatPersonPoints)
|
greatPersonPoints.add(greatPersonPointsForTurn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,7 +40,8 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
|||||||
setStatsInfoButton.onClick {
|
setStatsInfoButton.onClick {
|
||||||
centerTable.clear()
|
centerTable.clear()
|
||||||
centerTable.add(getHappinessTable())
|
centerTable.add(getHappinessTable())
|
||||||
centerTable.add(getGoldTable())
|
centerTable.add(getGoldTable()).row()
|
||||||
|
centerTable.add(getGreatPeopleTable())
|
||||||
centerTable.pack()
|
centerTable.pack()
|
||||||
centerTable.center(stage)
|
centerTable.center(stage)
|
||||||
}
|
}
|
||||||
@ -135,6 +136,32 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
|||||||
return goldTable
|
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 {
|
private fun getCityInfoTable(): Table {
|
||||||
val iconSize = 20f//if you set this too low, there is a chance that the tables will be misaligned
|
val iconSize = 20f//if you set this too low, there is a chance that the tables will be misaligned
|
||||||
val padding = 5f
|
val padding = 5f
|
||||||
|
Reference in New Issue
Block a user