mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-09 23:39:40 +07:00
Mass deprecation
This commit is contained in:
@ -3,8 +3,6 @@ package com.unciv
|
||||
object Constants {
|
||||
const val worker = "Worker"
|
||||
const val canBuildImprovements = "Can build [] improvements on tiles"
|
||||
@Deprecated("as of 3.15.5")
|
||||
const val workerUnique = "Can build improvements on tiles"
|
||||
const val workBoatsUnique = "May create improvements on water resources"
|
||||
const val settler = "Settler"
|
||||
const val settlerUnique = "Founds a new city"
|
||||
|
@ -402,14 +402,6 @@ class GameInfo {
|
||||
for (tech in civinfo.tech.techsResearched.toList())
|
||||
if (!ruleSet.technologies.containsKey(tech))
|
||||
civinfo.tech.techsResearched.remove(tech)
|
||||
for (policy in civinfo.policies.adoptedPolicies.toList())
|
||||
// So these two policies are deprecated since 3.14.17
|
||||
// However, we still need to convert save files that have those to valid save files
|
||||
// The easiest way to do this, is just to allow them here, and filter them out in
|
||||
// the policyManager class.
|
||||
// Yes, this is ugly, but it should be temporary, and it works.
|
||||
if (!ruleSet.policies.containsKey(policy) && !(policy == "Entrepreneurship" || policy == "Patronage"))
|
||||
civinfo.policies.adoptedPolicies.remove(policy)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,8 +139,7 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
|
||||
private fun addWorkerChoice() {
|
||||
val workerEquivalents = civInfo.gameInfo.ruleSet.units.values
|
||||
.filter { it.uniques.any {
|
||||
// Constants.workerUnique deprecated since 3.15.5
|
||||
unique -> unique.equalsPlaceholderText(Constants.canBuildImprovements) || unique.equalsPlaceholderText(Constants.workerUnique)
|
||||
unique -> unique.equalsPlaceholderText(Constants.canBuildImprovements)
|
||||
} && it.isBuildable(cityConstructions) }
|
||||
if (workerEquivalents.isEmpty()) return // for mods with no worker units
|
||||
if (civInfo.getIdleUnits().any { it.isAutomated() && it.hasUniqueToBuildImprovements })
|
||||
|
@ -202,14 +202,6 @@ object BattleDamage {
|
||||
if (attacker.matchesCategory(unique.params[1]))
|
||||
modifiers.add("defence vs [${unique.params[1]}] ", unique.params[0].toInt())
|
||||
}
|
||||
|
||||
// Deprecated since 3.15.7
|
||||
if (attacker.isRanged()) {
|
||||
val defenceVsRanged = 25 * defender.unit.getUniques()
|
||||
.count { it.text == "+25% Defence against ranged attacks" }
|
||||
if (defenceVsRanged > 0) modifiers.add("defence vs ranged", defenceVsRanged)
|
||||
}
|
||||
//
|
||||
|
||||
for (unique in defender.unit.getMatchingUniques("+[]% Strength when defending")) {
|
||||
modifiers.add("Defender Bonus", unique.params[0].toInt())
|
||||
@ -223,10 +215,10 @@ object BattleDamage {
|
||||
if (defender.unit.isFortified())
|
||||
modifiers["Fortification"] = 20 * defender.unit.getFortificationTurns()
|
||||
} else if (defender is CityCombatant) {
|
||||
|
||||
modifiers["Defensive Bonus"] = defender.city.civInfo.getMatchingUniques("+[]% Defensive strength for cities")
|
||||
.map { it.params[0].toFloat() / 100f }.sum().toInt()
|
||||
|
||||
|
||||
modifiers["Defensive Bonus"] =
|
||||
defender.city.civInfo.getMatchingUniques("+[]% Defensive strength for cities")
|
||||
.map { it.params[0].toFloat() / 100f }.sum().toInt()
|
||||
}
|
||||
|
||||
return modifiers
|
||||
@ -250,16 +242,6 @@ object BattleDamage {
|
||||
)
|
||||
modifiers[unique.params[2]] = unique.params[0].toInt()
|
||||
}
|
||||
|
||||
// Deprecated since 3.15.7
|
||||
if (tile.neighbors.flatMap { it.getUnits() }
|
||||
.any {
|
||||
it.hasUnique("-10% combat strength for adjacent enemy units") && it.civInfo.isAtWarWith(
|
||||
unit.getCivInfo()
|
||||
)
|
||||
})
|
||||
modifiers["Haka War Dance"] = -10
|
||||
//
|
||||
return modifiers
|
||||
}
|
||||
|
||||
|
@ -47,10 +47,6 @@ class CityExpansionManager {
|
||||
|
||||
for (unique in cityInfo.getMatchingUniques("[]% cost of natural border growth"))
|
||||
cultureToNextTile *= unique.params[0].toPercent()
|
||||
|
||||
// Unique deprecated since 3.15.10 (seems unused, and should be replaced by the unique above)
|
||||
if (cityInfo.civInfo.hasUnique("Increased rate of border expansion")) cultureToNextTile *= 0.75
|
||||
//
|
||||
|
||||
return cultureToNextTile.roundToInt()
|
||||
}
|
||||
|
@ -49,20 +49,6 @@ class PolicyManager {
|
||||
fun getPolicyByName(name: String): Policy = civInfo.gameInfo.ruleSet.policies[name]!!
|
||||
|
||||
fun setTransients() {
|
||||
// Reassign policies deprecated in 3.14.17, left for backwards compatibility
|
||||
if (adoptedPolicies.contains("Patronage") &&
|
||||
!civInfo.gameInfo.ruleSet.policies.contains("Patronage")
|
||||
) {
|
||||
adoptedPolicies.add("Merchant Navy")
|
||||
adoptedPolicies.remove("Patronage")
|
||||
}
|
||||
if (adoptedPolicies.contains("Entrepreneurship") &&
|
||||
!civInfo.gameInfo.ruleSet.policies.contains("Entrepreneurship")
|
||||
) {
|
||||
adoptedPolicies.add("Naval Tradition")
|
||||
adoptedPolicies.remove("Entrepreneurship")
|
||||
}
|
||||
//
|
||||
for (policyName in adoptedPolicies)
|
||||
addPolicyToTransients(getPolicyByName(policyName))
|
||||
}
|
||||
|
@ -158,11 +158,7 @@ class MapUnit {
|
||||
|
||||
var movement = baseUnit.movement
|
||||
movement += getMatchingUniques("[] Movement").sumBy { it.params[0].toInt() }
|
||||
|
||||
// Deprecated since 3.15.6
|
||||
movement += getUniques().count { it.text == "+1 Movement" }
|
||||
//
|
||||
|
||||
|
||||
for (unique in civInfo.getMatchingUniques("+[] Movement for all [] units"))
|
||||
if (matchesFilter(unique.params[1]))
|
||||
movement += unique.params[0].toInt()
|
||||
@ -204,8 +200,7 @@ class MapUnit {
|
||||
|
||||
//todo: parameterize [terrainFilter] in 5 to 7 of the following:
|
||||
|
||||
// "All tiles costs 1" obsoleted in 3.11.18 - keyword: Deprecate
|
||||
allTilesCosts1 = hasUnique("All tiles cost 1 movement") || hasUnique("All tiles costs 1")
|
||||
allTilesCosts1 = hasUnique("All tiles cost 1 movement")
|
||||
canPassThroughImpassableTiles = hasUnique("Can pass through impassable tiles")
|
||||
ignoresTerrainCost = hasUnique("Ignores terrain cost")
|
||||
ignoresZoneOfControl = hasUnique("Ignores Zone of Control")
|
||||
@ -216,8 +211,7 @@ class MapUnit {
|
||||
canEnterIceTiles = hasUnique("Can enter ice tiles")
|
||||
cannotEnterOceanTiles = hasUnique("Cannot enter ocean tiles")
|
||||
cannotEnterOceanTilesUntilAstronomy = hasUnique("Cannot enter ocean tiles until Astronomy")
|
||||
// Constants.workerUnique deprecated since 3.15.5
|
||||
hasUniqueToBuildImprovements = hasUnique(Constants.canBuildImprovements) || hasUnique(Constants.workerUnique)
|
||||
hasUniqueToBuildImprovements = hasUnique(Constants.canBuildImprovements)
|
||||
canEnterForeignTerrain =
|
||||
hasUnique("May enter foreign tiles without open borders, but loses [] religious strength each turn it ends there")
|
||||
|| hasUnique("May enter foreign tiles without open borders")
|
||||
@ -248,15 +242,12 @@ class MapUnit {
|
||||
for (unique in civInfo.getMatchingUniques("+[] Sight for all [] units"))
|
||||
if (matchesFilter(unique.params[1]))
|
||||
visibilityRange += unique.params[0].toInt()
|
||||
|
||||
// TODO: This should be replaced with "Sight" like others, for naming consistency
|
||||
visibilityRange += getMatchingUniques("[] Visibility Range").sumBy { it.params[0].toInt() }
|
||||
|
||||
if (hasUnique("Limited Visibility")) visibilityRange -= 1
|
||||
|
||||
// Deprecated since 3.15.1
|
||||
if (civInfo.hasUnique("+1 Sight for all land military units") && baseUnit.isMilitary() && baseUnit.isLandUnit())
|
||||
visibilityRange += 1
|
||||
//
|
||||
|
||||
|
||||
for (unique in getTile().getAllTerrains().flatMap { it.uniqueObjects })
|
||||
if (unique.placeholderText == "[] Sight for [] units" && matchesFilter(unique.params[1]))
|
||||
@ -313,7 +304,6 @@ class MapUnit {
|
||||
|
||||
fun isIdle(): Boolean {
|
||||
if (currentMovement == 0f) return false
|
||||
// Constants.workerUnique deprecated since 3.15.5
|
||||
if (getTile().improvementInProgress != null
|
||||
&& canBuildImprovement(getTile().getTileImprovementInProgress()!!))
|
||||
return false
|
||||
@ -325,10 +315,6 @@ class MapUnit {
|
||||
|
||||
fun maxAttacksPerTurn(): Int {
|
||||
var maxAttacksPerTurn = 1 + getMatchingUniques("[] additional attacks per turn").sumBy { it.params[0].toInt() }
|
||||
// Deprecated since 3.15.6
|
||||
if (hasUnique("1 additional attack per turn"))
|
||||
maxAttacksPerTurn++
|
||||
//
|
||||
return maxAttacksPerTurn
|
||||
}
|
||||
|
||||
@ -340,10 +326,6 @@ class MapUnit {
|
||||
fun getRange(): Int {
|
||||
if (baseUnit.isMelee()) return 1
|
||||
var range = baseUnit().range
|
||||
// Deprecated since 3.15.6
|
||||
if (hasUnique("+1 Range")) range++
|
||||
if (hasUnique("+2 Range")) range += 2
|
||||
//
|
||||
range += getMatchingUniques("[] Range").sumBy { it.params[0].toInt() }
|
||||
return range
|
||||
}
|
||||
@ -961,8 +943,6 @@ class MapUnit {
|
||||
}
|
||||
|
||||
fun canBuildImprovement(improvement: TileImprovement, tile: TileInfo = currentTile): Boolean {
|
||||
// Constants.workerUnique deprecated since 3.15.5
|
||||
if (hasUnique(Constants.workerUnique)) return true
|
||||
val matchingUniques = getMatchingUniques(Constants.canBuildImprovements)
|
||||
return matchingUniques.any { improvement.matchesFilter(it.params[0]) || tile.matchesTerrainFilter(it.params[0]) }
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import com.unciv.models.stats.Stats
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.civilopedia.FormattedLine
|
||||
import com.unciv.ui.utils.Fonts
|
||||
import com.unciv.ui.utils.toPercent
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.min
|
||||
|
||||
@ -228,9 +229,6 @@ open class TileInfo {
|
||||
if (city != null) {
|
||||
var tileUniques = city.getMatchingUniques("[] from [] tiles []")
|
||||
.filter { city.matchesFilter(it.params[2]) }
|
||||
// Deprecated since 3.15.9
|
||||
tileUniques += city.getLocalMatchingUniques("[] from [] tiles in this city")
|
||||
//
|
||||
tileUniques += city.getMatchingUniques("[] from every []")
|
||||
for (unique in tileUniques) {
|
||||
val tileType = unique.params[1]
|
||||
@ -329,9 +327,6 @@ open class TileInfo {
|
||||
if (city != null) {
|
||||
var tileUniques = city.getMatchingUniques("[] from [] tiles []")
|
||||
.filter { city.matchesFilter(it.params[2]) }
|
||||
// Deprecated since 3.15.9
|
||||
tileUniques += city.getLocalMatchingUniques("[] from [] tiles in this city")
|
||||
//
|
||||
val improvementUniques = improvement.uniqueObjects.filter {
|
||||
it.placeholderText == "[] on [] tiles once [] is discovered"
|
||||
&& observingCiv.tech.isResearched(it.params[2])
|
||||
@ -364,12 +359,7 @@ open class TileInfo {
|
||||
|
||||
for (unique in observingCiv.getMatchingUniques("+[]% yield from every []"))
|
||||
if (improvement.matchesFilter(unique.params[1]))
|
||||
stats.timesInPlace(1f + unique.params[0].toFloat() / 100f)
|
||||
|
||||
// Deprecated since 3.15
|
||||
if (containsGreatImprovement() && observingCiv.hasUnique("Tile yield from Great Improvements +100%"))
|
||||
stats.timesInPlace(2f)
|
||||
//
|
||||
stats.timesInPlace(unique.params[0].toPercent())
|
||||
|
||||
return stats
|
||||
}
|
||||
|
@ -212,16 +212,9 @@ class BaseUnit : INamed, INonPerpetualConstruction, ICivilopediaText {
|
||||
var cost = getBaseBuyCost(cityInfo, stat)?.toDouble()
|
||||
if (cost == null) return null
|
||||
|
||||
// Deprecated since 3.15
|
||||
if (stat == Stat.Gold && cityInfo.civInfo.hasUnique("Gold cost of purchasing units -33%")) cost *= 0.67f
|
||||
//
|
||||
|
||||
// Deprecated since 3.15.15
|
||||
if (stat == Stat.Gold) {
|
||||
for (unique in cityInfo.getMatchingUniques("Gold cost of purchasing [] units -[]%")) {
|
||||
if (matchesFilter(unique.params[0]))
|
||||
cost *= 1f - unique.params[1].toFloat() / 100f
|
||||
}
|
||||
for (unique in cityInfo.getMatchingUniques("Cost of purchasing items in cities reduced by []%"))
|
||||
cost *= 1f - (unique.params[0].toFloat() / 100f)
|
||||
}
|
||||
|
Reference in New Issue
Block a user