mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 05:46:43 -04:00
Fixed a bug where buying units with faith would not increase in cost (#5546)
This commit is contained in:
parent
6ac3547b8e
commit
074676c342
@ -534,19 +534,21 @@ class CityConstructions {
|
||||
if (!cityInfo.civInfo.gameInfo.gameParameters.godMode) {
|
||||
val construction = getConstruction(constructionName)
|
||||
if (construction is PerpetualConstruction) return false
|
||||
val constructionCost =
|
||||
(construction as INonPerpetualConstruction).getStatBuyCost(cityInfo, stat)
|
||||
val constructionCost = (construction as INonPerpetualConstruction).getStatBuyCost(cityInfo, stat)
|
||||
if (constructionCost == null) return false // We should never end up here anyway, so things have already gone _way_ wrong
|
||||
cityInfo.addStat(stat, -1 * constructionCost)
|
||||
|
||||
if (cityInfo.civInfo.getMatchingUniques("May buy [] units for [] [] [] starting from the [] at an increasing price ([])")
|
||||
.any {
|
||||
val conditionalState = StateForConditionals(civInfo = cityInfo.civInfo, cityInfo = cityInfo)
|
||||
|
||||
if ((
|
||||
cityInfo.civInfo.getMatchingUniques(UniqueType.BuyUnitsIncreasingCost, conditionalState) +
|
||||
cityInfo.civInfo.getMatchingUniques(UniqueType.BuyBuildingsIncreasingCost, conditionalState)
|
||||
).any {
|
||||
(
|
||||
construction is BaseUnit && construction.matchesFilter(it.params[0]) ||
|
||||
construction is Building && construction.matchesFilter(it.params[0])
|
||||
)
|
||||
&& cityInfo.matchesFilter(it.params[3])
|
||||
&& cityInfo.civInfo.getEraNumber() >= cityInfo.civInfo.gameInfo.ruleSet.eras[it.params[4]]!!.eraNumber
|
||||
&& it.params[2] == stat.name
|
||||
}
|
||||
) {
|
||||
|
@ -151,6 +151,7 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) {
|
||||
FreeExtraAnyBeliefs("May choose [amount] additional belief(s) of any type when [foundingOrEnhancing] a religion", UniqueTarget.Global),
|
||||
|
||||
BuyUnitsIncreasingCost("May buy [baseUnitFilter] units for [amount] [stat] [cityFilter] at an increasing price ([amount])", UniqueTarget.Global),
|
||||
BuyBuildingsIncreasingCost("May buy [buildingFilter] buildings for [amount] [stat] [cityFilter] at an increasing price ([amount])", UniqueTarget.Global),
|
||||
@Deprecated("As of 3.17.9", ReplaceWith ("May buy [baseUnitFilter] units for [amount] [stat] [cityFilter] at an increasing price ([amount]) <starting from the [era]>"))
|
||||
BuyUnitsIncreasingCostEra("May buy [baseUnitFilter] units for [amount] [stat] [cityFilter] starting from the [era] at an increasing price ([amount])", UniqueTarget.Global),
|
||||
BuyUnitsByProductionCost("May buy [baseUnitFilter] units with [stat] for [amount] times their normal Production cost", UniqueTarget.FollowerBelief, UniqueTarget.Global),
|
||||
|
@ -319,9 +319,8 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
||||
)
|
||||
}
|
||||
)
|
||||
+ (cityInfo.getMatchingUniques(
|
||||
UniqueType.BuyUnitsByProductionCost, conditionalState
|
||||
).filter {
|
||||
+ (cityInfo.getMatchingUniques(UniqueType.BuyUnitsByProductionCost, conditionalState)
|
||||
.filter {
|
||||
it.params[1] == stat.name
|
||||
&& matchesFilter(it.params[0])
|
||||
}.map {
|
||||
@ -481,7 +480,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
||||
if (unit.matchesFilter(unique.params[0]))
|
||||
XP += unique.params[1].toInt()
|
||||
}
|
||||
unit.promotions.XP = XP
|
||||
unit.promotions.XP = XP
|
||||
|
||||
for (unique in cityConstructions.cityInfo.getMatchingUniques("All newly-trained [] units [] receive the [] promotion")
|
||||
.filter { cityConstructions.cityInfo.matchesFilter(it.params[1]) }) {
|
||||
@ -490,13 +489,13 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
||||
|
||||
if (unit.matchesFilter(filter)
|
||||
|| (
|
||||
filter == "relevant"
|
||||
&& civInfo.gameInfo.ruleSet.unitPromotions.values
|
||||
.any {
|
||||
it.name == promotion
|
||||
&& unit.type.name in it.unitTypes
|
||||
}
|
||||
)
|
||||
filter == "relevant"
|
||||
&& civInfo.gameInfo.ruleSet.unitPromotions.values
|
||||
.any {
|
||||
it.name == promotion
|
||||
&& unit.type.name in it.unitTypes
|
||||
}
|
||||
)
|
||||
) {
|
||||
unit.promotions.addPromotion(promotion, isFree = true)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user