From e8bbd4bc706422a0047d0091d44694ff30911a96 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Tue, 8 Jun 2021 20:01:49 +0300 Subject: [PATCH] Resource.building, Building.resourceBonusStats deprecated in favor of '[stats] from [resource] tiles in this city' unique --- .../logic/automation/ConstructionAutomation.kt | 2 -- core/src/com/unciv/logic/map/TileInfo.kt | 12 ++---------- core/src/com/unciv/models/ruleset/Building.kt | 17 ----------------- .../unciv/models/ruleset/tile/TileResource.kt | 7 ------- .../ui/worldscreen/bottombar/BattleTable.kt | 6 ++---- 5 files changed, 4 insertions(+), 40 deletions(-) diff --git a/core/src/com/unciv/logic/automation/ConstructionAutomation.kt b/core/src/com/unciv/logic/automation/ConstructionAutomation.kt index 68b309f357..0bfeff71b0 100644 --- a/core/src/com/unciv/logic/automation/ConstructionAutomation.kt +++ b/core/src/com/unciv/logic/automation/ConstructionAutomation.kt @@ -279,8 +279,6 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){ } private fun addProductionBuildingChoice() { - val hasWaterResource = cityInfo.tilesInRange - .any { it.isWater && it.resource!=null && it.position in cityInfo.tiles } val productionBuilding = buildableNotWonders.asSequence() .filter { it.isStatRelated(Stat.Production) } .minByOrNull { it.cost } diff --git a/core/src/com/unciv/logic/map/TileInfo.kt b/core/src/com/unciv/logic/map/TileInfo.kt index 93da2d2bcc..d96c818c64 100644 --- a/core/src/com/unciv/logic/map/TileInfo.kt +++ b/core/src/com/unciv/logic/map/TileInfo.kt @@ -253,16 +253,8 @@ open class TileInfo { stats.add(wonder) } } - - if (hasViewableResource(observingCiv)) { - val resource = getTileResource() - stats.add(getTileResource()) // resource base - if (resource.building != null && city != null && city.cityConstructions.isBuilt(resource.building!!)) { - val resourceBuilding = tileMap.gameInfo.ruleSet.buildings[resource.building!!] - if (resourceBuilding?.resourceBonusStats != null) - stats.add(resourceBuilding.resourceBonusStats!!) // resource-specific building (eg forge, stable) bonus - } - } + // resource base + if (hasViewableResource(observingCiv)) stats.add(getTileResource()) val improvement = getTileImprovement() if (improvement != null) diff --git a/core/src/com/unciv/models/ruleset/Building.kt b/core/src/com/unciv/models/ruleset/Building.kt index f030940f9b..8136a7c9c0 100644 --- a/core/src/com/unciv/models/ruleset/Building.kt +++ b/core/src/com/unciv/models/ruleset/Building.kt @@ -64,12 +64,6 @@ class Building : NamedStats(), IConstruction { var replacementTextForUniques = "" val uniqueObjects: List by lazy { uniques.map { Unique(it) } } - /** - * The bonus stats that a resource gets when this building is built - */ - @Deprecated("Since 3.13.3 - replaced with '[stats] from [resource] tiles in this city'") - var resourceBonusStats: Stats? = null - fun getShortDescription(ruleset: Ruleset): String { // should fit in one line val infoList = mutableListOf() val str = getStats(null).toString() @@ -77,11 +71,6 @@ class Building : NamedStats(), IConstruction { for (stat in getStatPercentageBonuses(null).toHashMap()) if (stat.value != 0f) infoList += "+${stat.value.toInt()}% ${stat.key.name.tr()}" - val improvedResources = ruleset.tileResources.values.asSequence().filter { it.building == name }.map { it.name.tr() } - if (improvedResources.any()) { - // buildings that improve resources - infoList += improvedResources.joinToString() + " {provide} " + resourceBonusStats.toString() - } if (requiredNearbyImprovedResources != null) infoList += "Requires worked [" + requiredNearbyImprovedResources!!.joinToString("/") { it.tr() } + "] near city" if (uniques.isNotEmpty()) { @@ -152,11 +141,6 @@ class Building : NamedStats(), IConstruction { for ((specialistName, amount) in newSpecialists()) stringBuilder.appendLine("+$amount " + "[$specialistName] slots".tr()) - if (resourceBonusStats != null) { - val resources = ruleset.tileResources.values.filter { name == it.building }.joinToString { it.name.tr() } - stringBuilder.appendLine("$resources {provide} $resourceBonusStats".tr()) - } - if (requiredNearbyImprovedResources != null) stringBuilder.appendLine(("Requires worked [" + requiredNearbyImprovedResources!!.joinToString("/") { it.tr() } + "] near city").tr()) @@ -457,7 +441,6 @@ class Building : NamedStats(), IConstruction { fun isStatRelated(stat: Stat): Boolean { if (get(stat) > 0) return true if (getStatPercentageBonuses(null).get(stat) > 0) return true - if (resourceBonusStats != null && resourceBonusStats!!.get(stat) > 0) return true if (uniqueObjects.any { it.placeholderText == "[] Per [] Population in this city" && it.stats.get(stat) > 0 }) return true return false } diff --git a/core/src/com/unciv/models/ruleset/tile/TileResource.kt b/core/src/com/unciv/models/ruleset/tile/TileResource.kt index 1209f7ed6e..207f8ce8c4 100644 --- a/core/src/com/unciv/models/ruleset/tile/TileResource.kt +++ b/core/src/com/unciv/models/ruleset/tile/TileResource.kt @@ -12,13 +12,6 @@ class TileResource : NamedStats() { var terrainsCanBeFoundOn: List = listOf() var improvement: String? = null var improvementStats: Stats? = null - - /** - * The building that improves this resource, if any. E.G.: Granary for wheat, Stable for cattle. - * - */ - @Deprecated("Since 3.13.3 - replaced with '[stats] from [resource] tiles in this city' unique in the building") - var building: String? = null var revealedBy: String? = null var unique: String? = null diff --git a/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt b/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt index 851c8109eb..0bd3d02af4 100644 --- a/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt +++ b/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt @@ -46,13 +46,11 @@ class BattleTable(val worldScreen: WorldScreen): Table() { if (attacker is MapUnitCombatant && attacker.unit.hasUnique("Nuclear weapon")) { val selectedTile = worldScreen.mapHolder.selectedTile if (selectedTile == null) { hide(); return } // no selected tile - simulateNuke(attacker as MapUnitCombatant, selectedTile) + simulateNuke(attacker, selectedTile) } else { val defender = tryGetDefender() - if (defender == null) { - hide(); return - } + if (defender == null) { hide(); return } simulateBattle(attacker, defender) }