mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 06:51:30 -04:00
Deprecation of old uniques and fields
This commit is contained in:
parent
afdc2ffbd5
commit
43ff2ea5f9
@ -6,7 +6,6 @@ import com.unciv.logic.automation.NextTurnAutomation
|
|||||||
import com.unciv.logic.city.CityConstructions
|
import com.unciv.logic.city.CityConstructions
|
||||||
import com.unciv.logic.city.PerpetualConstruction
|
import com.unciv.logic.city.PerpetualConstruction
|
||||||
import com.unciv.logic.civilization.*
|
import com.unciv.logic.civilization.*
|
||||||
import com.unciv.logic.map.MapSizeNew
|
|
||||||
import com.unciv.logic.map.TileInfo
|
import com.unciv.logic.map.TileInfo
|
||||||
import com.unciv.logic.map.TileMap
|
import com.unciv.logic.map.TileMap
|
||||||
import com.unciv.models.metadata.GameParameters
|
import com.unciv.models.metadata.GameParameters
|
||||||
@ -278,12 +277,6 @@ class GameInfo {
|
|||||||
if (currentPlayer == "") currentPlayer = civilizations.first { it.isPlayerCivilization() }.civName
|
if (currentPlayer == "") currentPlayer = civilizations.first { it.isPlayerCivilization() }.civName
|
||||||
currentPlayerCiv = getCivilization(currentPlayer)
|
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,
|
// 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.
|
// 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
|
for (civInfo in civilizations) civInfo.gameInfo = this
|
||||||
|
@ -98,11 +98,6 @@ object BattleDamage {
|
|||||||
if (enemy.getCivInfo().isBarbarian()) {
|
if (enemy.getCivInfo().isBarbarian()) {
|
||||||
modifiers["Difficulty"] =
|
modifiers["Difficulty"] =
|
||||||
(civInfo.gameInfo.getDifficulty().barbarianBonus * 100).toInt()
|
(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
|
return modifiers
|
||||||
|
@ -84,9 +84,6 @@ class CityConstructions {
|
|||||||
"[] per [] population []" -> if (cityInfo.matchesFilter(unique.params[2]))
|
"[] per [] population []" -> if (cityInfo.matchesFilter(unique.params[2]))
|
||||||
stats.add(unique.stats.times(cityInfo.population.population / unique.params[1].toFloat()))
|
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)
|
"[] 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
|
return stats
|
||||||
|
@ -120,8 +120,6 @@ class MapParameters {
|
|||||||
var name = ""
|
var name = ""
|
||||||
var type = MapType.pangaea
|
var type = MapType.pangaea
|
||||||
var shape = MapShape.hexagonal
|
var shape = MapShape.hexagonal
|
||||||
@Deprecated("replaced by mapSize since 3.14.7")
|
|
||||||
var size = MapSize.Medium
|
|
||||||
var mapSize = MapSizeNew(MapSize.Medium)
|
var mapSize = MapSizeNew(MapSize.Medium)
|
||||||
var noRuins = false
|
var noRuins = false
|
||||||
var noNaturalWonders = false
|
var noNaturalWonders = false
|
||||||
|
@ -146,11 +146,6 @@ class MapUnit {
|
|||||||
// Deprecated since 3.15.6
|
// Deprecated since 3.15.6
|
||||||
movement += getUniques().count { it.text == "+1 Movement" }
|
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"))
|
for (unique in civInfo.getMatchingUniques("+[] Movement for all [] units"))
|
||||||
if (matchesFilter(unique.params[1]))
|
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())
|
if (civInfo.hasUnique("+1 Sight for all land military units") && type.isMilitary() && type.isLandUnit())
|
||||||
visibilityRange += 1
|
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 })
|
for (unique in getTile().getAllTerrains().flatMap { it.uniqueObjects })
|
||||||
if (unique.placeholderText == "[] Sight for [] units" && matchesFilter(unique.params[1]))
|
if (unique.placeholderText == "[] Sight for [] units" && matchesFilter(unique.params[1]))
|
||||||
|
@ -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
|
// and the toSequence so that aggregations (like neighbors.flatMap{it.units} don't take up their own space
|
||||||
|
|
||||||
fun getHeight(): Int {
|
fun getHeight(): Int {
|
||||||
if (ruleset.terrains.values.asSequence().flatMap { it.uniqueObjects }
|
return getAllTerrains().flatMap { it.uniqueObjects }
|
||||||
.any { it.placeholderText == "Has an elevation of [] for visibility calculations" })
|
.filter { it.placeholderText == "Has an elevation of [] for visibility calculations" }
|
||||||
return getAllTerrains().flatMap { it.uniqueObjects }
|
.map { it.params[0].toInt() }.sum()
|
||||||
.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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getBaseTerrain(): Terrain = baseTerrainObject
|
fun getBaseTerrain(): Terrain = baseTerrainObject
|
||||||
|
@ -469,8 +469,6 @@ class Building : NamedStats(), IConstruction {
|
|||||||
if (get(stat) > 0) return true
|
if (get(stat) > 0) return true
|
||||||
if (getStatPercentageBonuses(null).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
|
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
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,14 +36,7 @@ class Terrain : NamedStats() {
|
|||||||
var defenceBonus:Float = 0f
|
var defenceBonus:Float = 0f
|
||||||
var impassable = false
|
var impassable = false
|
||||||
|
|
||||||
/** Use isRough() instead */
|
fun isRough(): Boolean = uniques.contains("Rough terrain")
|
||||||
@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 getColor(): Color { // Can't be a lazy initialize, because we play around with the resulting color with lerp()s and the like
|
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
|
if (RGB == null) return Color.GOLD
|
||||||
|
@ -11,19 +11,11 @@ import kotlin.math.roundToInt
|
|||||||
class TileImprovement : NamedStats() {
|
class TileImprovement : NamedStats() {
|
||||||
|
|
||||||
var terrainsCanBeBuiltOn: Collection<String> = ArrayList()
|
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 techRequired: String? = null
|
||||||
|
|
||||||
var uniqueTo:String? = null
|
var uniqueTo:String? = null
|
||||||
var uniques = ArrayList<String>()
|
var uniques = ArrayList<String>()
|
||||||
val uniqueObjects:List<Unique> by lazy { uniques.map { Unique(it) } }
|
val uniqueObjects:List<Unique> by lazy { uniques.map { Unique(it) } }
|
||||||
val shortcutKey: Char? = null
|
val shortcutKey: Char? = null
|
||||||
|
|
||||||
val turnsToBuild: Int = 0 // This is the base cost.
|
val turnsToBuild: Int = 0 // This is the base cost.
|
||||||
|
|
||||||
fun getTurnsToBuild(civInfo: CivilizationInfo): Int {
|
fun getTurnsToBuild(civInfo: CivilizationInfo): Int {
|
||||||
@ -78,9 +70,7 @@ class TileImprovement : NamedStats() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check: Is this improvement allowed on a [given][name] terrain feature?
|
* 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
|
* 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
|
* from [terrainsCanBeBuiltOn]. Other improvements may be candidates without fulfilling the
|
||||||
* [terrainsCanBeBuiltOn] check - e.g. they are listed by a resource as 'their' improvement.
|
* [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.
|
* a terrain feature, thus the unique name.
|
||||||
*/
|
*/
|
||||||
fun isAllowedOnFeature(name: String): Boolean {
|
fun isAllowedOnFeature(name: String): Boolean {
|
||||||
if (name in resourceTerrainAllow) return true
|
|
||||||
return uniqueObjects.filter { it.placeholderText == "Does not need removal of []"
|
return uniqueObjects.filter { it.placeholderText == "Does not need removal of []"
|
||||||
&& it.params[0] == name
|
&& it.params[0] == name
|
||||||
}.any()
|
}.any()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user