Fix when units can be purchased (#9715)

This commit is contained in:
SeventhM 2023-07-02 04:53:06 -07:00 committed by GitHub
parent 0edfa4841e
commit 589a9fa29f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -41,7 +41,6 @@ interface INonPerpetualConstruction : IConstruction, INamed, IHasUniques {
fun canBePurchasedWithStat(city: City?, stat: Stat): Boolean {
if (stat == Stat.Production || stat == Stat.Happiness) return false
if (hasUnique(UniqueType.CannotBePurchased)) return false
if (stat == Stat.Gold) return !hasUnique(UniqueType.Unbuildable)
// Can be purchased with [Stat] [cityFilter]
if (city != null && getMatchingUniques(UniqueType.CanBePurchasedWithStat)
.any { it.params[0] == stat.name && city.matchesFilter(it.params[1]) }
@ -50,6 +49,7 @@ interface INonPerpetualConstruction : IConstruction, INamed, IHasUniques {
if (city != null && getMatchingUniques(UniqueType.CanBePurchasedForAmountStat)
.any { it.params[1] == stat.name && city.matchesFilter(it.params[2]) }
) return true
if (stat == Stat.Gold) return !hasUnique(UniqueType.Unbuildable)
return false
}

View File

@ -89,7 +89,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
override fun canBePurchasedWithStat(city: City?, stat: Stat): Boolean {
if (city == null) return super.canBePurchasedWithStat(null, stat)
if (hasUnique(UniqueType.CannotBePurchased)) return false
if (getRejectionReasons(city.civ, city).any { it.type != RejectionReasonType.Unbuildable })
if (getRejectionReasons(city.cityConstructions).any { it.type != RejectionReasonType.Unbuildable })
return false
if (costFunctions.canBePurchasedWithStat(city, stat)) return true
return super.canBePurchasedWithStat(city, stat)