From b0e3aa326b5db8e44504b65e6ac7c9a622f5629b Mon Sep 17 00:00:00 2001 From: yairm210 Date: Mon, 30 Aug 2021 19:52:57 +0300 Subject: [PATCH] Mass deprecation --- core/src/com/unciv/logic/GameInfo.kt | 8 ------- .../automation/ConstructionAutomation.kt | 2 +- core/src/com/unciv/logic/map/MapUnit.kt | 23 ++++++------------- core/src/com/unciv/logic/map/TileInfo.kt | 20 +--------------- .../src/com/unciv/logic/map/UnitPromotions.kt | 3 +-- core/src/com/unciv/models/UnitAction.kt | 3 --- core/src/com/unciv/models/ruleset/Building.kt | 7 +----- .../com/unciv/models/ruleset/unit/BaseUnit.kt | 8 ++----- 8 files changed, 13 insertions(+), 61 deletions(-) diff --git a/core/src/com/unciv/logic/GameInfo.kt b/core/src/com/unciv/logic/GameInfo.kt index 4058a3d15a..78a817e63a 100644 --- a/core/src/com/unciv/logic/GameInfo.kt +++ b/core/src/com/unciv/logic/GameInfo.kt @@ -286,14 +286,6 @@ class GameInfo { if (missingMods.isNotEmpty()) { throw UncivShowableException("Missing mods: [$missingMods]") } - - // compatibility code translating changed tech name "Railroad" - to be deprecated soon - val (oldTechName, newTechName) = "Railroad" to "Railroads" - if (ruleSet.technologies[oldTechName] == null && ruleSet.technologies[newTechName] != null) { - civilizations.forEach { - it.tech.replaceUpdatedTechName(oldTechName, newTechName) - } - } removeMissingModReferences() diff --git a/core/src/com/unciv/logic/automation/ConstructionAutomation.kt b/core/src/com/unciv/logic/automation/ConstructionAutomation.kt index 56ca42699c..ecf9ce807b 100644 --- a/core/src/com/unciv/logic/automation/ConstructionAutomation.kt +++ b/core/src/com/unciv/logic/automation/ConstructionAutomation.kt @@ -222,7 +222,7 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){ private fun addUnitTrainingBuildingChoice() { val unitTrainingBuilding = buildableNotWonders.asSequence() - .filter { it.xpForNewUnits > 0 }.minByOrNull { it.cost } + .filter { it.hasUnique("New [] units start with [] Experience []") }.minByOrNull { it.cost } if (unitTrainingBuilding != null && (preferredVictoryType != VictoryType.Cultural || isAtWar)) { var modifier = if (cityIsOverAverageProduction) 0.5f else 0.1f // You shouldn't be cranking out units anytime soon if (isAtWar) modifier *= 2 diff --git a/core/src/com/unciv/logic/map/MapUnit.kt b/core/src/com/unciv/logic/map/MapUnit.kt index 1b61f0c21e..2056733f65 100644 --- a/core/src/com/unciv/logic/map/MapUnit.kt +++ b/core/src/com/unciv/logic/map/MapUnit.kt @@ -309,9 +309,6 @@ class MapUnit { if (getTile().improvementInProgress != null && canBuildImprovement(getTile().getTileImprovementInProgress()!!)) return false - // unique "Can construct roads" deprecated since 3.15.5 - if (hasUnique("Can construct roads") && currentTile.improvementInProgress == RoadStatus.Road.name) return false - // return !(isFortified() || isExploring() || isSleeping() || isAutomated() || isMoving()) } @@ -616,8 +613,7 @@ class MapUnit { fun endTurn() { doAction() - if (currentMovement > 0 && - // Constants.workerUnique deprecated since 3.15.5 + if (currentMovement > 0 && getTile().improvementInProgress != null && canBuildImprovement(getTile().getTileImprovementInProgress()!!) ) workOnImprovement() @@ -824,10 +820,7 @@ class MapUnit { fun canIntercept(): Boolean { if (interceptChance() == 0) return false val maxAttacksPerTurn = 1 + - getMatchingUniques("[] extra interceptions may be made per turn").sumBy { it.params[0].toInt() } + - // Deprecated since 3.15.7 - getMatchingUniques("1 extra interception may be made per turn").count() - // + getMatchingUniques("[] extra interceptions may be made per turn").sumBy { it.params[0].toInt() } if (attacksThisTurn >= maxAttacksPerTurn) return false return true } @@ -843,11 +836,10 @@ class MapUnit { } fun carryCapacity(unit: MapUnit): Int { - var capacity = getMatchingUniques("Can carry [] [] units").filter { unit.matchesFilter(it.params[1]) }.sumBy { it.params[0].toInt() } - capacity += getMatchingUniques("Can carry [] extra [] units").filter { unit.matchesFilter(it.params[1]) }.sumBy { it.params[0].toInt() } - // Deprecated since 3.15.5 - capacity += getMatchingUniques("Can carry 2 aircraft").filter { unit.matchesFilter("Air") }.sumBy { 2 } - capacity += getMatchingUniques("Can carry 1 extra aircraft").filter { unit.matchesFilter("Air") }.sumBy { 1 } + var capacity = getMatchingUniques("Can carry [] [] units").filter { unit.matchesFilter(it.params[1]) } + .sumBy { it.params[0].toInt() } + capacity += getMatchingUniques("Can carry [] extra [] units").filter { unit.matchesFilter(it.params[1]) } + .sumBy { it.params[0].toInt() } return capacity } @@ -860,8 +852,7 @@ class MapUnit { } fun interceptDamagePercentBonus(): Int { - // "Bonus when intercepting []%" deprecated since 3.15.7 - return getUniques().filter { it.placeholderText == "Bonus when intercepting []%" || it.placeholderText == "[]% Damage when intercepting"} + return getUniques().filter { it.placeholderText == "[]% Damage when intercepting"} .sumBy { it.params[0].toInt() } } diff --git a/core/src/com/unciv/logic/map/TileInfo.kt b/core/src/com/unciv/logic/map/TileInfo.kt index 358635d8fb..9026c9a90e 100644 --- a/core/src/com/unciv/logic/map/TileInfo.kt +++ b/core/src/com/unciv/logic/map/TileInfo.kt @@ -55,18 +55,6 @@ open class TileInfo { lateinit var baseTerrain: String val terrainFeatures: ArrayList = ArrayList() - // Deprecation level can't be increased because of convertTerrainFeatureToArray - // Can't be flagged transient because it won't deserialize then - // but it should not serialize because it always has the default value on serialization and is flagged optional - // Can be removed together with convertTerrainFeatureToArray to drop support for save files from version 3.13.7 and below - @Deprecated(message = "Since 3.13.7 - replaced by terrainFeatures") - private var terrainFeature: String? = null - private fun convertTerrainFeatureToArray() { - if (terrainFeature != null) { - terrainFeatures.add(terrainFeature!!) - terrainFeature = null - } - } var naturalWonder: String? = null var resource: String? = null @@ -94,7 +82,6 @@ open class TileInfo { for (airUnit in airUnits) toReturn.airUnits.add(airUnit.clone()) toReturn.position = position.cpy() toReturn.baseTerrain = baseTerrain - convertTerrainFeatureToArray() toReturn.terrainFeatures.addAll(terrainFeatures) toReturn.naturalWonder = naturalWonder toReturn.resource = resource @@ -331,7 +318,7 @@ open class TileInfo { stats.add(unique.stats) if (city != null) { - var tileUniques = city.getMatchingUniques("[] from [] tiles []") + val tileUniques = city.getMatchingUniques("[] from [] tiles []") .filter { city.matchesFilter(it.params[2]) } val improvementUniques = improvement.uniqueObjects.filter { it.placeholderText == "[] on [] tiles once [] is discovered" @@ -401,10 +388,6 @@ open class TileInfo { return when { improvement.name == this.improvement -> false isCityCenter() -> false - // deprecated as of 3.15.15 - "Cannot be built on bonus resource" in improvement.uniques && resource != null - && getTileResource().resourceType == ResourceType.Bonus -> false - // improvement.uniqueObjects.filter { it.placeholderText == "Cannot be built on [] tiles" }.any { unique -> matchesTerrainFilter(unique.params[0]) } -> false @@ -672,7 +655,6 @@ open class TileInfo { } fun setTerrainTransients() { - convertTerrainFeatureToArray() // Uninitialized tilemap - when you're displaying a tile in the civilopedia or map editor if (::tileMap.isInitialized) convertHillToTerrainFeature() if (!ruleset.terrains.containsKey(baseTerrain)) diff --git a/core/src/com/unciv/logic/map/UnitPromotions.kt b/core/src/com/unciv/logic/map/UnitPromotions.kt index 0f215fb9ac..b848abfd0e 100644 --- a/core/src/com/unciv/logic/map/UnitPromotions.kt +++ b/core/src/com/unciv/logic/map/UnitPromotions.kt @@ -40,8 +40,7 @@ class UnitPromotions { val promotion = unit.civInfo.gameInfo.ruleSet.unitPromotions[promotionName]!! doDirectPromotionEffects(promotion) - // This usage of a promotion name as its identifier is deprecated since 3.15.6 - if (promotionName != "Heal Instantly" && promotion.uniqueObjects.none { it.placeholderText == "Doing so will consume this opportunity to choose a Promotion" }) + if (promotion.uniqueObjects.none { it.placeholderText == "Doing so will consume this opportunity to choose a Promotion" }) promotions.add(promotionName) unit.updateUniques() diff --git a/core/src/com/unciv/models/UnitAction.kt b/core/src/com/unciv/models/UnitAction.kt index db99ab96d4..c85ebc2e36 100644 --- a/core/src/com/unciv/models/UnitAction.kt +++ b/core/src/com/unciv/models/UnitAction.kt @@ -109,9 +109,6 @@ enum class UnitActionType( { ImageGetter.getUnitIcon(Constants.settler) }, 'c', UncivSound.Silent), ConstructImprovement("Construct improvement", { ImageGetter.getUnitIcon(Constants.worker) }, 'i'), - // Deprecated since 3.15.4 - ConstructRoad("Construct road", {ImageGetter.getImprovementIcon("Road")}, 'r'), - // Create("Create", null, 'i', UncivSound.Chimes), HurryResearch("Hurry Research", diff --git a/core/src/com/unciv/models/ruleset/Building.kt b/core/src/com/unciv/models/ruleset/Building.kt index b5d4b4e165..a9a2ae18ef 100644 --- a/core/src/com/unciv/models/ruleset/Building.kt +++ b/core/src/com/unciv/models/ruleset/Building.kt @@ -63,8 +63,6 @@ class Building : NamedStats(), INonPerpetualConstruction, ICivilopediaText { private var cannotBeBuiltWith: String? = null var cityStrength = 0 var cityHealth = 0 - @Deprecated("As of 3.15.16, replace with 'New [Military] units start with [15] Experience [in this city]'") - var xpForNewUnits = 0 var replaces: String? = null var uniqueTo: String? = null var quote: String = "" @@ -92,7 +90,6 @@ class Building : NamedStats(), INonPerpetualConstruction, ICivilopediaText { } if (cityStrength != 0) infoList += "{City strength} +$cityStrength" if (cityHealth != 0) infoList += "{City health} +$cityHealth" - if (xpForNewUnits != 0) infoList += "+$xpForNewUnits {XP for new units}" return infoList.joinToString("; ") { it.tr() } } @@ -157,7 +154,6 @@ class Building : NamedStats(), INonPerpetualConstruction, ICivilopediaText { if (cityStrength != 0) lines += "{City strength} +$cityStrength" if (cityHealth != 0) lines += "{City health} +$cityHealth" - if (xpForNewUnits != 0) lines += "+$xpForNewUnits {XP for new units}" if (maintenance != 0) lines += "{Maintenance cost}: $maintenance {Gold}" return lines.joinToString("\n") { it.tr() }.trim() } @@ -346,10 +342,9 @@ class Building : NamedStats(), INonPerpetualConstruction, ICivilopediaText { } } - if (cityStrength != 0 || cityHealth != 0 || xpForNewUnits != 0 || maintenance != 0) textList += FormattedLine() + if (cityStrength != 0 || cityHealth != 0 || maintenance != 0) textList += FormattedLine() if (cityStrength != 0) textList += FormattedLine("{City strength} +$cityStrength") if (cityHealth != 0) textList += FormattedLine("{City health} +$cityHealth") - if (xpForNewUnits != 0) textList += FormattedLine("+$xpForNewUnits {XP for new units}") if (maintenance != 0) textList += FormattedLine("{Maintenance cost}: $maintenance {Gold}") val seeAlso = ArrayList() diff --git a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt index bb5d27394e..3e1e29f557 100644 --- a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt +++ b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt @@ -338,15 +338,11 @@ class BaseUnit : INamed, INonPerpetualConstruction, ICivilopediaText { fun addConstructionBonuses(unit: MapUnit, cityConstructions: CityConstructions) { val civInfo = cityConstructions.cityInfo.civInfo - var XP = cityConstructions.getBuiltBuildings().sumBy { it.xpForNewUnits } + var XP = 0 for (unique in cityConstructions.cityInfo.getMatchingUniques("New [] units start with [] Experience []") - .filter { cityConstructions.cityInfo.matchesFilter(it.params[2]) } + - // Deprecated since 3.15.9 - cityConstructions.cityInfo.getMatchingUniques("New [] units start with [] Experience") + - cityConstructions.cityInfo.getLocalMatchingUniques("New [] units start with [] Experience in this city") - // + .filter { cityConstructions.cityInfo.matchesFilter(it.params[2]) } ) { if (unit.matchesFilter(unique.params[0])) XP += unique.params[1].toInt()