diff --git a/android/assets/jsons/Techs.json b/android/assets/jsons/Techs.json index cf114d2a..a53f1d63 100644 --- a/android/assets/jsons/Techs.json +++ b/android/assets/jsons/Techs.json @@ -93,6 +93,7 @@ cost:85, row:1, prerequisites:["Sailing"], + uniques:["Enables embarkation for land units"] }, { name:"Horseback Riding", @@ -161,7 +162,7 @@ name:"Guilds", row:7, prerequisites:["Currency"], - baseDescription:"Enables conversion of city production to gold" + uniques:["Enables conversion of city production to gold"] }, { name:"Metal Casting", @@ -186,7 +187,7 @@ name:"Education", row:3, prerequisites:["Theology","Civil Service"], - baseDescription:"Enables conversion of city production to science" + uniques:["Enables conversion of city production to science"] }, { name:"Chivalry", @@ -197,7 +198,7 @@ name:"Machinery", row:8, prerequisites:["Guilds","Engineering"], - baseDescription:"Improves movement speed on roads" + uniques:["Improves movement speed on roads"] }, { name:"Physics", @@ -221,7 +222,7 @@ { name:"Astronomy", row:2, - baseDescription:"Increases embarked movement +1", + uniques:["Increases embarked movement +1","Enables embarked units to enter ocean tiles"], prerequisites:["Compass","Education"] }, { @@ -339,7 +340,7 @@ { name:"Steam Power", row:7, - baseDescription:"Increases embarked movement +1", + uniques:["Increases embarked movement +1"], prerequisites:["Industrialization","Scientific Theory","Rifling"] }, { @@ -419,7 +420,7 @@ name:"Computers", row:5, prerequisites:["Mass Media"], - baseDescription:"+10% science and production in all cities" + uniques:["+10% science and production in all cities"] }, { name:"Nuclear Fission", @@ -486,7 +487,7 @@ name:"Future Tech", row:5, prerequisites:["Nanotechnology","Particle Physics","Satellites"], - baseDescription:"Who knows what the future holds?" + uniques:["Who knows what the future holds?"] } ] } diff --git a/core/src/com/unciv/logic/city/CityStats.kt b/core/src/com/unciv/logic/city/CityStats.kt index 2b265122..8c6a0174 100644 --- a/core/src/com/unciv/logic/city/CityStats.kt +++ b/core/src/com/unciv/logic/city/CityStats.kt @@ -58,7 +58,10 @@ class CityStats { private fun getStatPercentBonusesFromRailroad(): Stats { val stats = Stats() - if (cityInfo.civInfo.tech.isResearched("Combustion") + val techEnablingRailroad = GameBasics.TileImprovements["Railroad"]!!.techRequired!! + // If we conquered enemy cities connected by railroad, but we don't yet have that tech, + // we shouldn't get bonuses, it's as if the tracks aare layed out but we can't operate them. + if (cityInfo.civInfo.tech.isResearched(techEnablingRailroad) && (cityInfo.isCapital() || isConnectedToCapital(RoadStatus.Railroad))) stats.production += 25f return stats @@ -79,7 +82,7 @@ class CityStats { private fun getStatPercentBonusesFromComputers(): Stats { val stats = Stats() - if (cityInfo.civInfo.tech.isResearched("Computers")) { + if (cityInfo.civInfo.tech.getUniques().contains("+10% science and production in all cities")) { stats.production += 10f stats.science += 10f } diff --git a/core/src/com/unciv/logic/city/IConstruction.kt b/core/src/com/unciv/logic/city/IConstruction.kt index 6a04117c..21fab516 100644 --- a/core/src/com/unciv/logic/city/IConstruction.kt +++ b/core/src/com/unciv/logic/city/IConstruction.kt @@ -18,12 +18,12 @@ open class SpecialConstruction(override var name: String, override val descripti fun getSpecialConstructions(): List { val science = object:SpecialConstruction("Science", "Convert production to science at a rate of 4 to 1"){ override fun isBuildable(construction: CityConstructions): Boolean { - return construction.cityInfo.civInfo.tech.isResearched("Education") + return construction.cityInfo.civInfo.tech.getUniques().contains("Enables conversion of city production to science") } } val gold = object:SpecialConstruction("Gold", "Convert production to gold at a rate of 4 to 1"){ override fun isBuildable(construction: CityConstructions): Boolean { - return construction.cityInfo.civInfo.tech.isResearched("Guilds") + return construction.cityInfo.civInfo.tech.getUniques().contains("Enables conversion of city production to gold") } } val idle = object:SpecialConstruction("Nothing", "The city will not produce anything."){ diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index 1f501c40..1ffb0f77 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -48,7 +48,6 @@ class CivilizationInfo { constructor(civName: String, gameInfo: GameInfo) { this.civName = civName -// this.gameInfo = gameInfo // already happens in setTransients tech.techsResearched.add("Agriculture") } @@ -236,7 +235,7 @@ class CivilizationInfo { fun isDefeated()= cities.isEmpty() && !getCivUnits().any{it.name=="Settler"} fun getEra(): TechEra { - val maxEraOfTech = tech.techsResearched.map { GameBasics.Technologies[it]!! } + val maxEraOfTech = tech.getResearchedTechs() .map { it.era() } .max() if(maxEraOfTech!=null) return maxEraOfTech diff --git a/core/src/com/unciv/logic/civilization/TechManager.kt b/core/src/com/unciv/logic/civilization/TechManager.kt index 5185d08c..c9850e43 100644 --- a/core/src/com/unciv/logic/civilization/TechManager.kt +++ b/core/src/com/unciv/logic/civilization/TechManager.kt @@ -56,6 +56,11 @@ class TechManager { fun canBeResearched(TechName: String): Boolean { return GameBasics.Technologies[TechName]!!.prerequisites.all { isResearched(it) } } + + fun getResearchedTechs() = techsResearched.map { GameBasics.Technologies[it]!! } + + fun getUniques() = getResearchedTechs().flatMap { it.uniques } + //endregion fun nextTurn(scienceForNewTurn: Int) { diff --git a/core/src/com/unciv/logic/map/MapUnit.kt b/core/src/com/unciv/logic/map/MapUnit.kt index 32e2327d..5e8b6983 100644 --- a/core/src/com/unciv/logic/map/MapUnit.kt +++ b/core/src/com/unciv/logic/map/MapUnit.kt @@ -109,9 +109,10 @@ class MapUnit { fun canPassThrough(tile: TileInfo):Boolean{ val tileOwner = tile.getOwner() if(tile.isWater() && baseUnit.unitType.isLandUnit()){ - if(!civInfo.tech.isResearched("Optics")) + val techUniques = civInfo.tech.getUniques() + if(!techUniques.contains("Enables embarkation for land units")) return false - if(tile.baseTerrain == "Ocean" && !civInfo.tech.isResearched("Astronomy")) + if(tile.baseTerrain == "Ocean" && !techUniques.contains("Enables embarked units to enter ocean tiles")) return false } if(tile.isLand() && baseUnit.unitType.isWaterUnit()) @@ -167,8 +168,7 @@ class MapUnit { fun getEmbarkedMovement(): Int { var movement=2 - movement += civInfo.tech.techsResearched.map { GameBasics.Technologies[it]!! } - .count { it.baseDescription!=null && it.baseDescription!! == "Increases embarked movement +1" } + movement += civInfo.tech.getUniques().count { it == "Increases embarked movement +1" } return movement } diff --git a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt index de0309cb..3c7356ab 100644 --- a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt +++ b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt @@ -16,7 +16,7 @@ class UnitMovementAlgorithms(val unit:MapUnit) { if (from.roadStatus !== RoadStatus.None && to.roadStatus !== RoadStatus.None) //Road { - if (unit.civInfo.tech.isResearched("Machinery")) return 1 / 3f + if (unit.civInfo.tech.getUniques().contains("Improves movement speed on roads")) return 1 / 3f else return 1 / 2f } if (unit.hasUnique("Ignores terrain cost")) return 1f diff --git a/core/src/com/unciv/models/gamebasics/tech/Technology.kt b/core/src/com/unciv/models/gamebasics/tech/Technology.kt index ccfd7bd2..cffa145c 100644 --- a/core/src/com/unciv/models/gamebasics/tech/Technology.kt +++ b/core/src/com/unciv/models/gamebasics/tech/Technology.kt @@ -10,7 +10,7 @@ class Technology : ICivilopedia { override val description: String get(){ val SB=StringBuilder() - if(baseDescription!=null) SB.appendln(baseDescription!!.tr()) + for(unique in uniques) SB.appendln(unique.tr()) val improvedImprovements = GameBasics.TileImprovements.values.filter { it.improvingTech==name }.groupBy { it.improvingTechStats.toString() } for (improvement in improvedImprovements) { @@ -42,9 +42,9 @@ class Technology : ICivilopedia { } lateinit var name: String - var baseDescription: String? = null var cost: Int = 0 var prerequisites = HashSet() + var uniques = ArrayList() var column: TechColumn? = null // The column that this tech is in the tech tree var row: Int = 0