mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-30 14:48:56 +07:00
Unique deprecation (#7433)
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
package com.unciv.logic.battle
|
||||
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.models.Counter
|
||||
import com.unciv.models.ruleset.GlobalUniques
|
||||
import com.unciv.models.ruleset.unique.StateForConditionals
|
||||
@ -111,8 +110,6 @@ object BattleDamage {
|
||||
val modifiers = getGeneralModifiers(attacker, defender, CombatAction.Attack)
|
||||
|
||||
if (attacker is MapUnitCombatant) {
|
||||
modifiers.add(getTileSpecificModifiers(attacker, defender.getTile()))
|
||||
|
||||
if (attacker.unit.isEmbarked()
|
||||
&& !(attacker.unit.hasUnique(UniqueType.AttackAcrossCoast)))
|
||||
modifiers["Landing"] = -50
|
||||
@ -166,16 +163,13 @@ object BattleDamage {
|
||||
|
||||
if (defender.unit.isEmbarked()) {
|
||||
// embarked units get no defensive modifiers apart from this unique
|
||||
if (defender.unit.hasUnique(UniqueType.DefenceBonusWhenEmbarked, checkCivInfoUniques = true) ||
|
||||
defender.getCivInfo().hasUnique(UniqueType.DefenceBonusWhenEmbarkedCivwide)
|
||||
if (defender.unit.hasUnique(UniqueType.DefenceBonusWhenEmbarked, checkCivInfoUniques = true)
|
||||
)
|
||||
modifiers["Embarked"] = 100
|
||||
|
||||
return modifiers
|
||||
}
|
||||
|
||||
modifiers.putAll(getTileSpecificModifiers(defender, tile))
|
||||
|
||||
val tileDefenceBonus = tile.getDefensiveBonus()
|
||||
if (!defender.unit.hasUnique(UniqueType.NoDefensiveTerrainBonus, checkCivInfoUniques = true) && tileDefenceBonus > 0
|
||||
|| !defender.unit.hasUnique(UniqueType.NoDefensiveTerrainPenalty, checkCivInfoUniques = true) && tileDefenceBonus < 0
|
||||
@ -190,19 +184,6 @@ object BattleDamage {
|
||||
return modifiers
|
||||
}
|
||||
|
||||
@Deprecated("As of 4.0.3", level=DeprecationLevel.WARNING)
|
||||
private fun getTileSpecificModifiers(unit: MapUnitCombatant, tile: TileInfo): Counter<String> {
|
||||
val modifiers = Counter<String>()
|
||||
|
||||
for (unique in unit.getCivInfo().getMatchingUniques(UniqueType.StrengthWithinTilesOfTile)) {
|
||||
if (tile.getTilesInDistance(unique.params[1].toInt())
|
||||
.any { it.matchesFilter(unique.params[2]) }
|
||||
)
|
||||
modifiers[unique.params[2]] = unique.params[0].toInt()
|
||||
}
|
||||
|
||||
return modifiers
|
||||
}
|
||||
|
||||
private fun modifiersToMultiplicationBonus(modifiers: Counter<String>): Float {
|
||||
var finalModifier = 1f
|
||||
@ -213,7 +194,6 @@ object BattleDamage {
|
||||
private fun getHealthDependantDamageRatio(combatant: ICombatant): Float {
|
||||
return if (combatant !is MapUnitCombatant
|
||||
|| combatant.unit.hasUnique(UniqueType.NoDamagePenalty, checkCivInfoUniques = true)
|
||||
|| combatant.getCivInfo().hasUnique(UniqueType.UnitsFightFullStrengthWhenDamaged)
|
||||
) {
|
||||
1f
|
||||
}
|
||||
|
@ -335,11 +335,8 @@ class MapUnit : IsPartOfGameInfoSerialization {
|
||||
.none { it.value != DoubleMovementTerrainTarget.Feature }
|
||||
noFilteredDoubleMovementUniques = doubleMovementInTerrain
|
||||
.none { it.value == DoubleMovementTerrainTarget.Filter }
|
||||
costToDisembark = (getMatchingUniques(UniqueType.ReducedDisembarkCost, checkCivInfoUniques = true)
|
||||
// Deprecated as of 4.0.3
|
||||
+ getMatchingUniques(UniqueType.DisembarkCostDeprecated, checkCivInfoUniques = true)
|
||||
//
|
||||
).minOfOrNull { it.params[0].toFloat() }
|
||||
costToDisembark = (getMatchingUniques(UniqueType.ReducedDisembarkCost, checkCivInfoUniques = true))
|
||||
.minOfOrNull { it.params[0].toFloat() }
|
||||
costToEmbark = getMatchingUniques(UniqueType.ReducedEmbarkCost, checkCivInfoUniques = true)
|
||||
.minOfOrNull { it.params[0].toFloat() }
|
||||
|
||||
|
@ -188,11 +188,6 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
|
||||
stats.add(unique.stats)
|
||||
}
|
||||
|
||||
@Suppress("RemoveRedundantQualifierName") // make it clearer Building inherits Stats
|
||||
for (unique in getMatchingUniques(UniqueType.StatsWithResource))
|
||||
if (civInfo.hasResource(unique.params[1]))
|
||||
stats.add(unique.stats)
|
||||
|
||||
if (!isWonder)
|
||||
for (unique in localUniqueCache.get("StatsFromBuildings", city.getMatchingUniques(UniqueType.StatsFromBuildings))) {
|
||||
if (matchesFilter(unique.params[1]))
|
||||
@ -509,15 +504,6 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
|
||||
)
|
||||
rejectionReasons.add(RejectionReason.MustOwnTile.toInstance(unique.text))
|
||||
|
||||
// Deprecated since 3.16.11
|
||||
UniqueType.CanOnlyBeBuiltInAnnexedCities ->
|
||||
if (
|
||||
cityConstructions.cityInfo.isPuppet
|
||||
|| cityConstructions.cityInfo.civInfo.civName == cityConstructions.cityInfo.foundingCiv
|
||||
)
|
||||
rejectionReasons.add(RejectionReason.CanOnlyBeBuiltInSpecificCities.toInstance(unique.text))
|
||||
//
|
||||
|
||||
UniqueType.CanOnlyBeBuiltInCertainCities ->
|
||||
if (!cityConstructions.cityInfo.matchesFilter(unique.params[0]))
|
||||
rejectionReasons.add(RejectionReason.CanOnlyBeBuiltInSpecificCities.toInstance(unique.text))
|
||||
|
@ -223,8 +223,6 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
// Misc national uniques
|
||||
NotifiedOfBarbarianEncampments("Notified of new Barbarian encampments", UniqueTarget.Global),
|
||||
BorrowsCityNames("\"Borrows\" city names from other civilizations in the game", UniqueTarget.Global),
|
||||
@Deprecated("as of 4.0.3", ReplaceWith("Damage is ignored when determining unit Strength <for [All] units>"))
|
||||
UnitsFightFullStrengthWhenDamaged("Units fight as though they were at full strength even when damaged", UniqueTarget.Global),
|
||||
GoldWhenDiscoveringNaturalWonder("100 Gold for discovering a Natural Wonder (bonus enhanced to 500 Gold if first to discover it)", UniqueTarget.Global),
|
||||
UnhappinessFromCitiesDoubled("Unhappiness from number of Cities doubled", UniqueTarget.Global),
|
||||
GreatGeneralProvidesDoubleCombatBonus("Great General provides double combat bonus", UniqueTarget.Unit, UniqueTarget.Global),
|
||||
@ -241,8 +239,6 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
GainInfluenceWithUnitGiftToCityState("Gain [amount] Influence with a [baseUnitFilter] gift to a City-State", UniqueTarget.Global),
|
||||
FaithCostOfGreatProphetChange("[relativeAmount]% Faith cost of generating Great Prophet equivalents", UniqueTarget.Global),
|
||||
RestingPointOfCityStatesFollowingReligionChange("Resting point for Influence with City-States following this religion [amount]", UniqueTarget.Global),
|
||||
@Deprecated("as of 4.0.3", ReplaceWith("[+amount]% Strength <within [amount2] tiles of a [tileFilter]>"))
|
||||
StrengthWithinTilesOfTile("+[amount]% Strength if within [amount2] tiles of a [tileFilter]", UniqueTarget.Global),
|
||||
StatBonusPercentFromCityStates("[relativeAmount]% [stat] from City-States", UniqueTarget.Global),
|
||||
|
||||
ProvidesGoldWheneverGreatPersonExpended("Provides a sum of gold each time you spend a Great Person", UniqueTarget.Global),
|
||||
@ -326,13 +322,9 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
RequiresBuildingInAllCities("Requires a [buildingName] in all cities", UniqueTarget.Building),
|
||||
RequiresBuildingInSomeCities("Requires a [buildingName] in at least [amount] cities", UniqueTarget.Building),
|
||||
CanOnlyBeBuiltInCertainCities("Can only be built [cityFilter]", UniqueTarget.Building),
|
||||
@Deprecated("as of 3.19.16", ReplaceWith("Can only be built [in annexed cities]"))
|
||||
CanOnlyBeBuiltInAnnexedCities("Can only be built in annexed cities", UniqueTarget.Building),
|
||||
|
||||
MustHaveOwnedWithinTiles("Must have an owned [tileFilter] within [amount] tiles", UniqueTarget.Building),
|
||||
|
||||
@Deprecated("as of 3.19.7", ReplaceWith("[stats] <with [resource]>"))
|
||||
StatsWithResource("[stats] with [resource]", UniqueTarget.Building),
|
||||
|
||||
// Todo nuclear weapon and spaceship enabling requires a rethink.
|
||||
// This doesn't actually directly affect anything, the "Only available <if [Manhattan Project] is constructed>" of the nuclear weapons does that.
|
||||
@ -420,8 +412,6 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
|
||||
NormalVisionWhenEmbarked("Normal vision when embarked", UniqueTarget.Unit, UniqueTarget.Global),
|
||||
DefenceBonusWhenEmbarked("Defense bonus when embarked", UniqueTarget.Unit, UniqueTarget.Global),
|
||||
@Deprecated("as of 4.0.3", ReplaceWith("Defense bonus when embarked <for [All] units>"))
|
||||
DefenceBonusWhenEmbarkedCivwide("Embarked units can defend themselves", UniqueTarget.Global),
|
||||
AttackAcrossCoast("Eliminates combat penalty for attacking across a coast", UniqueTarget.Unit),
|
||||
AttackOnSea("May attack when embarked", UniqueTarget.Unit),
|
||||
AttackAcrossRiver("Eliminates combat penalty for attacking over a river", UniqueTarget.Unit),
|
||||
@ -471,8 +461,6 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
CanEnterForeignTilesButLosesReligiousStrength("May enter foreign tiles without open borders, but loses [amount] religious strength each turn it ends there", UniqueTarget.Unit),
|
||||
ReducedDisembarkCost("[amount] Movement point cost to disembark", UniqueTarget.Global, UniqueTarget.Unit),
|
||||
ReducedEmbarkCost("[amount] Movement point cost to embark", UniqueTarget.Global, UniqueTarget.Unit),
|
||||
@Deprecated("as of 4.0.3", ReplaceWith("[1] Movement point cost to disembark <for [All] units>"))
|
||||
DisembarkCostDeprecated("Units pay only 1 movement point to disembark", UniqueTarget.Global),
|
||||
|
||||
CannotBeBarbarian("Never appears as a Barbarian unit", UniqueTarget.Unit, flags = UniqueFlag.setOfHiddenToUsers),
|
||||
|
||||
@ -713,6 +701,19 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
// endregion
|
||||
|
||||
// region DEPRECATED AND REMOVED
|
||||
@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)
|
||||
StrengthWithinTilesOfTile("+[amount]% Strength if within [amount2] tiles of a [tileFilter]", UniqueTarget.Global),
|
||||
@Deprecated("as of 3.19.7", ReplaceWith("[stats] <with [resource]>"), DeprecationLevel.ERROR)
|
||||
StatsWithResource("[stats] with [resource]", UniqueTarget.Building),
|
||||
@Deprecated("as of 3.19.16", ReplaceWith("Can only be built [in annexed cities]"), DeprecationLevel.ERROR)
|
||||
CanOnlyBeBuiltInAnnexedCities("Can only be built in annexed cities", UniqueTarget.Building),
|
||||
@Deprecated("as of 4.0.3", ReplaceWith("Defense bonus when embarked <for [All] units>"), DeprecationLevel.ERROR)
|
||||
DefenceBonusWhenEmbarkedCivwide("Embarked units can defend themselves", UniqueTarget.Global),
|
||||
@Deprecated("as of 4.0.3", ReplaceWith("[1] Movement point cost to disembark <for [All] units>"), DeprecationLevel.ERROR)
|
||||
DisembarkCostDeprecated("Units pay only 1 movement point to disembark", UniqueTarget.Global),
|
||||
|
||||
@Deprecated("as of 4.0.3", ReplaceWith("When conquering an encampment, earn [25] Gold and recruit a Barbarian unit <with [67]% chance>"), DeprecationLevel.ERROR)
|
||||
ChanceToRecruitBarbarianFromEncampment("67% chance to earn 25 Gold and recruit a Barbarian unit from a conquered encampment", UniqueTarget.Global),
|
||||
@Deprecated("as of 4.0.3", ReplaceWith("When defeating a [{Barbarian} {Water}] unit, earn [25] Gold and recruit it <with [50]% chance>"), DeprecationLevel.ERROR)
|
||||
|
Reference in New Issue
Block a user