Fix Puppets building wonders (#11480)

* Fix Puppets building wonders

* Revert 'Disallow wonders from being selected in puppets, even when 'just' choosing best stat building'

* Simplify wonder logic to not check national wonders separately

* Whoops, world wonder and national wonders have different already built checks
This commit is contained in:
SeventhM 2024-04-21 05:29:51 -07:00 committed by GitHub
parent 2193e24364
commit 371690a678
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 18 deletions

View File

@ -256,9 +256,8 @@ object Automation {
city: City,
construction: INonPerpetualConstruction
): Boolean {
return !(construction is Building && construction.isWonder && city.isPuppet)
&& allowCreateImprovementBuildings(civInfo, city, construction)
&& allowSpendingResource(civInfo, construction, city)
return allowCreateImprovementBuildings(civInfo, city, construction)
&& allowSpendingResource(civInfo, construction, city)
}
@Suppress("MemberVisibilityCanBePrivate")

View File

@ -388,32 +388,32 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
if (!civ.tech.isResearched(requiredTech))
yield(RejectionReasonType.RequiresTech.toInstance("$requiredTech not researched!"))
// Regular wonders
if (isWonder) {
if (civ.gameInfo.getCities().any { it.cityConstructions.isBuilt(name) })
yield(RejectionReasonType.WonderAlreadyBuilt.toInstance())
// All Wonders
if(isAnyWonder()) {
if (civ.cities.any { it != cityConstructions.city && it.cityConstructions.isBeingConstructedOrEnqueued(name) })
yield(RejectionReasonType.WonderBeingBuiltElsewhere.toInstance())
if (civ.isCityState())
yield(RejectionReasonType.CityStateWonder.toInstance())
if (cityConstructions.city.isPuppet)
yield(RejectionReasonType.PuppetWonder.toInstance())
}
// World Wonders
if (isWonder) {
if (civ.gameInfo.getCities().any { it.cityConstructions.isBuilt(name) })
yield(RejectionReasonType.WonderAlreadyBuilt.toInstance())
val startingEra = civ.gameInfo.gameParameters.startingEra
if (name in ruleSet.eras[startingEra]!!.startingObsoleteWonders)
yield(RejectionReasonType.WonderDisabledEra.toInstance())
}
// National wonders
// National Wonders
if (isNationalWonder) {
if (civ.cities.any { it.cityConstructions.isBuilt(name) })
yield(RejectionReasonType.NationalWonderAlreadyBuilt.toInstance())
if (civ.cities.any { it != cityConstructions.city && it.cityConstructions.isBeingConstructedOrEnqueued(name) })
yield(RejectionReasonType.NationalWonderBeingBuiltElsewhere.toInstance())
if (civ.isCityState())
yield(RejectionReasonType.CityStateNationalWonder.toInstance())
}
if (requiredBuilding != null && !cityConstructions.containsBuildingOrEquivalent(requiredBuilding!!)) {

View File

@ -143,7 +143,6 @@ class RejectionReason(val type: RejectionReasonType,
private val orderedImportantRejectionTypes = listOf(
RejectionReasonType.ShouldNotBeDisplayed,
RejectionReasonType.WonderBeingBuiltElsewhere,
RejectionReasonType.NationalWonderBeingBuiltElsewhere,
RejectionReasonType.RequiresBuildingInAllCities,
RejectionReasonType.RequiresBuildingInThisCity,
RejectionReasonType.RequiresBuildingInSomeCity,
@ -206,9 +205,8 @@ enum class RejectionReasonType(val shouldShow: Boolean, val errorMessage: String
WonderAlreadyBuilt(false, "Wonder already built"),
NationalWonderAlreadyBuilt(false, "National Wonder already built"),
WonderBeingBuiltElsewhere(true, "Wonder is being built elsewhere"),
NationalWonderBeingBuiltElsewhere(true, "National Wonder is being built elsewhere"),
CityStateWonder(false, "No Wonders for city-states"),
CityStateNationalWonder(false, "No National Wonders for city-states"),
PuppetWonder(false, "No Wonders for Puppets"),
WonderDisabledEra(false, "This Wonder is disabled when starting in this era"),
ConsumesResources(true, "Consumes resources which you are lacking"),