Mass deprecation

This commit is contained in:
yairm210 2021-08-30 19:52:57 +03:00
parent b554a6db93
commit b0e3aa326b
8 changed files with 13 additions and 61 deletions

View File

@ -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()

View File

@ -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

View File

@ -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() }
}

View File

@ -55,18 +55,6 @@ open class TileInfo {
lateinit var baseTerrain: String
val terrainFeatures: ArrayList<String> = 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))

View File

@ -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()

View File

@ -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",

View File

@ -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<FormattedLine>()

View File

@ -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()