Deprecated old uniques

This commit is contained in:
Yair Morgenstern 2022-10-13 20:46:48 +03:00
parent 4526b0f17d
commit 95205893b7
7 changed files with 18 additions and 40 deletions

View File

@ -242,8 +242,6 @@ object SpecificUnitAutomation {
fun automateImprovementPlacer(unit: MapUnit) {
var improvementBuildingUniques = unit.getMatchingUniques(UniqueType.ConstructImprovementConsumingUnit)
if (unit.religiousActionsUnitCanDo().all { unit.abilityUsesLeft[it] == unit.maxAbilityUses[it] })
improvementBuildingUniques += unit.getMatchingUniques(UniqueType.CanConstructIfNoOtherActions)
val improvementName = improvementBuildingUniques.first().params[0]
val improvement = unit.civInfo.gameInfo.ruleSet.tileImprovements[improvementName]

View File

@ -3,7 +3,11 @@ package com.unciv.logic.automation.unit
import com.unciv.Constants
import com.unciv.logic.automation.Automation
import com.unciv.logic.automation.civilization.NextTurnAutomation
import com.unciv.logic.battle.*
import com.unciv.logic.battle.Battle
import com.unciv.logic.battle.BattleDamage
import com.unciv.logic.battle.CityCombatant
import com.unciv.logic.battle.ICombatant
import com.unciv.logic.battle.MapUnitCombatant
import com.unciv.logic.city.CityInfo
import com.unciv.logic.civilization.ReligionState
import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
@ -178,13 +182,10 @@ object UnitAutomation {
if (unit.hasUnique(UniqueType.PreventSpreadingReligion) || unit.canDoReligiousAction(Constants.removeHeresy))
return SpecificUnitAutomation.automateInquisitor(unit)
if (unit.hasUnique(UniqueType.ConstructImprovementConsumingUnit)
|| (unit.hasUnique(UniqueType.CanConstructIfNoOtherActions)
&& unit.religiousActionsUnitCanDo().all { unit.abilityUsesLeft[it] == unit.maxAbilityUses[it] }))
if (unit.hasUnique(UniqueType.ConstructImprovementConsumingUnit))
// catch great prophet for civs who can't found/enhance/spread religion
return SpecificUnitAutomation.automateImprovementPlacer(unit) // includes great people plus moddable units
// ToDo: automation of great people skills (may speed up construction, provides a science boost, etc.)
return // The AI doesn't know how to handle unknown civilian units

View File

@ -116,9 +116,6 @@ class CityStats(val cityInfo: CityInfo) {
val conversionUnique = cityInfo.civInfo.getMatchingUniques(UniqueType.ProductionToCivWideStatConversionBonus).firstOrNull { it.params[0] == stat.name }
if (conversionUnique != null) {
conversionRate *= conversionUnique.params[1].toPercent()
} else if (stat == Stat.Science && cityInfo.civInfo.hasUnique(UniqueType.ProductionToScienceConversionBonus)) {
// backwards compatibility
conversionRate *= 1.33f
}
return conversionRate
}

View File

@ -248,10 +248,6 @@ open class PerpetualStatConversion(val stat: Stat) :
override fun isBuildable(cityConstructions: CityConstructions): Boolean {
val hasProductionUnique = cityConstructions.cityInfo.civInfo.getMatchingUniques(UniqueType.EnablesCivWideStatProduction).any { it.params[0] == stat.name }
return when (stat) {
Stat.Science -> hasProductionUnique
|| cityConstructions.cityInfo.civInfo.hasUnique(UniqueType.EnablesScienceProduction) // backwards compatibility
Stat.Gold -> hasProductionUnique
|| cityConstructions.cityInfo.civInfo.hasUnique(UniqueType.EnablesGoldProduction) // backwards compatibility
Stat.Culture -> hasProductionUnique
Stat.Faith -> cityConstructions.cityInfo.civInfo.gameInfo.isReligionEnabled() && hasProductionUnique
else -> false

View File

@ -321,11 +321,6 @@ open class TileInfo : IsPartOfGameInfoSerialization {
if (naturalWonder != null) {
val wonderStats = getNaturalWonder().cloneStats()
// Spain doubles tile yield
if (city != null && city.civInfo.hasUnique(UniqueType.DoubleStatsFromNaturalWonders, stateForConditionals)) {
wonderStats.timesInPlace(2f)
}
if (getNaturalWonder().overrideStats)
stats = wonderStats
else
@ -340,12 +335,6 @@ open class TileInfo : IsPartOfGameInfoSerialization {
val tileType = unique.params[1]
if (!matchesTerrainFilter(tileType, observingCiv)) continue
stats.add(unique.stats)
if (naturalWonder != null
&& tileType == "Natural Wonder"
&& city.civInfo.hasUnique(UniqueType.DoubleStatsFromNaturalWonders)
) {
stats.add(unique.stats)
}
}
for (unique in localUniqueCache.get("StatsFromTilesWithout",

View File

@ -106,9 +106,6 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
PercentProductionUnits("[relativeAmount]% Production when constructing [baseUnitFilter] units [cityFilter]", UniqueTarget.Global, UniqueTarget.FollowerBelief),
PercentProductionWonders("[relativeAmount]% Production when constructing [buildingFilter] wonders [cityFilter]", UniqueTarget.Global, UniqueTarget.FollowerBelief),
PercentProductionBuildingsInCapital("[relativeAmount]% Production towards any buildings that already exist in the Capital", UniqueTarget.Global, UniqueTarget.FollowerBelief),
// todo: maybe should be converted to "[+100]% Yield from every [Natural Wonder]"?
@Deprecated("As of 4.1.19", ReplaceWith("[+100]% Yield from every [Natural Wonder]"))
DoubleStatsFromNaturalWonders("Tile yields from Natural Wonders doubled", UniqueTarget.Global),
//endregion Stat providing uniques
@ -180,11 +177,6 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
BuyUnitsByProductionCost("May buy [baseUnitFilter] units with [stat] for [amount] times their normal Production cost", UniqueTarget.FollowerBelief, UniqueTarget.Global),
BuyBuildingsByProductionCost("May buy [buildingFilter] buildings with [stat] for [amount] times their normal Production cost", UniqueTarget.FollowerBelief, UniqueTarget.Global),
@Deprecated("As of 4.1.14", ReplaceWith("Enables conversion of city production to [Gold]"))
EnablesGoldProduction("Enables conversion of city production to gold", UniqueTarget.Global),
@Deprecated("s of 4.1.14", ReplaceWith("Enables conversion of city production to [Science]"))
EnablesScienceProduction("Enables conversion of city production to science", UniqueTarget.Global),
EnablesCivWideStatProduction("Enables conversion of city production to [civWideStat]", UniqueTarget.Global),
BuyItemsDiscount("[stat] cost of purchasing items in cities [relativeAmount]%", UniqueTarget.Global, UniqueTarget.FollowerBelief),
@ -219,8 +211,6 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
@Deprecated("As of 4.2.4", ReplaceWith("Enemy [Land] units must spend [1] extra movement points when inside your territory <before discovering [Dynamite]>"))
EnemyLandUnitsSpendExtraMovementDepreciated("Enemy land units must spend 1 extra movement point when inside your territory (obsolete upon Dynamite)", UniqueTarget.Global),
@Deprecated("s of 4.1.14", ReplaceWith("Production to [Science] conversion in cities changed by [33]%"))
ProductionToScienceConversionBonus("Production to science conversion in cities increased by 33%", UniqueTarget.Global),
ProductionToCivWideStatConversionBonus("Production to [civWideStat] conversion in cities changed by [relativeAmount]%", UniqueTarget.Global),
// Misc national uniques
@ -356,8 +346,6 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
FoundCity("Founds a new city", UniqueTarget.Unit),
ConstructImprovementConsumingUnit("Can construct [improvementName]", UniqueTarget.Unit),
@Deprecated("as of 4.1.7", ReplaceWith("Can construct [improvementName] <if it hasn't used other actions yet>"))
CanConstructIfNoOtherActions("Can construct [improvementName] if it hasn't used other actions yet", UniqueTarget.Unit),
BuildImprovements("Can build [improvementFilter/terrainFilter] improvements on tiles", UniqueTarget.Unit),
CreateWaterImprovements("May create improvements on water resources", UniqueTarget.Unit),
@ -716,6 +704,17 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
// endregion
// region DEPRECATED AND REMOVED
@Deprecated("as of 4.1.7", ReplaceWith("Can construct [improvementName] <if it hasn't used other actions yet>"))
CanConstructIfNoOtherActions("Can construct [improvementName] if it hasn't used other actions yet", UniqueTarget.Unit),
@Deprecated("s of 4.1.14", ReplaceWith("Production to [Science] conversion in cities changed by [33]%"))
ProductionToScienceConversionBonus("Production to science conversion in cities increased by 33%", UniqueTarget.Global),
@Deprecated("As of 4.1.19", ReplaceWith("[+100]% Yield from every [Natural Wonder]"))
DoubleStatsFromNaturalWonders("Tile yields from Natural Wonders doubled", UniqueTarget.Global),
@Deprecated("As of 4.1.14", ReplaceWith("Enables conversion of city production to [Gold]"))
EnablesGoldProduction("Enables conversion of city production to gold", UniqueTarget.Global),
@Deprecated("s of 4.1.14", ReplaceWith("Enables conversion of city production to [Science]"))
EnablesScienceProduction("Enables conversion of city production to science", UniqueTarget.Global),
@Deprecated("as of 4.0.3", ReplaceWith("Damage is ignored when determining unit Strength <for [All] units>"), DeprecationLevel.ERROR)
UnitsFightFullStrengthWhenDamaged("Units fight as though they were at full strength even when damaged", UniqueTarget.Global),
@Deprecated("as of 4.0.3", ReplaceWith("[+amount]% Strength <within [amount2] tiles of a [tileFilter]>"), DeprecationLevel.ERROR)

View File

@ -702,9 +702,7 @@ object UnitActions {
fun getImprovementConstructionActions(unit: MapUnit, tile: TileInfo): ArrayList<UnitAction> {
val finalActions = ArrayList<UnitAction>()
var uniquesToCheck = unit.getMatchingUniques(UniqueType.ConstructImprovementConsumingUnit)
if (unit.religiousActionsUnitCanDo().all { unit.abilityUsesLeft[it] == unit.maxAbilityUses[it] })
uniquesToCheck += unit.getMatchingUniques(UniqueType.CanConstructIfNoOtherActions)
val uniquesToCheck = unit.getMatchingUniques(UniqueType.ConstructImprovementConsumingUnit)
val civResources = unit.civInfo.getCivResourcesByName()
for (unique in uniquesToCheck) {