mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-03 13:30:51 +07:00
chore: retire deprecated uniques
This commit is contained in:
parent
e89d342e31
commit
053f5b9442
@ -355,7 +355,7 @@ object ReligionAutomation {
|
|||||||
15f * if (civInfo.wantsToFocusOn(Victory.Focus.Military)) 2f else 1f
|
15f * if (civInfo.wantsToFocusOn(Victory.Focus.Military)) 2f else 1f
|
||||||
UniqueType.StatsWhenSpreading ->
|
UniqueType.StatsWhenSpreading ->
|
||||||
unique.params[0].toFloat() / 5f
|
unique.params[0].toFloat() / 5f
|
||||||
UniqueType.StatsWhenAdoptingReligion, UniqueType.StatsWhenAdoptingReligionSpeed ->
|
UniqueType.StatsWhenAdoptingReligion ->
|
||||||
unique.stats.values.sum() / 50f
|
unique.stats.values.sum() / 50f
|
||||||
UniqueType.RestingPointOfCityStatesFollowingReligionChange ->
|
UniqueType.RestingPointOfCityStatesFollowingReligionChange ->
|
||||||
if (civInfo.wantsToFocusOn(Victory.Focus.CityStates))
|
if (civInfo.wantsToFocusOn(Victory.Focus.CityStates))
|
||||||
@ -366,8 +366,6 @@ object ReligionAutomation {
|
|||||||
unique.stats.values.sum()
|
unique.stats.values.sum()
|
||||||
UniqueType.StatsFromGlobalFollowers ->
|
UniqueType.StatsFromGlobalFollowers ->
|
||||||
4f * (unique.stats.values.sum() / unique.params[1].toFloat())
|
4f * (unique.stats.values.sum() / unique.params[1].toFloat())
|
||||||
UniqueType.ProvidesStatsWheneverGreatPersonExpended ->
|
|
||||||
unique.stats.values.sum() / 2f
|
|
||||||
UniqueType.Strength ->
|
UniqueType.Strength ->
|
||||||
unique.params[0].toFloat() / 4f
|
unique.params[0].toFloat() / 4f
|
||||||
UniqueType.ReligionSpreadDistance ->
|
UniqueType.ReligionSpreadDistance ->
|
||||||
@ -451,7 +449,7 @@ object ReligionAutomation {
|
|||||||
// belief less than make the game crash. The `continue`s should only be reached whenever
|
// belief less than make the game crash. The `continue`s should only be reached whenever
|
||||||
// there are not enough beliefs to choose, but there should be, as otherwise we could
|
// there are not enough beliefs to choose, but there should be, as otherwise we could
|
||||||
// not have used a great prophet to found/enhance our religion.
|
// not have used a great prophet to found/enhance our religion.
|
||||||
for (belief in BeliefType.values()) {
|
for (belief in BeliefType.entries) {
|
||||||
if (belief == BeliefType.None) continue
|
if (belief == BeliefType.None) continue
|
||||||
repeat(beliefsToChoose[belief]) {
|
repeat(beliefsToChoose[belief]) {
|
||||||
chosenBeliefs.add(
|
chosenBeliefs.add(
|
||||||
|
@ -112,12 +112,9 @@ class CityReligionManager : IsPartOfGameInfoSerialization {
|
|||||||
if (newMajorityReligion in religionsAtSomePointAdopted) return
|
if (newMajorityReligion in religionsAtSomePointAdopted) return
|
||||||
|
|
||||||
val religionOwningCiv = newMajorityReligionObject.getFounder()
|
val religionOwningCiv = newMajorityReligionObject.getFounder()
|
||||||
if (religionOwningCiv.hasUnique(UniqueType.StatsWhenAdoptingReligionSpeed) || religionOwningCiv.hasUnique(UniqueType.StatsWhenAdoptingReligion)) {
|
if (religionOwningCiv.hasUnique(UniqueType.StatsWhenAdoptingReligion)) {
|
||||||
val statsGranted =
|
val statsGranted =
|
||||||
(
|
religionOwningCiv.getMatchingUniques(UniqueType.StatsWhenAdoptingReligion).map { it.stats.times(if (!it.isModifiedByGameSpeed()) 1f else city.civ.gameInfo.speed.modifier) }
|
||||||
religionOwningCiv.getMatchingUniques(UniqueType.StatsWhenAdoptingReligionSpeed)
|
|
||||||
+ religionOwningCiv.getMatchingUniques(UniqueType.StatsWhenAdoptingReligion)
|
|
||||||
).map { it.stats.times(if (!it.isModifiedByGameSpeed()) 1f else city.civ.gameInfo.speed.modifier) }
|
|
||||||
.reduce { acc, stats -> acc + stats }
|
.reduce { acc, stats -> acc + stats }
|
||||||
|
|
||||||
for ((key, value) in statsGranted)
|
for ((key, value) in statsGranted)
|
||||||
|
@ -24,7 +24,6 @@ import com.unciv.models.ruleset.unique.UniqueTriggerActivation
|
|||||||
import com.unciv.models.ruleset.unique.UniqueType
|
import com.unciv.models.ruleset.unique.UniqueType
|
||||||
import com.unciv.models.ruleset.unit.BaseUnit
|
import com.unciv.models.ruleset.unit.BaseUnit
|
||||||
import com.unciv.models.ruleset.unit.UnitType
|
import com.unciv.models.ruleset.unit.UnitType
|
||||||
import com.unciv.models.stats.Stats
|
|
||||||
import com.unciv.models.translations.tr
|
import com.unciv.models.translations.tr
|
||||||
import com.unciv.ui.components.UnitMovementMemoryType
|
import com.unciv.ui.components.UnitMovementMemoryType
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
@ -815,7 +814,6 @@ class MapUnit : IsPartOfGameInfoSerialization {
|
|||||||
|
|
||||||
/** Destroys the unit and gives stats if its a great person */
|
/** Destroys the unit and gives stats if its a great person */
|
||||||
fun consume() {
|
fun consume() {
|
||||||
addStatsPerGreatPersonUsage()
|
|
||||||
for (unique in civ.getTriggeredUniques(UniqueType.TriggerUponExpendingUnit))
|
for (unique in civ.getTriggeredUniques(UniqueType.TriggerUponExpendingUnit))
|
||||||
if (unique.conditionals.any { it.type == UniqueType.TriggerUponExpendingUnit && matchesFilter(it.params[0]) })
|
if (unique.conditionals.any { it.type == UniqueType.TriggerUponExpendingUnit && matchesFilter(it.params[0]) })
|
||||||
UniqueTriggerActivation.triggerUnique(unique, this,
|
UniqueTriggerActivation.triggerUnique(unique, this,
|
||||||
@ -823,31 +821,6 @@ class MapUnit : IsPartOfGameInfoSerialization {
|
|||||||
destroy()
|
destroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addStatsPerGreatPersonUsage() {
|
|
||||||
if (!isGreatPerson()) return
|
|
||||||
|
|
||||||
val gainedStats = Stats()
|
|
||||||
for (unique in civ.getMatchingUniques(UniqueType.ProvidesGoldWheneverGreatPersonExpended)) {
|
|
||||||
gainedStats.gold += (100 * civ.gameInfo.speed.goldCostModifier).toInt()
|
|
||||||
}
|
|
||||||
val speedModifiers = civ.gameInfo.speed.statCostModifiers
|
|
||||||
for (unique in civ.getMatchingUniques(UniqueType.ProvidesStatsWheneverGreatPersonExpended)) {
|
|
||||||
val uniqueStats = unique.stats.clone()
|
|
||||||
for ((stat, value) in uniqueStats) {
|
|
||||||
uniqueStats[stat] = value * speedModifiers[stat]!!
|
|
||||||
}
|
|
||||||
gainedStats.add(uniqueStats)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gainedStats.isEmpty()) return
|
|
||||||
|
|
||||||
for (stat in gainedStats)
|
|
||||||
civ.addStat(stat.key, stat.value.toInt())
|
|
||||||
|
|
||||||
civ.addNotification("By expending your [$name] you gained [${gainedStats.toStringForNotifications()}]!",
|
|
||||||
getTile().position, NotificationCategory.Units, name)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun removeFromTile() = currentTile.removeUnit(this)
|
fun removeFromTile() = currentTile.removeUnit(this)
|
||||||
|
|
||||||
|
|
||||||
|
@ -127,15 +127,6 @@ object Conditionals {
|
|||||||
UniqueType.ConditionalWhenBetweenStatResource ->
|
UniqueType.ConditionalWhenBetweenStatResource ->
|
||||||
checkResourceOrStatAmount(conditional.params[2], conditional.params[0].toFloat(), conditional.params[1].toFloat(), unique?.isModifiedByGameSpeed() == true)
|
checkResourceOrStatAmount(conditional.params[2], conditional.params[0].toFloat(), conditional.params[1].toFloat(), unique?.isModifiedByGameSpeed() == true)
|
||||||
{ current, lowerLimit, upperLimit -> current >= lowerLimit && current <= upperLimit }
|
{ current, lowerLimit, upperLimit -> current >= lowerLimit && current <= upperLimit }
|
||||||
UniqueType.ConditionalWhenAboveAmountStatResourceSpeed ->
|
|
||||||
checkResourceOrStatAmount(conditional.params[1], conditional.params[0].toFloat(), Float.MAX_VALUE, true)
|
|
||||||
{ current, lowerLimit, _ -> current > lowerLimit }
|
|
||||||
UniqueType.ConditionalWhenBelowAmountStatResourceSpeed ->
|
|
||||||
checkResourceOrStatAmount(conditional.params[1], Float.MIN_VALUE, conditional.params[0].toFloat(), true)
|
|
||||||
{ current, _, upperLimit -> current < upperLimit }
|
|
||||||
UniqueType.ConditionalWhenBetweenStatResourceSpeed ->
|
|
||||||
checkResourceOrStatAmount(conditional.params[2], conditional.params[0].toFloat(), conditional.params[1].toFloat(), true)
|
|
||||||
{ current, lowerLimit, upperLimit -> current >= lowerLimit && current <= upperLimit }
|
|
||||||
|
|
||||||
UniqueType.ConditionalHappy -> checkOnCiv { stats.happiness >= 0 }
|
UniqueType.ConditionalHappy -> checkOnCiv { stats.happiness >= 0 }
|
||||||
UniqueType.ConditionalBetweenHappiness ->
|
UniqueType.ConditionalBetweenHappiness ->
|
||||||
|
@ -154,10 +154,6 @@ enum class UniqueType(
|
|||||||
|
|
||||||
/// Great Persons
|
/// Great Persons
|
||||||
GreatPersonPointPercentage("[relativeAmount]% Great Person generation [cityFilter]", UniqueTarget.Global, UniqueTarget.FollowerBelief),
|
GreatPersonPointPercentage("[relativeAmount]% Great Person generation [cityFilter]", UniqueTarget.Global, UniqueTarget.FollowerBelief),
|
||||||
@Deprecated("As of 4.11.19", ReplaceWith("Gain [100] [Gold] <upon expending a [Great Person] unit> <(modified by game speed)>"))
|
|
||||||
ProvidesGoldWheneverGreatPersonExpended("Provides a sum of gold each time you spend a Great Person", UniqueTarget.Global),
|
|
||||||
@Deprecated("As of 4.11.19", ReplaceWith("Gain [amount] [stat] <upon expending a [Great Person] unit> <(modified by game speed)>"))
|
|
||||||
ProvidesStatsWheneverGreatPersonExpended("[stats] whenever a Great Person is expended", UniqueTarget.Global),
|
|
||||||
PercentGoldFromTradeMissions("[relativeAmount]% Gold from Great Merchant trade missions", UniqueTarget.Global),
|
PercentGoldFromTradeMissions("[relativeAmount]% Gold from Great Merchant trade missions", UniqueTarget.Global),
|
||||||
GreatGeneralProvidesDoubleCombatBonus("Great General provides double combat bonus", UniqueTarget.Unit, UniqueTarget.Global),
|
GreatGeneralProvidesDoubleCombatBonus("Great General provides double combat bonus", UniqueTarget.Unit, UniqueTarget.Global),
|
||||||
// This should probably support conditionals, e.g. <after discovering [tech]>
|
// This should probably support conditionals, e.g. <after discovering [tech]>
|
||||||
@ -224,8 +220,6 @@ enum class UniqueType(
|
|||||||
FreeExtraBeliefs("May choose [amount] additional [beliefType] beliefs when [foundingOrEnhancing] a religion", UniqueTarget.Global),
|
FreeExtraBeliefs("May choose [amount] additional [beliefType] beliefs when [foundingOrEnhancing] a religion", UniqueTarget.Global),
|
||||||
FreeExtraAnyBeliefs("May choose [amount] additional belief(s) of any type when [foundingOrEnhancing] a religion", UniqueTarget.Global),
|
FreeExtraAnyBeliefs("May choose [amount] additional belief(s) of any type when [foundingOrEnhancing] a religion", UniqueTarget.Global),
|
||||||
StatsWhenAdoptingReligion("[stats] when a city adopts this religion for the first time", UniqueTarget.Global, flags = setOf(UniqueFlag.AcceptsSpeedModifier)),
|
StatsWhenAdoptingReligion("[stats] when a city adopts this religion for the first time", UniqueTarget.Global, flags = setOf(UniqueFlag.AcceptsSpeedModifier)),
|
||||||
@Deprecated("As of 4.11.18", ReplaceWith("[stats] when a city adopts this religion for the first time <(modified by game speed)>"))
|
|
||||||
StatsWhenAdoptingReligionSpeed("[stats] when a city adopts this religion for the first time (modified by game speed)", UniqueTarget.Global),
|
|
||||||
NaturalReligionSpreadStrength("[relativeAmount]% Natural religion spread [cityFilter]", UniqueTarget.FollowerBelief, UniqueTarget.Global),
|
NaturalReligionSpreadStrength("[relativeAmount]% Natural religion spread [cityFilter]", UniqueTarget.FollowerBelief, UniqueTarget.Global),
|
||||||
ReligionSpreadDistance("Religion naturally spreads to cities [amount] tiles away", UniqueTarget.Global, UniqueTarget.FollowerBelief),
|
ReligionSpreadDistance("Religion naturally spreads to cities [amount] tiles away", UniqueTarget.Global, UniqueTarget.FollowerBelief),
|
||||||
MayNotGenerateGreatProphet("May not generate great prophet equivalents naturally", UniqueTarget.Global),
|
MayNotGenerateGreatProphet("May not generate great prophet equivalents naturally", UniqueTarget.Global),
|
||||||
@ -722,15 +716,6 @@ enum class UniqueType(
|
|||||||
ConditionalWhenBetweenStatResource("when between [amount] and [amount] [stat/resource]", UniqueTarget.Conditional, flags = setOf(UniqueFlag.AcceptsSpeedModifier),
|
ConditionalWhenBetweenStatResource("when between [amount] and [amount] [stat/resource]", UniqueTarget.Conditional, flags = setOf(UniqueFlag.AcceptsSpeedModifier),
|
||||||
docDescription = "Stats refers to the accumulated stat, not stat-per-turn"),
|
docDescription = "Stats refers to the accumulated stat, not stat-per-turn"),
|
||||||
|
|
||||||
// The game speed-adjusted versions of above
|
|
||||||
|
|
||||||
@Deprecated("As of 4.11.18", ReplaceWith("when above [amount] [stat/resource] <(modified by game speed)>"))
|
|
||||||
ConditionalWhenAboveAmountStatResourceSpeed("when above [amount] [stat/resource] (modified by game speed)", UniqueTarget.Conditional),
|
|
||||||
@Deprecated("As of 4.11.18", ReplaceWith("when below [amount] [stat/resource] <(modified by game speed)>"))
|
|
||||||
ConditionalWhenBelowAmountStatResourceSpeed("when below [amount] [stat/resource] (modified by game speed)", UniqueTarget.Conditional),
|
|
||||||
@Deprecated("As of 4.11.18", ReplaceWith("when between [amount] and [amount] [stat/resource] <(modified by game speed)>"))
|
|
||||||
ConditionalWhenBetweenStatResourceSpeed("when between [amount] and [amount] [stat/resource] (modified by game speed)", UniqueTarget.Conditional),
|
|
||||||
|
|
||||||
/////// city conditionals
|
/////// city conditionals
|
||||||
ConditionalInThisCity("in this city", UniqueTarget.Conditional),
|
ConditionalInThisCity("in this city", UniqueTarget.Conditional),
|
||||||
ConditionalCityFilter("in [cityFilter] cities", UniqueTarget.Conditional),
|
ConditionalCityFilter("in [cityFilter] cities", UniqueTarget.Conditional),
|
||||||
@ -953,6 +938,18 @@ enum class UniqueType(
|
|||||||
|
|
||||||
///////////////////////////////////////////// region 99 DEPRECATED AND REMOVED /////////////////////////////////////////////
|
///////////////////////////////////////////// region 99 DEPRECATED AND REMOVED /////////////////////////////////////////////
|
||||||
|
|
||||||
|
@Deprecated("As of 4.11.19", ReplaceWith("Gain [100] [Gold] <upon expending a [Great Person] unit> <(modified by game speed)>"), DeprecationLevel.ERROR)
|
||||||
|
ProvidesGoldWheneverGreatPersonExpended("Provides a sum of gold each time you spend a Great Person", UniqueTarget.Global),
|
||||||
|
@Deprecated("As of 4.11.19", ReplaceWith("Gain [amount] [stat] <upon expending a [Great Person] unit> <(modified by game speed)>"), DeprecationLevel.ERROR)
|
||||||
|
ProvidesStatsWheneverGreatPersonExpended("[stats] whenever a Great Person is expended", UniqueTarget.Global),
|
||||||
|
@Deprecated("As of 4.11.18", ReplaceWith("when above [amount] [stat/resource] <(modified by game speed)>"), DeprecationLevel.ERROR)
|
||||||
|
ConditionalWhenAboveAmountStatResourceSpeed("when above [amount] [stat/resource] (modified by game speed)", UniqueTarget.Conditional),
|
||||||
|
@Deprecated("As of 4.11.18", ReplaceWith("when below [amount] [stat/resource] <(modified by game speed)>"), DeprecationLevel.ERROR)
|
||||||
|
ConditionalWhenBelowAmountStatResourceSpeed("when below [amount] [stat/resource] (modified by game speed)", UniqueTarget.Conditional),
|
||||||
|
@Deprecated("As of 4.11.18", ReplaceWith("when between [amount] and [amount] [stat/resource] <(modified by game speed)>"), DeprecationLevel.ERROR)
|
||||||
|
ConditionalWhenBetweenStatResourceSpeed("when between [amount] and [amount] [stat/resource] (modified by game speed)", UniqueTarget.Conditional),
|
||||||
|
@Deprecated("As of 4.11.18", ReplaceWith("[stats] when a city adopts this religion for the first time <(modified by game speed)>"), DeprecationLevel.ERROR)
|
||||||
|
StatsWhenAdoptingReligionSpeed("[stats] when a city adopts this religion for the first time (modified by game speed)", UniqueTarget.Global),
|
||||||
@Deprecated("As of 4.10.17", ReplaceWith("Grants [+500 Gold] to the first civilization to discover it"), DeprecationLevel.ERROR)
|
@Deprecated("As of 4.10.17", ReplaceWith("Grants [+500 Gold] to the first civilization to discover it"), DeprecationLevel.ERROR)
|
||||||
GrantsGoldToFirstToDiscover("Grants 500 Gold to the first civilization to discover it", UniqueTarget.Terrain),
|
GrantsGoldToFirstToDiscover("Grants 500 Gold to the first civilization to discover it", UniqueTarget.Terrain),
|
||||||
@Deprecated("as of 4.10.17", ReplaceWith("[+100 Gold] for discovering a Natural Wonder (bonus enhanced to [+500 Gold] if first to discover it)"), DeprecationLevel.ERROR)
|
@Deprecated("as of 4.10.17", ReplaceWith("[+100 Gold] for discovering a Natural Wonder (bonus enhanced to [+500 Gold] if first to discover it)"), DeprecationLevel.ERROR)
|
||||||
|
@ -112,9 +112,13 @@ class UniqueValidator(val ruleset: Ruleset) {
|
|||||||
|
|
||||||
val resourceUniques = setOf(UniqueType.ProvidesResources, UniqueType.ConsumesResources,
|
val resourceUniques = setOf(UniqueType.ProvidesResources, UniqueType.ConsumesResources,
|
||||||
UniqueType.DoubleResourceProduced, UniqueType.StrategicResourcesIncrease)
|
UniqueType.DoubleResourceProduced, UniqueType.StrategicResourcesIncrease)
|
||||||
val resourceConditionals = setOf(UniqueType.ConditionalWithResource, UniqueType.ConditionalWithoutResource,
|
val resourceConditionals = setOf(
|
||||||
UniqueType.ConditionalWhenBetweenStatResource, UniqueType.ConditionalWhenAboveAmountStatResource, UniqueType.ConditionalWhenBelowAmountStatResource,
|
UniqueType.ConditionalWithResource,
|
||||||
UniqueType.ConditionalWhenAboveAmountStatResourceSpeed, UniqueType.ConditionalWhenBelowAmountStatResourceSpeed, UniqueType.ConditionalWhenBetweenStatResourceSpeed)
|
UniqueType.ConditionalWithoutResource,
|
||||||
|
UniqueType.ConditionalWhenBetweenStatResource,
|
||||||
|
UniqueType.ConditionalWhenAboveAmountStatResource,
|
||||||
|
UniqueType.ConditionalWhenBelowAmountStatResource,
|
||||||
|
)
|
||||||
|
|
||||||
private fun addConditionalErrors(
|
private fun addConditionalErrors(
|
||||||
conditional: Unique,
|
conditional: Unique,
|
||||||
|
@ -608,7 +608,7 @@ class GlobalUniquesTests {
|
|||||||
val tile = game.getTile(Vector2.Zero)
|
val tile = game.getTile(Vector2.Zero)
|
||||||
val city = game.addCity(civInfo, tile, true)
|
val city = game.addCity(civInfo, tile, true)
|
||||||
val unit = game.addUnit("Great Engineer", civInfo, tile)
|
val unit = game.addUnit("Great Engineer", civInfo, tile)
|
||||||
val building = game.createBuilding("[+250 Gold] whenever a Great Person is expended")
|
val building = game.createBuilding("Gain [250] [Gold] <upon expending a [Great Person] unit>")
|
||||||
city.cityConstructions.addBuilding(building)
|
city.cityConstructions.addBuilding(building)
|
||||||
|
|
||||||
civInfo.addGold(-civInfo.gold) // reset gold just to be sure
|
civInfo.addGold(-civInfo.gold) // reset gold just to be sure
|
||||||
|
Loading…
Reference in New Issue
Block a user