mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-10 15:27:27 +07:00
Fix objects being purchable with a blocking conditional (#10618)
This commit is contained in:
parent
6617504c05
commit
58e5139f35
@ -45,17 +45,18 @@ interface INonPerpetualConstruction : IConstruction, INamed, IHasUniques {
|
||||
|
||||
/** Only checks if it has the unique to be bought with this stat, not whether it is purchasable at all */
|
||||
fun canBePurchasedWithStat(city: City?, stat: Stat): Boolean {
|
||||
val stateForConditionals = StateForConditionals(city?.civ, city)
|
||||
if (stat == Stat.Production || stat == Stat.Happiness) return false
|
||||
if (hasUnique(UniqueType.CannotBePurchased)) return false
|
||||
if (hasUnique(UniqueType.CannotBePurchased, stateForConditionals)) return false
|
||||
// Can be purchased with [Stat] [cityFilter]
|
||||
if (city != null && getMatchingUniques(UniqueType.CanBePurchasedWithStat)
|
||||
if (city != null && getMatchingUniques(UniqueType.CanBePurchasedWithStat, stateForConditionals)
|
||||
.any { it.params[0] == stat.name && city.matchesFilter(it.params[1]) }
|
||||
) return true
|
||||
// Can be purchased for [amount] [Stat] [cityFilter]
|
||||
if (city != null && getMatchingUniques(UniqueType.CanBePurchasedForAmountStat)
|
||||
if (city != null && getMatchingUniques(UniqueType.CanBePurchasedForAmountStat, stateForConditionals)
|
||||
.any { it.params[1] == stat.name && city.matchesFilter(it.params[2]) }
|
||||
) return true
|
||||
if (stat == Stat.Gold) return !hasUnique(UniqueType.Unbuildable)
|
||||
if (stat == Stat.Gold) return !hasUnique(UniqueType.Unbuildable, stateForConditionals)
|
||||
return false
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user