From a06a4531beb1caf3c9b171968ac069b02643be44 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Tue, 7 Jul 2020 22:49:36 +0300 Subject: [PATCH] Great improvements are no longer hardcoded, so new great improvements can be modded in =) --- core/src/com/unciv/Constants.kt | 1 - core/src/com/unciv/logic/map/TileInfo.kt | 7 +++---- core/src/com/unciv/models/ruleset/Building.kt | 2 +- core/src/com/unciv/models/ruleset/tile/TileImprovement.kt | 1 + core/src/com/unciv/ui/mapeditor/TileEditorOptionsTable.kt | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/core/src/com/unciv/Constants.kt b/core/src/com/unciv/Constants.kt index e28b9d96..ff4b4197 100644 --- a/core/src/com/unciv/Constants.kt +++ b/core/src/com/unciv/Constants.kt @@ -46,7 +46,6 @@ object Constants { const val researchAgreement = "Research Agreement" const val openBorders = "Open Borders" const val random = "Random" - val greatImprovements = listOf("Academy", "Landmark", "Manufactory", "Customs house", "Citadel") const val fort = "Fort" const val citadel = "Citadel" diff --git a/core/src/com/unciv/logic/map/TileInfo.kt b/core/src/com/unciv/logic/map/TileInfo.kt index ab8ae31f..63a7da8c 100644 --- a/core/src/com/unciv/logic/map/TileInfo.kt +++ b/core/src/com/unciv/logic/map/TileInfo.kt @@ -69,13 +69,12 @@ open class TileInfo { } fun containsGreatImprovement(): Boolean { - if (improvement in Constants.greatImprovements) return true - return false + return getTileImprovement()?.isGreatImprovement() == true } fun containsUnfinishedGreatImprovement(): Boolean { - if (improvementInProgress in Constants.greatImprovements) return true - return false + if(improvementInProgress==null) return false + return ruleset.tileImprovements[improvementInProgress!!]!!.isGreatImprovement() } fun containsUnique(unique: String): Boolean = diff --git a/core/src/com/unciv/models/ruleset/Building.kt b/core/src/com/unciv/models/ruleset/Building.kt index af052ba5..98a888bf 100644 --- a/core/src/com/unciv/models/ruleset/Building.kt +++ b/core/src/com/unciv/models/ruleset/Building.kt @@ -316,7 +316,7 @@ class Building : NamedStats(), IConstruction{ it.resource != null && requiredNearbyImprovedResources!!.contains(it.resource!!) && it.getOwner() == civInfo - && (it.getTileResource().improvement == it.improvement || it.improvement in Constants.greatImprovements || it.isCityCenter()) + && (it.getTileResource().improvement == it.improvement || it.getTileImprovement()?.isGreatImprovement()==true || it.isCityCenter()) } if (!containsResourceWithImprovement) return "Nearby $requiredNearbyImprovedResources required" } diff --git a/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt b/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt index 393c1e37..812668e3 100644 --- a/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt +++ b/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt @@ -70,5 +70,6 @@ class TileImprovement : NamedStats() { } fun hasUnique(unique: String) = uniques.contains(unique) + fun isGreatImprovement() = hasUnique("Great improvement") } diff --git a/core/src/com/unciv/ui/mapeditor/TileEditorOptionsTable.kt b/core/src/com/unciv/ui/mapeditor/TileEditorOptionsTable.kt index 88c019dd..3c5b68cc 100644 --- a/core/src/com/unciv/ui/mapeditor/TileEditorOptionsTable.kt +++ b/core/src/com/unciv/ui/mapeditor/TileEditorOptionsTable.kt @@ -535,7 +535,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera improvement.terrainsCanBeBuiltOn.isEmpty() && improvement.turnsToBuild == 0 // Allow Great Improvement but clear unbuildable terrain feature // Allow barbarian camps, ruins and similar without clear - -> if (topTerrain.unbuildable && improvement.name in Constants.greatImprovements) + -> if (topTerrain.unbuildable && improvement.isGreatImprovement()) tileInfo.terrainFeature = null topTerrain.unbuildable -> tileInfo.improvement = null // forbid on unbuildable feature