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
This commit is contained in:
SeventhM 2023-08-27 23:10:44 -07:00 committed by GitHub
parent df5ecf83a1
commit ef8deffe67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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())