Correct year shown when starting in later eras (#5070)

* json, getEquivalentTurn

* WorldScreenTopBar.kt

* affects shown year only
This commit is contained in:
SimonCeder 2021-09-02 23:13:58 +02:00 committed by GitHub
parent 2993ffb272
commit 8cb464c9f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 4 deletions

View File

@ -11,6 +11,7 @@
"startingMilitaryUnit": "Warrior", "startingMilitaryUnit": "Warrior",
"settlerPopulation": 1, "settlerPopulation": 1,
"baseUnitBuyCost": 200, "baseUnitBuyCost": 200,
"startPercent": 0,
"friendBonus": { "friendBonus": {
"Cultured": ["Provides [3] [Culture] per turn"], "Cultured": ["Provides [3] [Culture] per turn"],
"Maritime": ["Provides [2] [Food] [in capital]"], "Maritime": ["Provides [2] [Food] [in capital]"],
@ -36,6 +37,7 @@
"startingCulture": 100, "startingCulture": 100,
"settlerPopulation": 1, "settlerPopulation": 1,
"baseUnitBuyCost": 200, "baseUnitBuyCost": 200,
"startPercent": 10,
"friendBonus": { "friendBonus": {
"Cultured": ["Provides [3] [Culture] per turn"], "Cultured": ["Provides [3] [Culture] per turn"],
"Maritime": ["Provides [2] [Food] [in capital]"], "Maritime": ["Provides [2] [Food] [in capital]"],
@ -63,6 +65,7 @@
"settlerBuildings": ["Shrine","Monument"], "settlerBuildings": ["Shrine","Monument"],
"startingObsoleteWonders": ["Temple of Artemis", "Stonehenge", "The Great Library", "Mausoleum of Halicarnassus", "The Pyramids", "Statue of Zeus"], "startingObsoleteWonders": ["Temple of Artemis", "Stonehenge", "The Great Library", "Mausoleum of Halicarnassus", "The Pyramids", "Statue of Zeus"],
"baseUnitBuyCost": 200, "baseUnitBuyCost": 200,
"startPercent": 25,
"friendBonus": { "friendBonus": {
"Cultured": ["Provides [6] [Culture] per turn"], "Cultured": ["Provides [6] [Culture] per turn"],
"Maritime": ["Provides [2] [Food] [in capital]"], "Maritime": ["Provides [2] [Food] [in capital]"],
@ -91,6 +94,7 @@
"startingObsoleteWonders": ["Temple of Artemis", "Stonehenge", "The Great Library", "Mausoleum of Halicarnassus", "The Pyramids", "Statue of Zeus", "startingObsoleteWonders": ["Temple of Artemis", "Stonehenge", "The Great Library", "Mausoleum of Halicarnassus", "The Pyramids", "Statue of Zeus",
"The Great Lighthouse", "Hanging Gardens", "Terracotta Army", "The Oracle", "Petra", "Great Wall", "Colossus"], "The Great Lighthouse", "Hanging Gardens", "Terracotta Army", "The Oracle", "Petra", "Great Wall", "Colossus"],
"baseUnitBuyCost": 300, "baseUnitBuyCost": 300,
"startPercent": 37,
"friendBonus": { "friendBonus": {
"Cultured": ["Provides [6] [Culture] per turn"], "Cultured": ["Provides [6] [Culture] per turn"],
"Maritime": ["Provides [2] [Food] [in capital]"], "Maritime": ["Provides [2] [Food] [in capital]"],
@ -120,6 +124,7 @@
"The Great Lighthouse", "Hanging Gardens", "Terracotta Army", "The Oracle", "Petra", "Great Wall", "Colossus", "The Great Lighthouse", "Hanging Gardens", "Terracotta Army", "The Oracle", "Petra", "Great Wall", "Colossus",
"Hagia Sophia", "Chichen Itza", "Machu Picchu", "Angkor Wat", "Alhambra", "Notre Dame"], "Hagia Sophia", "Chichen Itza", "Machu Picchu", "Angkor Wat", "Alhambra", "Notre Dame"],
"baseUnitBuyCost": 400, "baseUnitBuyCost": 400,
"startPercent": 50,
"friendBonus": { "friendBonus": {
"Cultured": ["Provides [13] [Culture] per turn"], "Cultured": ["Provides [13] [Culture] per turn"],
"Maritime": ["Provides [2] [Food] [in capital]"], "Maritime": ["Provides [2] [Food] [in capital]"],
@ -150,6 +155,7 @@
"Hagia Sophia", "Chichen Itza", "Machu Picchu", "Angkor Wat", "Alhambra", "Notre Dame", "Hagia Sophia", "Chichen Itza", "Machu Picchu", "Angkor Wat", "Alhambra", "Notre Dame",
"Sistine Chapel", "Forbidden Palace", "Leaning Tower of Pisa", "Himeji Castle", "Taj Mahal", "Porcelain Tower", "Kremlin"], "Sistine Chapel", "Forbidden Palace", "Leaning Tower of Pisa", "Himeji Castle", "Taj Mahal", "Porcelain Tower", "Kremlin"],
"baseUnitBuyCost": 600, "baseUnitBuyCost": 600,
"startPercent": 65,
"friendBonus": { "friendBonus": {
"Cultured": ["Provides [13] [Culture] per turn"], "Cultured": ["Provides [13] [Culture] per turn"],
"Maritime": ["Provides [2] [Food] [in capital]"], "Maritime": ["Provides [2] [Food] [in capital]"],
@ -181,6 +187,7 @@
"Sistine Chapel", "Forbidden Palace", "Leaning Tower of Pisa", "Himeji Castle", "Taj Mahal", "Porcelain Tower", "Kremlin", "Sistine Chapel", "Forbidden Palace", "Leaning Tower of Pisa", "Himeji Castle", "Taj Mahal", "Porcelain Tower", "Kremlin",
"The Louvre", "Big Ben", "Brandenburg Gate"], "The Louvre", "Big Ben", "Brandenburg Gate"],
"baseUnitBuyCost": 800, "baseUnitBuyCost": 800,
"startPercent": 65,
"friendBonus": { "friendBonus": {
"Cultured": ["Provides [13] [Culture] per turn"], "Cultured": ["Provides [13] [Culture] per turn"],
"Maritime": ["Provides [2] [Food] [in capital]"], "Maritime": ["Provides [2] [Food] [in capital]"],
@ -213,6 +220,7 @@
"The Louvre", "Big Ben", "Brandenburg Gate", "The Louvre", "Big Ben", "Brandenburg Gate",
"Eiffel Tower", "Statue of Liberty", "Neuschwanstein", "Cristo Redentor"], "Eiffel Tower", "Statue of Liberty", "Neuschwanstein", "Cristo Redentor"],
"baseUnitBuyCost": 1000, "baseUnitBuyCost": 1000,
"startPercent": 80,
// So theoretically this is always just all the wonders at least 2 eras old. So we could just use that. // So theoretically this is always just all the wonders at least 2 eras old. So we could just use that.
// But where is the modularity? The excluding of very specific wonders? That is no fun. // But where is the modularity? The excluding of very specific wonders? That is no fun.
// So we just write down the entire long list (sorted by era!) instead. // So we just write down the entire long list (sorted by era!) instead.
@ -250,6 +258,7 @@
"The Louvre", "Big Ben", "Brandenburg Gate", "The Louvre", "Big Ben", "Brandenburg Gate",
"Eiffel Tower", "Statue of Liberty", "Neuschwanstein", "Cristo Redentor"], "Eiffel Tower", "Statue of Liberty", "Neuschwanstein", "Cristo Redentor"],
"baseUnitBuyCost": 1000, "baseUnitBuyCost": 1000,
"startPercent": 80,
"friendBonus": { "friendBonus": {
"Cultured": ["Provides [13] [Culture] per turn"], "Cultured": ["Provides [13] [Culture] per turn"],
"Maritime": ["Provides [2] [Food] [in capital]"], "Maritime": ["Provides [2] [Food] [in capital]"],

View File

@ -20,6 +20,7 @@ class Era : INamed {
var settlerBuildings = ArrayList<String>() var settlerBuildings = ArrayList<String>()
var startingObsoleteWonders = ArrayList<String>() var startingObsoleteWonders = ArrayList<String>()
var baseUnitBuyCost = 200 var baseUnitBuyCost = 200
var startPercent = 0
var friendBonus = HashMap<String, List<String>>() var friendBonus = HashMap<String, List<String>>()
var allyBonus = HashMap<String, List<String>>() var allyBonus = HashMap<String, List<String>>()
var iconRGB: List<Int>? = null var iconRGB: List<Int>? = null

View File

@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.Actor import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.scenes.scene2d.Group import com.badlogic.gdx.scenes.scene2d.Group
import com.badlogic.gdx.scenes.scene2d.ui.* import com.badlogic.gdx.scenes.scene2d.ui.*
import com.unciv.logic.GameInfo
import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.models.metadata.GameSpeed import com.unciv.models.metadata.GameSpeed
import com.unciv.models.ruleset.tile.ResourceType import com.unciv.models.ruleset.tile.ResourceType
@ -200,7 +201,7 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
else resourceLabels[resource.name]!!.setText(civResources.first { it.resource == resource }.amount.toString()) else resourceLabels[resource.name]!!.setText(civResources.first { it.resource == resource }.amount.toString())
} }
val year = getYear(civInfo.gameInfo.gameParameters.gameSpeed, civInfo.gameInfo.turns).toInt() val year = getYear(civInfo.gameInfo.gameParameters.gameSpeed, getEquivalentTurn(civInfo.gameInfo)).toInt()
val yearText = "[" + abs(year) + "] " + if (year < 0) "BC" else "AD" val yearText = "[" + abs(year) + "] " + if (year < 0) "BC" else "AD"
turnsLabel.setText(Fonts.turn + "" + civInfo.gameInfo.turns + " | " + yearText.tr()) turnsLabel.setText(Fonts.turn + "" + civInfo.gameInfo.turns + " | " + yearText.tr())
@ -264,10 +265,10 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
// Best to initialize these once only // Best to initialize these once only
private val marathon = listOf(YearsToTurn(100, 15.0), YearsToTurn(400, 10.0), YearsToTurn(570, 5.0), YearsToTurn(771, 2.0), YearsToTurn(900, 1.0), YearsToTurn(1000, 0.5), YearsToTurn(1500, 0.25)) private val marathon = listOf(YearsToTurn(100, 15.0), YearsToTurn(400, 10.0), YearsToTurn(570, 5.0), YearsToTurn(771, 2.0), YearsToTurn(900, 1.0), YearsToTurn(1080, 0.5), YearsToTurn(1344, 0.25), YearsToTurn(1500, 0.083333))
private val epic = listOf(YearsToTurn(140, 25.0), YearsToTurn(230, 15.0), YearsToTurn(270, 10.0), YearsToTurn(360, 5.0), YearsToTurn(430, 2.0), YearsToTurn(530, 1.0), YearsToTurn(1500, 0.5)) private val epic = listOf(YearsToTurn(140, 25.0), YearsToTurn(230, 15.0), YearsToTurn(270, 10.0), YearsToTurn(360, 5.0), YearsToTurn(430, 2.0), YearsToTurn(530, 1.0), YearsToTurn(1500, 0.5))
private val standard = listOf(YearsToTurn(75, 40.0), YearsToTurn(135, 25.0), YearsToTurn(160, 15.0), YearsToTurn(211, 10.0), YearsToTurn(270, 5.0), YearsToTurn(315, 2.0), YearsToTurn(440, 1.0)) private val standard = listOf(YearsToTurn(75, 40.0), YearsToTurn(135, 25.0), YearsToTurn(160, 20.0), YearsToTurn(210, 10.0), YearsToTurn(270, 5.0), YearsToTurn(320, 2.0), YearsToTurn(440, 1.0), YearsToTurn(500, 0.5))
private val quick = listOf(YearsToTurn(50, 60.0), YearsToTurn(80, 40.0), YearsToTurn(100, 25.0), YearsToTurn(130, 15.0), YearsToTurn(155, 10.0), YearsToTurn(195, 5.0), YearsToTurn(260, 2.0)) private val quick = listOf(YearsToTurn(50, 60.0), YearsToTurn(80, 40.0), YearsToTurn(100, 30.0), YearsToTurn(130, 20.0), YearsToTurn(155, 10.0), YearsToTurn(195, 5.0), YearsToTurn(260, 2.0), YearsToTurn(310, 1.0))
private fun getYear(gameSpeed: GameSpeed, turn: Int): Float { private fun getYear(gameSpeed: GameSpeed, turn: Int): Float {
@ -290,4 +291,11 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
return year return year
} }
private fun getEquivalentTurn(gameInfo: GameInfo): Int {
val totalTurns = 500f * gameInfo.gameParameters.gameSpeed.modifier
val startPercent = gameInfo.ruleSet.eras[gameInfo.gameParameters.startingEra]?.startPercent
if (startPercent == null) return gameInfo.turns
return gameInfo.turns + ((totalTurns * startPercent).toInt() / 100)
}
} }