All era names changed to "... era" to fit in with what is actually translated and displayed

Removed Era enum - too restrictive to tech tree variations (atomic era, anyone?)
As a side bonus, mods can now add their own eras, that'll be interesting?
This commit is contained in:
Yair Morgenstern
2020-04-17 15:11:45 +03:00
parent 4c48cfe4f3
commit eba7dc8c8c
18 changed files with 78 additions and 61 deletions

View File

@ -1,7 +1,7 @@
[ [
{ {
"name": "Tradition", "name": "Tradition",
"era": "Ancient", "era": "Ancient era",
"effect": "+3 culture in capital and increased rate of border expansion", "effect": "+3 culture in capital and increased rate of border expansion",
"policies": [ "policies": [
{ {
@ -44,7 +44,7 @@
}, },
{ {
"name": "Liberty", "name": "Liberty",
"era": "Ancient", "era": "Ancient era",
"effect": "+1 culture in every city", "effect": "+1 culture in every city",
"policies": [ "policies": [
{ {
@ -88,7 +88,7 @@
}, },
{ {
"name": "Honor", "name": "Honor",
"era": "Ancient", "era": "Ancient era",
"effect": "+25% bonus vs Barbarians; gain Culture when you kill a barbarian unit", "effect": "+25% bonus vs Barbarians; gain Culture when you kill a barbarian unit",
"policies": [ "policies": [
{ {
@ -131,7 +131,7 @@
] ]
},{ },{
"name": "Piety", "name": "Piety",
"era": "Classical", "era": "Classical era",
"effect": "Building time of culture buildings reduced by 15%", "effect": "Building time of culture buildings reduced by 15%",
"policies": [ "policies": [
{ {
@ -174,7 +174,7 @@
] ]
},/*{ },/*{
"name": "Patronage", "name": "Patronage",
"era": "Classical", "era": "Classical era",
"effect": "Influence with City-States degrades 25% slower than normal", "effect": "Influence with City-States degrades 25% slower than normal",
"policies": [ "policies": [
{ {
@ -219,7 +219,7 @@
{ {
"name": "Commerce", "name": "Commerce",
"effect": "+25% gold in capital", "effect": "+25% gold in capital",
"era": "Medieval", "era": "Medieval era",
"policies": [ "policies": [
{ {
"name": "Trade Unions", "name": "Trade Unions",
@ -262,7 +262,7 @@
}, },
{ {
"name": "Rationalism", "name": "Rationalism",
"era": "Renaissance", "era": "Renaissance era",
"effect": "Production to science conversion in cities increased by 33%", "effect": "Production to science conversion in cities increased by 33%",
"policies": [ "policies": [
{ {
@ -306,7 +306,7 @@
}, },
/*{ /*{
"name": "Order", "name": "Order",
"era": "Industrial", "era": "Industrial era",
"effect": "+1 Happiness per City", "effect": "+1 Happiness per City",
"policies": [ "policies": [
{ {
@ -349,7 +349,7 @@
},*/ },*/
{ {
"name": "Freedom", "name": "Freedom",
"era": "Renaissance", "era": "Renaissance era",
"effect": "+25% great people rate", "effect": "+25% great people rate",
"policies": [ "policies": [
{ {
@ -392,7 +392,7 @@
}, },
{ {
"name": "Autocracy", "name": "Autocracy",
"era": "Industrial", "era": "Industrial era",
"effect": "-33% unit upkeep costs", "effect": "-33% unit upkeep costs",
"policies": [ "policies": [
{ {

View File

@ -1,7 +1,7 @@
[ [
{ {
"columnNumber": 0, "columnNumber": 0,
"era": "Ancient", "era": "Ancient era",
"techCost": 20, "techCost": 20,
"buildingCost": 40, "buildingCost": 40,
"techs": [ "techs": [
@ -15,7 +15,7 @@
}, },
{ {
"columnNumber": 1, "columnNumber": 1,
"era": "Ancient", "era": "Ancient era",
"techCost": 35, "techCost": 35,
"buildingCost": 60, "buildingCost": 60,
"techs": [ "techs": [
@ -48,7 +48,7 @@
}, },
{ {
"columnNumber": 2, "columnNumber": 2,
"era": "Ancient", "era": "Ancient era",
"techCost": 55, "techCost": 55,
"buildingCost": 75, "buildingCost": 75,
"wonderCost": 185, "wonderCost": 185,
@ -99,7 +99,7 @@
}, },
{ {
"columnNumber": 3, "columnNumber": 3,
"era": "Classical", "era": "Classical era",
"techCost": 105, "techCost": 105,
"buildingCost": 100, "buildingCost": 100,
"wonderCost": 250, "wonderCost": 250,
@ -134,7 +134,7 @@
}, },
{ {
"columnNumber": 4, "columnNumber": 4,
"era": "Classical", "era": "Classical era",
"techCost": 175, "techCost": 175,
"buildingCost": 120, "buildingCost": 120,
"wonderCost": 300, "wonderCost": 300,
@ -167,7 +167,7 @@
}, },
{ {
"columnNumber": 5, "columnNumber": 5,
"era": "Medieval", "era": "Medieval era",
"techCost": 275, "techCost": 275,
"buildingCost": 160, "buildingCost": 160,
"wonderCost": 400, "wonderCost": 400,
@ -202,7 +202,7 @@
}, },
{ {
"columnNumber": 6, "columnNumber": 6,
"era": "Medieval", "era": "Medieval era",
"techCost": 485, "techCost": 485,
"buildingCost": 200, "buildingCost": 200,
"wonderCost": 500, "wonderCost": 500,
@ -250,7 +250,7 @@
}, },
{ {
"columnNumber": 7, "columnNumber": 7,
"era": "Renaissance", "era": "Renaissance era",
"techCost": 780, "techCost": 780,
"buildingCost": 250, "buildingCost": 250,
"wonderCost": 625, "wonderCost": 625,
@ -290,7 +290,7 @@
}, },
{ {
"columnNumber": 8, "columnNumber": 8,
"era": "Renaissance", "era": "Renaissance era",
"techCost": 1150, "techCost": 1150,
"buildingCost": 300, "buildingCost": 300,
"wonderCost": 750, "wonderCost": 750,
@ -329,7 +329,7 @@
}, },
{ {
"columnNumber": 9, "columnNumber": 9,
"era": "Industrial", "era": "Industrial era",
"techCost": 1600, "techCost": 1600,
"buildingCost": 360, "buildingCost": 360,
"wonderCost": 920, "wonderCost": 920,
@ -374,7 +374,7 @@
}, },
{ {
"columnNumber": 10, "columnNumber": 10,
"era": "Industrial", "era": "Industrial era",
"techCost": 2350, "techCost": 2350,
"buildingCost": 500, "buildingCost": 500,
"wonderCost": 1060, "wonderCost": 1060,
@ -408,7 +408,7 @@
}, },
{ {
"columnNumber": 11, "columnNumber": 11,
"era": "Modern", "era": "Modern era",
"techCost": 3100, "techCost": 3100,
"buildingCost": 500, "buildingCost": 500,
"wonderCost": 1250, "wonderCost": 1250,
@ -447,7 +447,7 @@
}, },
{ {
"columnNumber": 12, "columnNumber": 12,
"era": "Modern", "era": "Modern era",
"techCost": 4100, "techCost": 4100,
"buildingCost": 500, "buildingCost": 500,
"wonderCost": 1250, "wonderCost": 1250,
@ -480,7 +480,7 @@
}, },
{ {
"columnNumber": 13, "columnNumber": 13,
"era": "Information", "era": "Information era",
"techCost": 5100, "techCost": 5100,
"buildingCost": 500, "buildingCost": 500,
"wonderCost": 1250, "wonderCost": 1250,
@ -513,7 +513,7 @@
}, },
{ {
"columnNumber": 14, "columnNumber": 14,
"era": "Information", "era": "Information era",
"techCost": 6400, "techCost": 6400,
"buildingCost": 750, "buildingCost": 750,
"wonderCost": 2000, "wonderCost": 2000,
@ -547,7 +547,7 @@
}, },
{ {
"columnNumber": 15, "columnNumber": 15,
"era": "Future", "era": "Future era",
"techCost": 7700, "techCost": 7700,
"buildingCost": 750, "buildingCost": 750,
"wonderCost": 1250, "wonderCost": 1250,
@ -581,7 +581,7 @@
{ {
"columnNumber": 16, "columnNumber": 16,
"era": "Future", "era": "Future era",
"techCost": 8800, "techCost": 8800,
"buildingCost": 750, "buildingCost": 750,
"wonderCost": 1250, "wonderCost": 1250,
@ -602,7 +602,7 @@
}, },
{ {
"columnNumber": 17, "columnNumber": 17,
"era": "Future", "era": "Future era",
"techCost": 9500, "techCost": 9500,
"buildingCost": 750, "buildingCost": 750,
"wonderCost": 1250, "wonderCost": 1250,

View File

@ -63,4 +63,7 @@ object Constants {
const val close = "Close" const val close = "Close"
const val scienceConversionEffect = "Production to science conversion in cities increased by 33%" const val scienceConversionEffect = "Production to science conversion in cities increased by 33%"
const val ancientEra="Ancient era"
const val futureEra="Future era"
} }

View File

@ -26,7 +26,8 @@ class MapUnitCombatant(val unit: MapUnit) : ICombatant {
} }
override fun getDefendingStrength(): Int { 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 return unit.baseUnit().strength
} }

View File

@ -81,7 +81,7 @@ class CivInfoStats(val civInfo: CivilizationInfo){
if (otherCiv.isCityState() && otherCiv.getCityStateType() == CityStateType.Cultured if (otherCiv.isCityState() && otherCiv.getCityStateType() == CityStateType.Cultured
&& otherCiv.getDiplomacyManager(civInfo.civName).relationshipLevel() >= RelationshipLevel.Friend) { && otherCiv.getDiplomacyManager(civInfo.civName).relationshipLevel() >= RelationshipLevel.Friend) {
val cultureBonus = Stats() val cultureBonus = Stats()
var culture = 3f * (civInfo.getEra().ordinal+1) var culture = 3f * (civInfo.getEraNumber()+1)
if(civInfo.nation.unique == UniqueAbility.FATHER_GOVERNS_CHILDREN) if(civInfo.nation.unique == UniqueAbility.FATHER_GOVERNS_CHILDREN)
culture*=1.5f culture*=1.5f
cultureBonus.add(Stat.Culture, culture) cultureBonus.add(Stat.Culture, culture)

View File

@ -2,6 +2,7 @@ package com.unciv.logic.civilization
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.math.Vector2 import com.badlogic.gdx.math.Vector2
import com.sun.xml.internal.bind.v2.runtime.reflect.opt.Const
import com.unciv.Constants import com.unciv.Constants
import com.unciv.JsonParser import com.unciv.JsonParser
import com.unciv.UncivGame import com.unciv.UncivGame
@ -268,13 +269,17 @@ class CivilizationInfo {
&& !isBarbarian() // Barbarians can be never defeated && !isBarbarian() // Barbarians can be never defeated
&& (citiesCreated > 0 || !getCivUnits().any { it.name == Constants.settler }) && (citiesCreated > 0 || !getCivUnits().any { it.name == Constants.settler })
fun getEra(): TechEra { fun getEra(): String {
val maxEraOfTech = tech.researchedTechnologies val maxEraOfTech = tech.researchedTechnologies
.asSequence() .asSequence()
.map { it.era() } .map { it.column!! }
.max() .maxBy { it.columnNumber }!!
if(maxEraOfTech!=null) return maxEraOfTech .era
else return TechEra.Ancient return maxEraOfTech
}
fun getEraNumber(): Int {
return gameInfo.ruleSet.getEraNumber(getEra())
} }
fun isAtWarWith(otherCiv:CivilizationInfo): Boolean { fun isAtWarWith(otherCiv:CivilizationInfo): Boolean {
@ -518,12 +523,11 @@ class CivilizationInfo {
fun getResearchAgreementCost(otherCiv: CivilizationInfo): Int { fun getResearchAgreementCost(otherCiv: CivilizationInfo): Int {
// https://forums.civfanatics.com/resources/research-agreements-bnw.25568/ // https://forums.civfanatics.com/resources/research-agreements-bnw.25568/
val highestEra = sequenceOf(getEra(),otherCiv.getEra()).maxBy { it.ordinal }!! val basicGoldCostOfSignResearchAgreement = when(getEra()){
val basicGoldCostOfSignResearchAgreement = when(highestEra){ "Medieval era", "Renaissance era" -> 250
TechEra.Medieval, TechEra.Renaissance -> 250 "Industrial era" -> 300
TechEra.Industrial -> 300 "Modern era" -> 350
TechEra.Modern -> 350 "Information era", Constants.futureEra -> 400
TechEra.Information, TechEra.Future -> 400
else -> 0 else -> 0
} }
return (basicGoldCostOfSignResearchAgreement * gameInfo.gameParameters.gameSpeed.modifier).toInt() return (basicGoldCostOfSignResearchAgreement * gameInfo.gameParameters.gameSpeed.modifier).toInt()

View File

@ -86,7 +86,7 @@ class PolicyManager {
if(isAdopted(policy.name)) return false if(isAdopted(policy.name)) return false
if (policy.name.endsWith("Complete")) return false if (policy.name.endsWith("Complete")) return false
if (!getAdoptedPolicies().containsAll(policy.requires!!)) 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 return true
} }

View File

@ -223,12 +223,12 @@ class TechManager {
civInfo.popupAlerts.add(PopupAlert(AlertType.TechResearched,techName)) civInfo.popupAlerts.add(PopupAlert(AlertType.TechResearched,techName))
val currentEra = civInfo.getEra() val currentEra = civInfo.getEra()
if (previousEra < currentEra) { if (previousEra != currentEra) {
civInfo.addNotification("You have entered the [$currentEra era]!", null, Color.GOLD) civInfo.addNotification("You have entered the [$currentEra]!", null, Color.GOLD)
if (civInfo.isMajorCiv()) { if (civInfo.isMajorCiv()) {
for (knownCiv in civInfo.getKnownCivs()) { for (knownCiv in civInfo.getKnownCivs()) {
knownCiv.addNotification( knownCiv.addNotification(
"[${civInfo.civName}] has entered the [$currentEra era]!", "[${civInfo.civName}] has entered the [$currentEra]!",
null, null,
Color.BLUE Color.BLUE
) )

View File

@ -570,7 +570,7 @@ class MapUnit {
.filter { .filter {
!civInfo.tech.isResearched(it.name) !civInfo.tech.isResearched(it.name)
&& civInfo.tech.canBeResearched(it.name) && civInfo.tech.canBeResearched(it.name)
&& it.era() == TechEra.Ancient && it.era() == Constants.ancientEra
} }
if(researchableAncientEraTechs.isNotEmpty()) if(researchableAncientEraTechs.isNotEmpty())
actions.add { actions.add {

View File

@ -247,6 +247,6 @@ class TradeEvaluation{
} }
fun evaluateResearchAgreementCostForThem(ourCivilization: CivilizationInfo, otherCivilization: CivilizationInfo): Int { fun evaluateResearchAgreementCostForThem(ourCivilization: CivilizationInfo, otherCivilization: CivilizationInfo): Int {
return -100 * (ourCivilization.getEra().ordinal-otherCivilization.getEra().ordinal) return -100 * (ourCivilization.getEraNumber()-otherCivilization.getEraNumber())
} }
} }

View File

@ -1,5 +1,6 @@
package com.unciv.models.metadata package com.unciv.models.metadata
import com.unciv.Constants
import com.unciv.logic.civilization.PlayerType import com.unciv.logic.civilization.PlayerType
import com.unciv.models.ruleset.VictoryType import com.unciv.models.ruleset.VictoryType
import com.unciv.models.ruleset.tech.TechEra import com.unciv.models.ruleset.tech.TechEra
@ -18,7 +19,7 @@ class GameParameters { // Default values are the default new game
var nuclearWeaponsEnabled = true var nuclearWeaponsEnabled = true
var victoryTypes: ArrayList<VictoryType> = VictoryType.values().toCollection(ArrayList()) // By default, all victory types var victoryTypes: ArrayList<VictoryType> = VictoryType.values().toCollection(ArrayList()) // By default, all victory types
var startingEra = TechEra.Ancient var startingEra = Constants.ancientEra
var isOnlineMultiplayer = false var isOnlineMultiplayer = false
var mods = LinkedHashSet<String>() var mods = LinkedHashSet<String>()

View File

@ -4,5 +4,5 @@ import com.unciv.models.ruleset.tech.TechEra
class PolicyBranch : Policy() { class PolicyBranch : Policy() {
var policies: ArrayList<Policy> = arrayListOf() var policies: ArrayList<Policy> = arrayListOf()
lateinit var era: TechEra lateinit var era: String
} }

View File

@ -166,6 +166,12 @@ class Ruleset {
} }
} }
} }
fun getEras(): List<String> {
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 /** Loading mods is expensive, so let's only do it once and

View File

@ -4,7 +4,7 @@ import java.util.*
class TechColumn { class TechColumn {
var columnNumber: Int = 0 var columnNumber: Int = 0
lateinit var era: TechEra lateinit var era: String
var techs = ArrayList<Technology>() var techs = ArrayList<Technology>()
var techCost: Int = 0 var techCost: Int = 0
var buildingCost: Int = 0 var buildingCost: Int = 0

View File

@ -160,8 +160,9 @@ class NewGameScreenOptionsTable(val newGameScreen: NewGameScreen, val updatePlay
private fun addEraSelectBox() { private fun addEraSelectBox() {
// The eras enum values are "Medieval" etc. but are shown to the player as "Medieval era".tr() // 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 // because in other languages "Medieval era" is one word
addSelectBox("{Starting Era}:", TechEra.values().map { it.name + " era" }, newGameParameters.startingEra.name + " era") val eras = ruleset.technologies.values.map { it.era() }.distinct()
{newGameParameters.startingEra = TechEra.valueOf(it.replace(" era", ""))} addSelectBox("{Starting Era}:", eras, newGameParameters.startingEra)
{ newGameParameters.startingEra = it }
} }

View File

@ -82,18 +82,19 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
} }
private fun createTechTable() { 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<Array<Technology?>>(columns) { arrayOfNulls(10) } // Divided into columns, then rows val techMatrix = Array<Array<Technology?>>(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 techMatrix[technology.column!!.columnNumber][technology.row - 1] = technology
} }
val erasName = arrayOf("Ancient","Classical","Medieval","Renaissance","Industrial","Modern","Information","Future") val erasName = allTechs.map { it.era() }.distinct()
for (i in 0..7) { for ((i,eraName) in erasName.withIndex()) {
val j = if (erasName[i]!="Ancient" && erasName[i]!="Future") 2 else 3 val columnSpan = if (eraName != Constants.ancientEra && eraName != Constants.futureEra) 2 else 3
if (i%2==0) topTable.add((erasName[i]+" era").toLabel().addBorder(2f, Color.BLUE)).fill().colspan(j) val color = if (i % 2 == 0) Color.BLUE else Color.FIREBRICK
else topTable.add((erasName[i]+" era").toLabel().addBorder(2f, Color.FIREBRICK)).fill().colspan(j) topTable.add(eraName.toLabel().addBorder(2f, color)).fill().colspan(columnSpan)
} }
for (i in 0..9) { for (i in 0..9) {

View File

@ -333,7 +333,7 @@ object UnitActions {
uncivSound = UncivSound.Chimes, uncivSound = UncivSound.Chimes,
action = { action = {
// http://civilization.wikia.com/wiki/Great_Merchant_(Civ5) // 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")) if (unit.civInfo.policies.isAdopted("Commerce Complete"))
goldEarned *= 2 goldEarned *= 2
unit.civInfo.gold += goldEarned.toInt() unit.civInfo.gold += goldEarned.toInt()