From 0951e5d6fd091e21b0d8546ba5a4a9eafe07f3dc Mon Sep 17 00:00:00 2001 From: Xander Lenstra <71121390+xlenstra@users.noreply.github.com> Date: Tue, 1 Feb 2022 08:43:25 +0100 Subject: [PATCH] Fixed a bug where unit discounts would not work (#6081) --- core/src/com/unciv/models/ruleset/unique/UniqueType.kt | 4 +++- core/src/com/unciv/models/ruleset/unit/BaseUnit.kt | 2 +- docs/uniques.md | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt index d3ffdaeec2..b8624e3628 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt @@ -208,7 +208,9 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags: BuyItemsDiscount("[stat] cost of purchasing items in cities [amount]%", UniqueTarget.Global, UniqueTarget.FollowerBelief), BuyBuildingsDiscount("[stat] cost of purchasing [buildingFilter] buildings [amount]%", UniqueTarget.Global, UniqueTarget.FollowerBelief), - BuyUnitsDiscount("[stat] cost of purchasing [baseUnitFilter] units in cities [amount]%", UniqueTarget.Global, UniqueTarget.FollowerBelief), + BuyUnitsDiscount("[stat] cost of purchasing [baseUnitFilter] units [amount]%", UniqueTarget.Global, UniqueTarget.FollowerBelief), + @Deprecated("As of 3.19.3", ReplaceWith("[stat] cost of purchasing [baseUnitFilter] units [amount]%")) + BuyUnitsDiscountDeprecated("[stat] cost of purchasing [baseUnitFilter] units in cities [amount]%", UniqueTarget.Global, UniqueTarget.FollowerBelief), // Should be replaced with moddable improvements when roads become moddable RoadMovementSpeed("Improves movement speed on roads",UniqueTarget.Global), diff --git a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt index 6b607d8372..2b824a5fda 100644 --- a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt +++ b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt @@ -324,7 +324,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction { var cost = getBaseBuyCost(cityInfo, stat)?.toDouble() if (cost == null) return null - for (unique in cityInfo.getMatchingUniques(UniqueType.BuyUnitsDiscount)) { + for (unique in cityInfo.getMatchingUniques(UniqueType.BuyUnitsDiscount) + cityInfo.getMatchingUniques(UniqueType.BuyUnitsDiscountDeprecated)) { if (stat.name == unique.params[0] && matchesFilter(unique.params[1])) cost *= unique.params[2].toPercent() } diff --git a/docs/uniques.md b/docs/uniques.md index 49acd13f64..d623500ff5 100644 --- a/docs/uniques.md +++ b/docs/uniques.md @@ -313,8 +313,8 @@ Example: "[Culture] cost of purchasing [Culture] buildings [20]%" Applicable to: Global, FollowerBelief -#### [stat] cost of purchasing [baseUnitFilter] units in cities [amount]% -Example: "[Culture] cost of purchasing [Melee] units in cities [20]%" +#### [stat] cost of purchasing [baseUnitFilter] units [amount]% +Example: "[Culture] cost of purchasing [Melee] units [20]%" Applicable to: Global, FollowerBelief @@ -1434,6 +1434,7 @@ Applicable to: Conditional - "-[amount]% Culture cost of acquiring tiles [cityFilter]" - Deprecated As of 3.19.1, replace with "[-amount]% Culture cost of natural border growth [cityFilter]" - "[amount]% cost of natural border growth" - Deprecated As of 3.19.1, replace with "[amount]% Culture cost of natural border growth [cityFilter]" - "-[amount]% Gold cost of acquiring tiles [cityFilter]" - Deprecated As of 3.19.1, replace with "[-amount]% Gold cost of acquiring tiles [cityFilter]" + - "[stat] cost of purchasing [baseUnitFilter] units in cities [amount]%" - Deprecated As of 3.19.3, replace with "[stat] cost of purchasing [baseUnitFilter] units [amount]%" - "Maintenance on roads & railroads reduced by [amount]%" - Deprecated As of 3.18.17, replace with "[-amount]% maintenance on road & railroads" - "-[amount]% maintenance cost for buildings [cityFilter]" - Deprecated As of 3.18.17, replace with "[-amount]% maintenance cost for buildings [cityFilter]" - "+[amount] happiness from each type of luxury resource" - Deprecated As of 3.18.17, replace with "[+amount] Happiness from each type of luxury resource"