mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-05 21:11:35 +07:00
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:
parent
df5ecf83a1
commit
ef8deffe67
@ -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())
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user