From c142d1508ce0d0c94bb6b83082b8edebd7107d7d Mon Sep 17 00:00:00 2001 From: dHannasch Date: Sun, 3 Dec 2023 13:14:28 -0700 Subject: [PATCH] Add iHasUniques.techColumn() (#10595) * Update IHasUniques.kt * Update IHasUniques.kt * Update IConstruction.kt * Update IHasUniques.kt * Update CivInfoTransientCache.kt * Update UnitUpgradeManager.kt * Update WonderOverviewTab.kt * Update IHasUniques.kt * Update IHasUniques.kt * Update Ruleset.kt * Update IHasUniques.kt * Update IHasUniques.kt * Update IHasUniques.kt * Update IHasUniques.kt --- core/src/com/unciv/models/ruleset/Ruleset.kt | 2 +- core/src/com/unciv/models/ruleset/unique/IHasUniques.kt | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/com/unciv/models/ruleset/Ruleset.kt b/core/src/com/unciv/models/ruleset/Ruleset.kt index b8d5030239..fc12baf59a 100644 --- a/core/src/com/unciv/models/ruleset/Ruleset.kt +++ b/core/src/com/unciv/models/ruleset/Ruleset.kt @@ -406,7 +406,7 @@ class Ruleset { fun updateBuildingCosts() { for (building in buildings.values) { if (building.cost == -1 && building.getMatchingUniques(UniqueType.Unbuildable).none { it.conditionals.isEmpty() }) { - val column = technologies[building.requiredTech]?.column + val column = building.techColumn(this) if (column != null) { building.cost = if (building.isAnyWonder()) column.wonderCost else column.buildingCost } diff --git a/core/src/com/unciv/models/ruleset/unique/IHasUniques.kt b/core/src/com/unciv/models/ruleset/unique/IHasUniques.kt index 654c06b3d9..3a9ee9ae28 100644 --- a/core/src/com/unciv/models/ruleset/unique/IHasUniques.kt +++ b/core/src/com/unciv/models/ruleset/unique/IHasUniques.kt @@ -2,6 +2,7 @@ package com.unciv.models.ruleset.unique import com.unciv.models.ruleset.Ruleset import com.unciv.models.ruleset.tech.Era +import com.unciv.models.ruleset.tech.TechColumn import com.unciv.models.ruleset.tech.Technology import com.unciv.models.stats.INamed @@ -68,6 +69,10 @@ interface IHasUniques : INamed { requiredTechnologies(ruleset).map{ it.era() }.map{ ruleset.eras[it]!! }.maxByOrNull{ it.eraNumber } // This will return null only if requiredTechnologies() is empty. + fun techColumn(ruleset: Ruleset): TechColumn? = + requiredTechnologies(ruleset).map{ it.column }.filterNotNull().maxByOrNull{ it.columnNumber } + // This will return null only if *all* required techs have null TechColumn. + fun availableInEra(ruleset: Ruleset, requestedEra: String): Boolean { val eraAvailable: Era? = era(ruleset) if (eraAvailable == null)