diff --git a/core/src/com/unciv/logic/city/CityConstructions.kt b/core/src/com/unciv/logic/city/CityConstructions.kt index f7654c7e43..624c83a38d 100644 --- a/core/src/com/unciv/logic/city/CityConstructions.kt +++ b/core/src/com/unciv/logic/city/CityConstructions.kt @@ -205,7 +205,7 @@ class CityConstructions { val turnsToConstruction = turnsToConstruction(constructionName, useStoredProduction) val currentProgress = if (useStoredProduction) getWorkDone(constructionName) else 0 val lines = ArrayList() - val buildable = construction.uniques.none{ it == "Unbuildable" } + val buildable = construction.uniqueObjects.none{ it.isOfType(UniqueType.Unbuildable) } if (buildable) lines += (if (currentProgress == 0) "" else "$currentProgress/") + "$cost${Fonts.production} $turnsToConstruction${Fonts.turn}" diff --git a/core/src/com/unciv/logic/city/IConstruction.kt b/core/src/com/unciv/logic/city/IConstruction.kt index b0bfdc3b06..274ec33f8d 100644 --- a/core/src/com/unciv/logic/city/IConstruction.kt +++ b/core/src/com/unciv/logic/city/IConstruction.kt @@ -2,6 +2,7 @@ package com.unciv.logic.city import com.unciv.logic.civilization.CivilizationInfo import com.unciv.models.ruleset.IHasUniques +import com.unciv.models.ruleset.unique.UniqueType import com.unciv.models.stats.INamed import com.unciv.models.stats.Stat import com.unciv.ui.utils.Fonts @@ -27,7 +28,7 @@ interface INonPerpetualConstruction : IConstruction, INamed, IHasUniques { fun canBePurchasedWithStat(cityInfo: CityInfo?, stat: Stat): Boolean { if (stat in listOf(Stat.Production, Stat.Happiness)) return false if ("Cannot be purchased" in uniques) return false - if (stat == Stat.Gold) return !uniques.contains("Unbuildable") + if (stat == Stat.Gold) return !hasUnique(UniqueType.Unbuildable) // Can be purchased with [Stat] [cityFilter] if (getMatchingUniques("Can be purchased with [] []") .any { it.params[0] == stat.name && (cityInfo != null && cityInfo.matchesFilter(it.params[1])) } diff --git a/core/src/com/unciv/models/ruleset/Building.kt b/core/src/com/unciv/models/ruleset/Building.kt index 8b772225b5..296c54a629 100644 --- a/core/src/com/unciv/models/ruleset/Building.kt +++ b/core/src/com/unciv/models/ruleset/Building.kt @@ -107,7 +107,7 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction { private fun getUniquesStringsWithoutDisablers() = getUniquesStrings() .filterNot { it.startsWith("Hidden ") && it.endsWith(" disabled") || - it == "Unbuildable" || + it == UniqueType.Unbuildable.text || it == Constants.hideFromCivilopediaUnique } @@ -403,7 +403,7 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction { rejectionReasons.add(RejectionReason.AlreadyBuilt) // for buildings that are created as side effects of other things, and not directly built, // or for buildings that can only be bought - if (uniques.contains("Unbuildable")) + if (hasUnique(UniqueType.Unbuildable)) rejectionReasons.add(RejectionReason.Unbuildable) for (unique in uniqueObjects) { @@ -467,7 +467,7 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction { if (civInfo.tech.isResearched(unique.params[0])) rejectionReasons.add(RejectionReason.Obsoleted.apply { errorMessage = unique.text }) - "Hidden when religion is disabled" -> + UniqueType.HiddenWithoutReligion.text -> if (!civInfo.gameInfo.isReligionEnabled()) rejectionReasons.add(RejectionReason.DisabledBySetting) } diff --git a/core/src/com/unciv/models/ruleset/Ruleset.kt b/core/src/com/unciv/models/ruleset/Ruleset.kt index 5b05d38010..661a291709 100644 --- a/core/src/com/unciv/models/ruleset/Ruleset.kt +++ b/core/src/com/unciv/models/ruleset/Ruleset.kt @@ -256,7 +256,7 @@ class Ruleset { * */ fun updateBuildingCosts() { for (building in buildings.values) { - if (building.cost == 0 && !building.uniques.contains("Unbuildable")) { + if (building.cost == 0 && !building.hasUnique(UniqueType.Unbuildable)) { val column = technologies[building.requiredTech]?.column ?: throw UncivShowableException("Building (${building.name}) is buildable and therefore must either have an explicit cost or reference an existing tech") building.cost = if (building.isAnyWonder()) column.wonderCost else column.buildingCost @@ -393,7 +393,7 @@ class Ruleset { } for (building in buildings.values) { - if (building.requiredTech == null && building.cost == 0 && !building.uniques.contains("Unbuildable")) + if (building.requiredTech == null && building.cost == 0 && !building.hasUnique(UniqueType.Unbuildable)) lines += "${building.name} is buildable and therefore must either have an explicit cost or reference an existing tech!" checkUniques(building, lines, UniqueType.UniqueComplianceErrorSeverity.RulesetInvariant) diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt index 328c904255..592b0bcd6c 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt @@ -138,6 +138,12 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) { MayanGainGreatPerson("Receive a free Great Person at the end of every [comment] (every 394 years), after researching [tech]. Each bonus person can only be chosen once.", UniqueTarget.Nation), MayanCalendarDisplay("Once The Long Count activates, the year on the world screen displays as the traditional Mayan Long Count.", UniqueTarget.Nation), + ///////////////////////////////////////// BUILDING UNIQUES ///////////////////////////////////////// + + Unbuildable("Unbuildable", UniqueTarget.Building), + + + ///////////////////////////////////////// UNIT UNIQUES ///////////////////////////////////////// FoundCity("Founds a new city", UniqueTarget.Unit), diff --git a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt index 32fa8b0b2d..e75439eb12 100644 --- a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt +++ b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt @@ -90,7 +90,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction { if (replacementTextForUniques != "") lines += replacementTextForUniques else for (unique in uniques.filterNot { - it.startsWith("Hidden ") && it.endsWith(" disabled") || it == "Unbuildable" + it.startsWith("Hidden ") && it.endsWith(" disabled") || it == UniqueType.Unbuildable.text }) lines += unique.tr() @@ -382,7 +382,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction { val rejectionReasons = RejectionReasons() val ruleSet = civInfo.gameInfo.ruleSet - if (uniques.contains("Unbuildable")) + if (hasUnique(UniqueType.Unbuildable)) rejectionReasons.add(RejectionReason.Unbuildable) if (requiredTech != null && !civInfo.tech.isResearched(requiredTech!!))