Deprecation of old uniques and fields

This commit is contained in:
Yair Morgenstern 2021-07-02 00:05:28 +03:00
parent afdc2ffbd5
commit 43ff2ea5f9
9 changed files with 6 additions and 60 deletions

View File

@ -6,7 +6,6 @@ import com.unciv.logic.automation.NextTurnAutomation
import com.unciv.logic.city.CityConstructions
import com.unciv.logic.city.PerpetualConstruction
import com.unciv.logic.civilization.*
import com.unciv.logic.map.MapSizeNew
import com.unciv.logic.map.TileInfo
import com.unciv.logic.map.TileMap
import com.unciv.models.metadata.GameParameters
@ -278,12 +277,6 @@ class GameInfo {
if (currentPlayer == "") currentPlayer = civilizations.first { it.isPlayerCivilization() }.civName
currentPlayerCiv = getCivilization(currentPlayer)
// as of version 3.9.18, added new custom map size
// empty mapSize name and non-custom map type means - it is old style map size,
// therefore we need to create new mapSize property
if (tileMap.mapParameters.mapSize.name == "" && tileMap.mapParameters.type != Constants.custom)
tileMap.mapParameters.mapSize = MapSizeNew(tileMap.mapParameters.size.name)
// this is separated into 2 loops because when we activate updateVisibleTiles in civ.setTransients,
// we try to find new civs, and we check if civ is barbarian, which we can't know unless the gameInfo is already set.
for (civInfo in civilizations) civInfo.gameInfo = this

View File

@ -98,11 +98,6 @@ object BattleDamage {
if (enemy.getCivInfo().isBarbarian()) {
modifiers["Difficulty"] =
(civInfo.gameInfo.getDifficulty().barbarianBonus * 100).toInt()
// Deprecated since 3.14.17
if (civInfo.hasUnique("+25% bonus vs Barbarians")) {
modifiers["vs Barbarians (deprecated)"] = 25
}
//
}
return modifiers

View File

@ -84,9 +84,6 @@ class CityConstructions {
"[] per [] population []" -> if (cityInfo.matchesFilter(unique.params[2]))
stats.add(unique.stats.times(cityInfo.population.population / unique.params[1].toFloat()))
"[] once [] is discovered" -> if (cityInfo.civInfo.tech.isResearched(unique.params[1])) stats.add(unique.stats)
// Deprecated since 3.14.17, left for modding compatibility
"[] Per [] Population in this city" ->
stats.add(unique.stats.times(cityInfo.population.population / unique.params[1].toFloat()))
}
return stats

View File

@ -120,8 +120,6 @@ class MapParameters {
var name = ""
var type = MapType.pangaea
var shape = MapShape.hexagonal
@Deprecated("replaced by mapSize since 3.14.7")
var size = MapSize.Medium
var mapSize = MapSizeNew(MapSize.Medium)
var noRuins = false
var noNaturalWonders = false

View File

@ -146,11 +146,6 @@ class MapUnit {
// Deprecated since 3.15.6
movement += getUniques().count { it.text == "+1 Movement" }
//
// Deprecated since 3.14.17
if (type.isMilitary() && type.isWaterUnit() && civInfo.hasUnique("All military naval units receive +1 movement and +1 sight")) {
movement += 1
}
//
for (unique in civInfo.getMatchingUniques("+[] Movement for all [] units"))
if (matchesFilter(unique.params[1]))
@ -224,11 +219,7 @@ class MapUnit {
if (civInfo.hasUnique("+1 Sight for all land military units") && type.isMilitary() && type.isLandUnit())
visibilityRange += 1
//
// Deprecated since 3.14.17
if (type.isMilitary() && type.isWaterUnit() && civInfo.hasUnique("All military naval units receive +1 movement and +1 sight"))
visibilityRange += 1
//
for (unique in getTile().getAllTerrains().flatMap { it.uniqueObjects })
if (unique.placeholderText == "[] Sight for [] units" && matchesFilter(unique.params[1]))

View File

@ -165,17 +165,9 @@ open class TileInfo {
// and the toSequence so that aggregations (like neighbors.flatMap{it.units} don't take up their own space
fun getHeight(): Int {
if (ruleset.terrains.values.asSequence().flatMap { it.uniqueObjects }
.any { it.placeholderText == "Has an elevation of [] for visibility calculations" })
return getAllTerrains().flatMap { it.uniqueObjects }
.filter { it.placeholderText == "Has an elevation of [] for visibility calculations" }
.map { it.params[0].toInt() }.sum()
// Old method - deprecated 3.14.7
if (baseTerrain == Constants.mountain) return 4
if (isHill()) return 2
if (terrainFeatures.contains(Constants.forest) || terrainFeatures.contains(Constants.jungle)) return 1
return 0
return getAllTerrains().flatMap { it.uniqueObjects }
.filter { it.placeholderText == "Has an elevation of [] for visibility calculations" }
.map { it.params[0].toInt() }.sum()
}
fun getBaseTerrain(): Terrain = baseTerrainObject

View File

@ -469,8 +469,6 @@ class Building : NamedStats(), IConstruction {
if (get(stat) > 0) return true
if (getStatPercentageBonuses(null).get(stat) > 0) return true
if (uniqueObjects.any { it.placeholderText == "[] per [] population []" && it.stats.get(stat) > 0 }) return true
// Deprecated since 3.14.17, left for modding compatibility
if (uniqueObjects.any { it.placeholderText == "[] Per [] Population in this city"}) return true
return false
}

View File

@ -36,14 +36,7 @@ class Terrain : NamedStats() {
var defenceBonus:Float = 0f
var impassable = false
/** Use isRough() instead */
@Deprecated("As of 3.14.1")
var rough = false
fun isRough(): Boolean {
// "rough" property deprecated since 3.14.1
return uniques.contains("Rough terrain") || rough
}
fun isRough(): Boolean = uniques.contains("Rough terrain")
fun getColor(): Color { // Can't be a lazy initialize, because we play around with the resulting color with lerp()s and the like
if (RGB == null) return Color.GOLD

View File

@ -11,19 +11,11 @@ import kotlin.math.roundToInt
class TileImprovement : NamedStats() {
var terrainsCanBeBuiltOn: Collection<String> = ArrayList()
// Used only for Camp - but avoid hardcoded comparison and *allow modding*
// Terrain Features that need not be cleared if the improvement enables a resource
@Deprecated("As of 3.14.15")
var resourceTerrainAllow: Collection<String> = ArrayList()
var techRequired: String? = null
var uniqueTo:String? = null
var uniques = ArrayList<String>()
val uniqueObjects:List<Unique> by lazy { uniques.map { Unique(it) } }
val shortcutKey: Char? = null
val turnsToBuild: Int = 0 // This is the base cost.
fun getTurnsToBuild(civInfo: CivilizationInfo): Int {
@ -78,9 +70,7 @@ class TileImprovement : NamedStats() {
/**
* Check: Is this improvement allowed on a [given][name] terrain feature?
*
* Uses both _legacy_ [resourceTerrainAllow] and unique "Does not need removal of []"
*
*
* Background: This not used for e.g. a lumbermill - it derives the right to be placed on forest
* from [terrainsCanBeBuiltOn]. Other improvements may be candidates without fulfilling the
* [terrainsCanBeBuiltOn] check - e.g. they are listed by a resource as 'their' improvement.
@ -89,7 +79,6 @@ class TileImprovement : NamedStats() {
* a terrain feature, thus the unique name.
*/
fun isAllowedOnFeature(name: String): Boolean {
if (name in resourceTerrainAllow) return true
return uniqueObjects.filter { it.placeholderText == "Does not need removal of []"
&& it.params[0] == name
}.any()