From 589a9fa29f5e78659e609366831c710b79765941 Mon Sep 17 00:00:00 2001 From: SeventhM <127357473+SeventhM@users.noreply.github.com> Date: Sun, 2 Jul 2023 04:53:06 -0700 Subject: [PATCH] Fix when units can be purchased (#9715) --- core/src/com/unciv/models/ruleset/IConstruction.kt | 2 +- core/src/com/unciv/models/ruleset/unit/BaseUnit.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/models/ruleset/IConstruction.kt b/core/src/com/unciv/models/ruleset/IConstruction.kt index 85f45d9395..c3c30e04b4 100644 --- a/core/src/com/unciv/models/ruleset/IConstruction.kt +++ b/core/src/com/unciv/models/ruleset/IConstruction.kt @@ -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 } diff --git a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt index f38e85d3d5..7e81cde9cd 100644 --- a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt +++ b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt @@ -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)