From ef8deffe67ca210883c1c5179eccf4f16e1f038f Mon Sep 17 00:00:00 2001 From: SeventhM <127357473+SeventhM@users.noreply.github.com> Date: Sun, 27 Aug 2023 23:10:44 -0700 Subject: [PATCH] Allow buildings to require population, Allow buildings to use condtionals (#9987) * Allow buildings to require population, Allow buildings to use condtionals * Almost forgot the conditional part, whoops * Fix unintended error --- core/src/com/unciv/models/ruleset/Building.kt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/core/src/com/unciv/models/ruleset/Building.kt b/core/src/com/unciv/models/ruleset/Building.kt index ad586022aa..01d753301b 100644 --- a/core/src/com/unciv/models/ruleset/Building.kt +++ b/core/src/com/unciv/models/ruleset/Building.kt @@ -463,18 +463,26 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction { if (cityConstructions.isBuilt(name)) yield(RejectionReasonType.AlreadyBuilt.toInstance()) - // for buildings that are created as side effects of other things, and not directly built, - // or for buildings that can only be bought - if (hasUnique(UniqueType.Unbuildable, StateForConditionals(civ, cityConstructions.city))) - yield(RejectionReasonType.Unbuildable.toInstance()) for (unique in uniqueObjects) { + if (unique.type != UniqueType.OnlyAvailableWhen && + !unique.conditionalsApply(StateForConditionals(civ, cityConstructions.city))) continue + @Suppress("NON_EXHAUSTIVE_WHEN") when (unique.type) { - UniqueType.OnlyAvailableWhen-> + // for buildings that are created as side effects of other things, and not directly built, + // or for buildings that can only be bought + UniqueType.Unbuildable -> + yield(RejectionReasonType.Unbuildable.toInstance()) + + UniqueType.OnlyAvailableWhen -> if (!unique.conditionalsApply(civ, cityConstructions.city)) yield(RejectionReasonType.ShouldNotBeDisplayed.toInstance()) + UniqueType.RequiresPopulation -> + if (unique.params[0].toInt() > cityConstructions.city.population.population) + yield(RejectionReasonType.PopulationRequirement.toInstance(unique.text)) + UniqueType.EnablesNuclearWeapons -> if (!cityConstructions.city.civ.gameInfo.gameParameters.nuclearWeaponsEnabled) yield(RejectionReasonType.DisabledBySetting.toInstance())