diff --git a/android/assets/jsons/Policies.json b/android/assets/jsons/Policies.json index 4ab5b1ec19..f0414d75eb 100644 --- a/android/assets/jsons/Policies.json +++ b/android/assets/jsons/Policies.json @@ -1,7 +1,7 @@ [ { "name": "Tradition", - "era": "Ancient", + "era": "Ancient era", "effect": "+3 culture in capital and increased rate of border expansion", "policies": [ { @@ -44,7 +44,7 @@ }, { "name": "Liberty", - "era": "Ancient", + "era": "Ancient era", "effect": "+1 culture in every city", "policies": [ { @@ -88,7 +88,7 @@ }, { "name": "Honor", - "era": "Ancient", + "era": "Ancient era", "effect": "+25% bonus vs Barbarians; gain Culture when you kill a barbarian unit", "policies": [ { @@ -131,7 +131,7 @@ ] },{ "name": "Piety", - "era": "Classical", + "era": "Classical era", "effect": "Building time of culture buildings reduced by 15%", "policies": [ { @@ -174,7 +174,7 @@ ] },/*{ "name": "Patronage", - "era": "Classical", + "era": "Classical era", "effect": "Influence with City-States degrades 25% slower than normal", "policies": [ { @@ -219,7 +219,7 @@ { "name": "Commerce", "effect": "+25% gold in capital", - "era": "Medieval", + "era": "Medieval era", "policies": [ { "name": "Trade Unions", @@ -262,7 +262,7 @@ }, { "name": "Rationalism", - "era": "Renaissance", + "era": "Renaissance era", "effect": "Production to science conversion in cities increased by 33%", "policies": [ { @@ -306,7 +306,7 @@ }, /*{ "name": "Order", - "era": "Industrial", + "era": "Industrial era", "effect": "+1 Happiness per City", "policies": [ { @@ -349,7 +349,7 @@ },*/ { "name": "Freedom", - "era": "Renaissance", + "era": "Renaissance era", "effect": "+25% great people rate", "policies": [ { @@ -392,7 +392,7 @@ }, { "name": "Autocracy", - "era": "Industrial", + "era": "Industrial era", "effect": "-33% unit upkeep costs", "policies": [ { diff --git a/android/assets/jsons/Techs.json b/android/assets/jsons/Techs.json index b02734f93a..25608e4428 100644 --- a/android/assets/jsons/Techs.json +++ b/android/assets/jsons/Techs.json @@ -1,7 +1,7 @@ [ { "columnNumber": 0, - "era": "Ancient", + "era": "Ancient era", "techCost": 20, "buildingCost": 40, "techs": [ @@ -15,7 +15,7 @@ }, { "columnNumber": 1, - "era": "Ancient", + "era": "Ancient era", "techCost": 35, "buildingCost": 60, "techs": [ @@ -48,7 +48,7 @@ }, { "columnNumber": 2, - "era": "Ancient", + "era": "Ancient era", "techCost": 55, "buildingCost": 75, "wonderCost": 185, @@ -99,7 +99,7 @@ }, { "columnNumber": 3, - "era": "Classical", + "era": "Classical era", "techCost": 105, "buildingCost": 100, "wonderCost": 250, @@ -134,7 +134,7 @@ }, { "columnNumber": 4, - "era": "Classical", + "era": "Classical era", "techCost": 175, "buildingCost": 120, "wonderCost": 300, @@ -167,7 +167,7 @@ }, { "columnNumber": 5, - "era": "Medieval", + "era": "Medieval era", "techCost": 275, "buildingCost": 160, "wonderCost": 400, @@ -202,7 +202,7 @@ }, { "columnNumber": 6, - "era": "Medieval", + "era": "Medieval era", "techCost": 485, "buildingCost": 200, "wonderCost": 500, @@ -250,7 +250,7 @@ }, { "columnNumber": 7, - "era": "Renaissance", + "era": "Renaissance era", "techCost": 780, "buildingCost": 250, "wonderCost": 625, @@ -290,7 +290,7 @@ }, { "columnNumber": 8, - "era": "Renaissance", + "era": "Renaissance era", "techCost": 1150, "buildingCost": 300, "wonderCost": 750, @@ -329,7 +329,7 @@ }, { "columnNumber": 9, - "era": "Industrial", + "era": "Industrial era", "techCost": 1600, "buildingCost": 360, "wonderCost": 920, @@ -374,7 +374,7 @@ }, { "columnNumber": 10, - "era": "Industrial", + "era": "Industrial era", "techCost": 2350, "buildingCost": 500, "wonderCost": 1060, @@ -408,7 +408,7 @@ }, { "columnNumber": 11, - "era": "Modern", + "era": "Modern era", "techCost": 3100, "buildingCost": 500, "wonderCost": 1250, @@ -447,7 +447,7 @@ }, { "columnNumber": 12, - "era": "Modern", + "era": "Modern era", "techCost": 4100, "buildingCost": 500, "wonderCost": 1250, @@ -480,7 +480,7 @@ }, { "columnNumber": 13, - "era": "Information", + "era": "Information era", "techCost": 5100, "buildingCost": 500, "wonderCost": 1250, @@ -513,7 +513,7 @@ }, { "columnNumber": 14, - "era": "Information", + "era": "Information era", "techCost": 6400, "buildingCost": 750, "wonderCost": 2000, @@ -547,7 +547,7 @@ }, { "columnNumber": 15, - "era": "Future", + "era": "Future era", "techCost": 7700, "buildingCost": 750, "wonderCost": 1250, @@ -581,7 +581,7 @@ { "columnNumber": 16, - "era": "Future", + "era": "Future era", "techCost": 8800, "buildingCost": 750, "wonderCost": 1250, @@ -602,7 +602,7 @@ }, { "columnNumber": 17, - "era": "Future", + "era": "Future era", "techCost": 9500, "buildingCost": 750, "wonderCost": 1250, diff --git a/core/src/com/unciv/Constants.kt b/core/src/com/unciv/Constants.kt index d79e067282..6037119483 100644 --- a/core/src/com/unciv/Constants.kt +++ b/core/src/com/unciv/Constants.kt @@ -63,4 +63,7 @@ object Constants { const val close = "Close" const val scienceConversionEffect = "Production to science conversion in cities increased by 33%" + + const val ancientEra="Ancient era" + const val futureEra="Future era" } \ No newline at end of file diff --git a/core/src/com/unciv/logic/battle/MapUnitCombatant.kt b/core/src/com/unciv/logic/battle/MapUnitCombatant.kt index 38b4ee7960..57e4be5d7e 100644 --- a/core/src/com/unciv/logic/battle/MapUnitCombatant.kt +++ b/core/src/com/unciv/logic/battle/MapUnitCombatant.kt @@ -26,7 +26,8 @@ class MapUnitCombatant(val unit: MapUnit) : ICombatant { } override fun getDefendingStrength(): Int { - if(unit.isEmbarked() && !unit.type.isCivilian()) return 5 * getCivInfo().getEra().ordinal + if(unit.isEmbarked() && !unit.type.isCivilian()) + return 5 * getCivInfo().getEraNumber() return unit.baseUnit().strength } diff --git a/core/src/com/unciv/logic/civilization/CivInfoStats.kt b/core/src/com/unciv/logic/civilization/CivInfoStats.kt index d0aa75d6c5..a6c5a628ad 100644 --- a/core/src/com/unciv/logic/civilization/CivInfoStats.kt +++ b/core/src/com/unciv/logic/civilization/CivInfoStats.kt @@ -81,7 +81,7 @@ class CivInfoStats(val civInfo: CivilizationInfo){ if (otherCiv.isCityState() && otherCiv.getCityStateType() == CityStateType.Cultured && otherCiv.getDiplomacyManager(civInfo.civName).relationshipLevel() >= RelationshipLevel.Friend) { val cultureBonus = Stats() - var culture = 3f * (civInfo.getEra().ordinal+1) + var culture = 3f * (civInfo.getEraNumber()+1) if(civInfo.nation.unique == UniqueAbility.FATHER_GOVERNS_CHILDREN) culture*=1.5f cultureBonus.add(Stat.Culture, culture) diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index b25dba20af..beaf1d0469 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -2,6 +2,7 @@ package com.unciv.logic.civilization import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.math.Vector2 +import com.sun.xml.internal.bind.v2.runtime.reflect.opt.Const import com.unciv.Constants import com.unciv.JsonParser import com.unciv.UncivGame @@ -268,13 +269,17 @@ class CivilizationInfo { && !isBarbarian() // Barbarians can be never defeated && (citiesCreated > 0 || !getCivUnits().any { it.name == Constants.settler }) - fun getEra(): TechEra { + fun getEra(): String { val maxEraOfTech = tech.researchedTechnologies .asSequence() - .map { it.era() } - .max() - if(maxEraOfTech!=null) return maxEraOfTech - else return TechEra.Ancient + .map { it.column!! } + .maxBy { it.columnNumber }!! + .era + return maxEraOfTech + } + + fun getEraNumber(): Int { + return gameInfo.ruleSet.getEraNumber(getEra()) } fun isAtWarWith(otherCiv:CivilizationInfo): Boolean { @@ -518,12 +523,11 @@ class CivilizationInfo { fun getResearchAgreementCost(otherCiv: CivilizationInfo): Int { // https://forums.civfanatics.com/resources/research-agreements-bnw.25568/ - val highestEra = sequenceOf(getEra(),otherCiv.getEra()).maxBy { it.ordinal }!! - val basicGoldCostOfSignResearchAgreement = when(highestEra){ - TechEra.Medieval, TechEra.Renaissance -> 250 - TechEra.Industrial -> 300 - TechEra.Modern -> 350 - TechEra.Information, TechEra.Future -> 400 + val basicGoldCostOfSignResearchAgreement = when(getEra()){ + "Medieval era", "Renaissance era" -> 250 + "Industrial era" -> 300 + "Modern era" -> 350 + "Information era", Constants.futureEra -> 400 else -> 0 } return (basicGoldCostOfSignResearchAgreement * gameInfo.gameParameters.gameSpeed.modifier).toInt() diff --git a/core/src/com/unciv/logic/civilization/PolicyManager.kt b/core/src/com/unciv/logic/civilization/PolicyManager.kt index 2d7092dd1d..6000d8c890 100644 --- a/core/src/com/unciv/logic/civilization/PolicyManager.kt +++ b/core/src/com/unciv/logic/civilization/PolicyManager.kt @@ -86,7 +86,7 @@ class PolicyManager { if(isAdopted(policy.name)) return false if (policy.name.endsWith("Complete")) return false if (!getAdoptedPolicies().containsAll(policy.requires!!)) return false - if (policy.branch.era > civInfo.getEra()) return false + if (civInfo.gameInfo.ruleSet.getEraNumber(policy.branch.era) > civInfo.getEraNumber()) return false return true } diff --git a/core/src/com/unciv/logic/civilization/TechManager.kt b/core/src/com/unciv/logic/civilization/TechManager.kt index fe6d94113f..fd79c37430 100644 --- a/core/src/com/unciv/logic/civilization/TechManager.kt +++ b/core/src/com/unciv/logic/civilization/TechManager.kt @@ -223,12 +223,12 @@ class TechManager { civInfo.popupAlerts.add(PopupAlert(AlertType.TechResearched,techName)) val currentEra = civInfo.getEra() - if (previousEra < currentEra) { - civInfo.addNotification("You have entered the [$currentEra era]!", null, Color.GOLD) + if (previousEra != currentEra) { + civInfo.addNotification("You have entered the [$currentEra]!", null, Color.GOLD) if (civInfo.isMajorCiv()) { for (knownCiv in civInfo.getKnownCivs()) { knownCiv.addNotification( - "[${civInfo.civName}] has entered the [$currentEra era]!", + "[${civInfo.civName}] has entered the [$currentEra]!", null, Color.BLUE ) diff --git a/core/src/com/unciv/logic/map/MapUnit.kt b/core/src/com/unciv/logic/map/MapUnit.kt index 417f7f0d20..c6ac9bfafe 100644 --- a/core/src/com/unciv/logic/map/MapUnit.kt +++ b/core/src/com/unciv/logic/map/MapUnit.kt @@ -570,7 +570,7 @@ class MapUnit { .filter { !civInfo.tech.isResearched(it.name) && civInfo.tech.canBeResearched(it.name) - && it.era() == TechEra.Ancient + && it.era() == Constants.ancientEra } if(researchableAncientEraTechs.isNotEmpty()) actions.add { diff --git a/core/src/com/unciv/logic/trade/TradeEvaluation.kt b/core/src/com/unciv/logic/trade/TradeEvaluation.kt index 36e7ea1f71..714be5a348 100644 --- a/core/src/com/unciv/logic/trade/TradeEvaluation.kt +++ b/core/src/com/unciv/logic/trade/TradeEvaluation.kt @@ -247,6 +247,6 @@ class TradeEvaluation{ } fun evaluateResearchAgreementCostForThem(ourCivilization: CivilizationInfo, otherCivilization: CivilizationInfo): Int { - return -100 * (ourCivilization.getEra().ordinal-otherCivilization.getEra().ordinal) + return -100 * (ourCivilization.getEraNumber()-otherCivilization.getEraNumber()) } } \ No newline at end of file diff --git a/core/src/com/unciv/models/metadata/GameParameters.kt b/core/src/com/unciv/models/metadata/GameParameters.kt index 067da731ff..bfb89ed414 100644 --- a/core/src/com/unciv/models/metadata/GameParameters.kt +++ b/core/src/com/unciv/models/metadata/GameParameters.kt @@ -1,5 +1,6 @@ package com.unciv.models.metadata +import com.unciv.Constants import com.unciv.logic.civilization.PlayerType import com.unciv.models.ruleset.VictoryType import com.unciv.models.ruleset.tech.TechEra @@ -18,7 +19,7 @@ class GameParameters { // Default values are the default new game var nuclearWeaponsEnabled = true var victoryTypes: ArrayList = VictoryType.values().toCollection(ArrayList()) // By default, all victory types - var startingEra = TechEra.Ancient + var startingEra = Constants.ancientEra var isOnlineMultiplayer = false var mods = LinkedHashSet() diff --git a/core/src/com/unciv/models/ruleset/PolicyBranch.kt b/core/src/com/unciv/models/ruleset/PolicyBranch.kt index 880b3415b7..71e2547b35 100644 --- a/core/src/com/unciv/models/ruleset/PolicyBranch.kt +++ b/core/src/com/unciv/models/ruleset/PolicyBranch.kt @@ -4,5 +4,5 @@ import com.unciv.models.ruleset.tech.TechEra class PolicyBranch : Policy() { var policies: ArrayList = arrayListOf() - lateinit var era: TechEra + lateinit var era: String } diff --git a/core/src/com/unciv/models/ruleset/Ruleset.kt b/core/src/com/unciv/models/ruleset/Ruleset.kt index 126150c08c..137204e508 100644 --- a/core/src/com/unciv/models/ruleset/Ruleset.kt +++ b/core/src/com/unciv/models/ruleset/Ruleset.kt @@ -166,6 +166,12 @@ class Ruleset { } } } + + fun getEras(): List { + return technologies.values.map { it.column!!.era }.distinct() + } + + fun getEraNumber(era:String) = getEras().indexOf(era) } /** Loading mods is expensive, so let's only do it once and diff --git a/core/src/com/unciv/models/ruleset/tech/TechColumn.kt b/core/src/com/unciv/models/ruleset/tech/TechColumn.kt index 1a0db7db1b..b62eed549c 100644 --- a/core/src/com/unciv/models/ruleset/tech/TechColumn.kt +++ b/core/src/com/unciv/models/ruleset/tech/TechColumn.kt @@ -4,7 +4,7 @@ import java.util.* class TechColumn { var columnNumber: Int = 0 - lateinit var era: TechEra + lateinit var era: String var techs = ArrayList() var techCost: Int = 0 var buildingCost: Int = 0 diff --git a/core/src/com/unciv/models/ruleset/tech/TechEra.kt b/core/src/com/unciv/models/ruleset/tech/TechEra.kt index 993153944b..ac554cb4cb 100644 --- a/core/src/com/unciv/models/ruleset/tech/TechEra.kt +++ b/core/src/com/unciv/models/ruleset/tech/TechEra.kt @@ -1,6 +1,6 @@ package com.unciv.models.ruleset.tech -enum class TechEra{ +enum class TechEra { Ancient, Classical, Medieval, diff --git a/core/src/com/unciv/ui/newgamescreen/NewGameScreenOptionsTable.kt b/core/src/com/unciv/ui/newgamescreen/NewGameScreenOptionsTable.kt index 274dbcc510..305cba3e69 100644 --- a/core/src/com/unciv/ui/newgamescreen/NewGameScreenOptionsTable.kt +++ b/core/src/com/unciv/ui/newgamescreen/NewGameScreenOptionsTable.kt @@ -160,8 +160,9 @@ class NewGameScreenOptionsTable(val newGameScreen: NewGameScreen, val updatePlay private fun addEraSelectBox() { // The eras enum values are "Medieval" etc. but are shown to the player as "Medieval era".tr() // because in other languages "Medieval era" is one word - addSelectBox("{Starting Era}:", TechEra.values().map { it.name + " era" }, newGameParameters.startingEra.name + " era") - {newGameParameters.startingEra = TechEra.valueOf(it.replace(" era", ""))} + val eras = ruleset.technologies.values.map { it.era() }.distinct() + addSelectBox("{Starting Era}:", eras, newGameParameters.startingEra) + { newGameParameters.startingEra = it } } diff --git a/core/src/com/unciv/ui/pickerscreens/TechPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/TechPickerScreen.kt index 18551870c9..6146e903e7 100644 --- a/core/src/com/unciv/ui/pickerscreens/TechPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/TechPickerScreen.kt @@ -82,18 +82,19 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec } private fun createTechTable() { - val columns = civInfo.gameInfo.ruleSet.technologies.values.map { it.column!!.columnNumber}.max()!! +1 + val allTechs = civInfo.gameInfo.ruleSet.technologies.values + val columns = allTechs.map { it.column!!.columnNumber}.max()!! +1 val techMatrix = Array>(columns) { arrayOfNulls(10) } // Divided into columns, then rows - for (technology in civInfo.gameInfo.ruleSet.technologies.values) { + for (technology in allTechs) { techMatrix[technology.column!!.columnNumber][technology.row - 1] = technology } - val erasName = arrayOf("Ancient","Classical","Medieval","Renaissance","Industrial","Modern","Information","Future") - for (i in 0..7) { - val j = if (erasName[i]!="Ancient" && erasName[i]!="Future") 2 else 3 - if (i%2==0) topTable.add((erasName[i]+" era").toLabel().addBorder(2f, Color.BLUE)).fill().colspan(j) - else topTable.add((erasName[i]+" era").toLabel().addBorder(2f, Color.FIREBRICK)).fill().colspan(j) + val erasName = allTechs.map { it.era() }.distinct() + for ((i,eraName) in erasName.withIndex()) { + val columnSpan = if (eraName != Constants.ancientEra && eraName != Constants.futureEra) 2 else 3 + val color = if (i % 2 == 0) Color.BLUE else Color.FIREBRICK + topTable.add(eraName.toLabel().addBorder(2f, color)).fill().colspan(columnSpan) } for (i in 0..9) { diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt index d7307fb0d9..f464a2d1ce 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt @@ -333,7 +333,7 @@ object UnitActions { uncivSound = UncivSound.Chimes, action = { // http://civilization.wikia.com/wiki/Great_Merchant_(Civ5) - var goldEarned = (350 + 50 * unit.civInfo.getEra().ordinal) * unit.civInfo.gameInfo.gameParameters.gameSpeed.modifier + var goldEarned = (350 + 50 * unit.civInfo.getEraNumber()) * unit.civInfo.gameInfo.gameParameters.gameSpeed.modifier if (unit.civInfo.policies.isAdopted("Commerce Complete")) goldEarned *= 2 unit.civInfo.gold += goldEarned.toInt()