From 75d7494f893e5947e9cf6fd1f965f8370319afd8 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 9 Feb 2023 19:21:31 +0200 Subject: [PATCH] Resolved #8628 - modding: conditionally-unbuildable buildings display their cost --- core/src/com/unciv/logic/city/CityConstructions.kt | 3 ++- core/src/com/unciv/models/ruleset/Ruleset.kt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/logic/city/CityConstructions.kt b/core/src/com/unciv/logic/city/CityConstructions.kt index 0ce8b73175..488b4885a9 100644 --- a/core/src/com/unciv/logic/city/CityConstructions.kt +++ b/core/src/com/unciv/logic/city/CityConstructions.kt @@ -142,7 +142,8 @@ class CityConstructions : IsPartOfGameInfoSerialization { val turnsToConstruction = turnsToConstruction(constructionName, useStoredProduction) val currentProgress = if (useStoredProduction) getWorkDone(constructionName) else 0 val lines = ArrayList() - val buildable = construction.uniqueObjects.none{ it.isOfType(UniqueType.Unbuildable) } + val buildable = !construction.getMatchingUniques(UniqueType.Unbuildable) + .any { it.conditionalsApply(StateForConditionals(city.civ, city)) } if (buildable) lines += (if (currentProgress == 0) "" else "$currentProgress/") + "$cost${Fonts.production} $turnsToConstruction${Fonts.turn}" diff --git a/core/src/com/unciv/models/ruleset/Ruleset.kt b/core/src/com/unciv/models/ruleset/Ruleset.kt index 26c620371a..df81978345 100644 --- a/core/src/com/unciv/models/ruleset/Ruleset.kt +++ b/core/src/com/unciv/models/ruleset/Ruleset.kt @@ -415,7 +415,7 @@ class Ruleset { * */ fun updateBuildingCosts() { for (building in buildings.values) { - if (building.cost == 0 && !building.hasUnique(UniqueType.Unbuildable)) { + if (building.cost == 0 && building.getMatchingUniques(UniqueType.Unbuildable).none { it.conditionals.isEmpty() }) { 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