mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-22 13:49:54 +07:00
In-game year is displayed by the number of turns
This commit is contained in:
@ -21,8 +21,8 @@ android {
|
||||
applicationId "com.unciv.game"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 26
|
||||
versionCode 58
|
||||
versionName "2.1.8"
|
||||
versionCode 59
|
||||
versionName "2.2.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
@ -15,7 +15,7 @@ class GameInfo {
|
||||
var tutorial = mutableListOf<String>()
|
||||
var civilizations = mutableListOf<CivilizationInfo>()
|
||||
var tileMap: TileMap = TileMap()
|
||||
var turns = 1
|
||||
var turns = 0
|
||||
@Transient var tilesToCities = HashMap<TileInfo,CityInfo>()
|
||||
|
||||
|
||||
|
@ -4,13 +4,16 @@ import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.ResourceType
|
||||
import com.unciv.models.stats.Stats
|
||||
import com.unciv.ui.cityscreen.addClickListener
|
||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
import com.unciv.ui.utils.centerY
|
||||
import com.unciv.ui.utils.colorFromRGB
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.ceil
|
||||
|
||||
class CivStatsTable(val screen: WorldScreen) : Table() {
|
||||
@ -30,11 +33,8 @@ class CivStatsTable(val screen: WorldScreen) : Table() {
|
||||
init {
|
||||
background = ImageGetter.getDrawable("skin/whiteDot.png").tint(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f))
|
||||
|
||||
//add(Table().apply {
|
||||
add(getStatsTable()).row()
|
||||
add(getResourceTable())
|
||||
// pack()
|
||||
// })
|
||||
|
||||
pad(5f)
|
||||
pack()
|
||||
@ -105,37 +105,54 @@ class CivStatsTable(val screen: WorldScreen) : Table() {
|
||||
else resourceLabels[resource.name]!!.setText(civResources[resource]!!.toString())
|
||||
}
|
||||
|
||||
turnsLabel.setText("Turns: " + civInfo.gameInfo.turns + "/400")
|
||||
val turns = civInfo.gameInfo.turns
|
||||
val year = when{
|
||||
turns<=75 -> -4000+turns*40
|
||||
turns<=135 -> -1000+(turns-75)*25
|
||||
turns<=160 -> 500+(turns-135)*20
|
||||
turns<=210 -> 1000+(turns-160)*10
|
||||
turns<=270 -> 1500+(turns-210)*5
|
||||
turns<=320 -> 1800+(turns-270)*2
|
||||
turns<=440 -> 1900+(turns-320)
|
||||
else -> 2020+(turns-440)/2
|
||||
}
|
||||
|
||||
turnsLabel.setText("Turn " + civInfo.gameInfo.turns + " | "+ abs(year)+(if (year<0) " BCE" else " CE"))
|
||||
|
||||
val nextTurnStats = civInfo.getStatsForNextTurn()
|
||||
|
||||
val goldPerTurn = "(" + (if (nextTurnStats.gold > 0) "+" else "") + Math.round(nextTurnStats.gold) + ")"
|
||||
goldLabel.setText("" + Math.round(civInfo.gold.toFloat()) + goldPerTurn)
|
||||
|
||||
scienceLabel.setText("+" + Math.round(nextTurnStats.science))
|
||||
happinessLabel.setText(getHappinessText(civInfo))
|
||||
|
||||
if (civInfo.happiness < 0) {
|
||||
happinessLabel.color = Color.valueOf("ef5350")
|
||||
happinessImage.drawable = ImageGetter.getStatIcon("Malcontent").drawable
|
||||
} else {
|
||||
happinessLabel.color = colorFromRGB(92, 194, 77)
|
||||
happinessImage.drawable = ImageGetter.getStatIcon("Happiness").drawable
|
||||
}
|
||||
|
||||
cultureLabel.setText(getCultureText(civInfo, nextTurnStats))
|
||||
}
|
||||
|
||||
private fun getCultureText(civInfo: CivilizationInfo, nextTurnStats: Stats): String {
|
||||
val turnsToNextPolicy = (civInfo.policies.getCultureNeededForNextPolicy() - civInfo.policies.storedCulture) / nextTurnStats.culture
|
||||
var cultureString = "+" + Math.round(nextTurnStats.culture)
|
||||
if (turnsToNextPolicy > 0) cultureString += " (" + ceil(turnsToNextPolicy).toInt() + ")"
|
||||
else cultureString += " (!)"
|
||||
return cultureString
|
||||
}
|
||||
|
||||
private fun getHappinessText(civInfo: CivilizationInfo): String {
|
||||
var happinessText = civInfo.happiness.toString()
|
||||
if (civInfo.goldenAges.isGoldenAge())
|
||||
happinessText += " GOLDEN AGE (${civInfo.goldenAges.turnsLeftForCurrentGoldenAge})"
|
||||
else
|
||||
happinessText += (" (" + civInfo.goldenAges.storedHappiness + "/"
|
||||
+ civInfo.goldenAges.happinessRequiredForNextGoldenAge() + ")")
|
||||
happinessLabel.setText(happinessText)
|
||||
|
||||
if(civInfo.happiness<0){
|
||||
happinessLabel.color = Color.valueOf("ef5350")
|
||||
happinessImage.drawable = ImageGetter.getStatIcon("Malcontent").drawable
|
||||
}
|
||||
else{
|
||||
happinessLabel.color = colorFromRGB(92, 194, 77)
|
||||
happinessImage.drawable = ImageGetter.getStatIcon("Happiness").drawable
|
||||
}
|
||||
|
||||
val turnsToNextPolicy = (civInfo.policies.getCultureNeededForNextPolicy() - civInfo.policies.storedCulture) / nextTurnStats.culture
|
||||
var cultureString = "+" + Math.round(nextTurnStats.culture)
|
||||
if(turnsToNextPolicy>0) cultureString+= " ("+ ceil(turnsToNextPolicy).toInt()+")"
|
||||
else cultureString += " (!)"
|
||||
cultureLabel.setText(cultureString)
|
||||
return happinessText
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user