Fixed a bug where unit discounts would not work (#6081)

This commit is contained in:
Xander Lenstra 2022-02-01 08:43:25 +01:00 committed by GitHub
parent f6e22f60bf
commit 0951e5d6fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 4 deletions

View File

@ -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), 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), 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 // Should be replaced with moddable improvements when roads become moddable
RoadMovementSpeed("Improves movement speed on roads",UniqueTarget.Global), RoadMovementSpeed("Improves movement speed on roads",UniqueTarget.Global),

View File

@ -324,7 +324,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
var cost = getBaseBuyCost(cityInfo, stat)?.toDouble() var cost = getBaseBuyCost(cityInfo, stat)?.toDouble()
if (cost == null) return null 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])) if (stat.name == unique.params[0] && matchesFilter(unique.params[1]))
cost *= unique.params[2].toPercent() cost *= unique.params[2].toPercent()
} }

View File

@ -313,8 +313,8 @@ Example: "[Culture] cost of purchasing [Culture] buildings [20]%"
Applicable to: Global, FollowerBelief Applicable to: Global, FollowerBelief
#### [stat] cost of purchasing [baseUnitFilter] units in cities [amount]% #### [stat] cost of purchasing [baseUnitFilter] units [amount]%
Example: "[Culture] cost of purchasing [Melee] units in cities [20]%" Example: "[Culture] cost of purchasing [Melee] units [20]%"
Applicable to: Global, FollowerBelief 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]% 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]% 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]" - "-[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" - "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]% 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" - "+[amount] happiness from each type of luxury resource" - Deprecated As of 3.18.17, replace with "[+amount] Happiness from each type of luxury resource"