Resource.building, Building.resourceBonusStats deprecated in favor of '[stats] from [resource] tiles in this city' unique

This commit is contained in:
Yair Morgenstern 2021-06-08 20:01:49 +03:00
parent 21aa371cc3
commit e8bbd4bc70
5 changed files with 4 additions and 40 deletions

View File

@ -279,8 +279,6 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
} }
private fun addProductionBuildingChoice() { private fun addProductionBuildingChoice() {
val hasWaterResource = cityInfo.tilesInRange
.any { it.isWater && it.resource!=null && it.position in cityInfo.tiles }
val productionBuilding = buildableNotWonders.asSequence() val productionBuilding = buildableNotWonders.asSequence()
.filter { it.isStatRelated(Stat.Production) } .filter { it.isStatRelated(Stat.Production) }
.minByOrNull { it.cost } .minByOrNull { it.cost }

View File

@ -253,16 +253,8 @@ open class TileInfo {
stats.add(wonder) stats.add(wonder)
} }
} }
// resource base
if (hasViewableResource(observingCiv)) { if (hasViewableResource(observingCiv)) stats.add(getTileResource())
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
}
}
val improvement = getTileImprovement() val improvement = getTileImprovement()
if (improvement != null) if (improvement != null)

View File

@ -64,12 +64,6 @@ class Building : NamedStats(), IConstruction {
var replacementTextForUniques = "" var replacementTextForUniques = ""
val uniqueObjects: List<Unique> by lazy { uniques.map { Unique(it) } } val uniqueObjects: List<Unique> 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 fun getShortDescription(ruleset: Ruleset): String { // should fit in one line
val infoList = mutableListOf<String>() val infoList = mutableListOf<String>()
val str = getStats(null).toString() val str = getStats(null).toString()
@ -77,11 +71,6 @@ class Building : NamedStats(), IConstruction {
for (stat in getStatPercentageBonuses(null).toHashMap()) for (stat in getStatPercentageBonuses(null).toHashMap())
if (stat.value != 0f) infoList += "+${stat.value.toInt()}% ${stat.key.name.tr()}" 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) if (requiredNearbyImprovedResources != null)
infoList += "Requires worked [" + requiredNearbyImprovedResources!!.joinToString("/") { it.tr() } + "] near city" infoList += "Requires worked [" + requiredNearbyImprovedResources!!.joinToString("/") { it.tr() } + "] near city"
if (uniques.isNotEmpty()) { if (uniques.isNotEmpty()) {
@ -152,11 +141,6 @@ class Building : NamedStats(), IConstruction {
for ((specialistName, amount) in newSpecialists()) for ((specialistName, amount) in newSpecialists())
stringBuilder.appendLine("+$amount " + "[$specialistName] slots".tr()) 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) if (requiredNearbyImprovedResources != null)
stringBuilder.appendLine(("Requires worked [" + requiredNearbyImprovedResources!!.joinToString("/") { it.tr() } + "] near city").tr()) stringBuilder.appendLine(("Requires worked [" + requiredNearbyImprovedResources!!.joinToString("/") { it.tr() } + "] near city").tr())
@ -457,7 +441,6 @@ class Building : NamedStats(), IConstruction {
fun isStatRelated(stat: Stat): Boolean { fun isStatRelated(stat: Stat): Boolean {
if (get(stat) > 0) return true if (get(stat) > 0) return true
if (getStatPercentageBonuses(null).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 if (uniqueObjects.any { it.placeholderText == "[] Per [] Population in this city" && it.stats.get(stat) > 0 }) return true
return false return false
} }

View File

@ -12,13 +12,6 @@ class TileResource : NamedStats() {
var terrainsCanBeFoundOn: List<String> = listOf() var terrainsCanBeFoundOn: List<String> = listOf()
var improvement: String? = null var improvement: String? = null
var improvementStats: Stats? = 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 revealedBy: String? = null
var unique: String? = null var unique: String? = null

View File

@ -46,13 +46,11 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
if (attacker is MapUnitCombatant && attacker.unit.hasUnique("Nuclear weapon")) { if (attacker is MapUnitCombatant && attacker.unit.hasUnique("Nuclear weapon")) {
val selectedTile = worldScreen.mapHolder.selectedTile val selectedTile = worldScreen.mapHolder.selectedTile
if (selectedTile == null) { hide(); return } // no selected tile if (selectedTile == null) { hide(); return } // no selected tile
simulateNuke(attacker as MapUnitCombatant, selectedTile) simulateNuke(attacker, selectedTile)
} }
else { else {
val defender = tryGetDefender() val defender = tryGetDefender()
if (defender == null) { if (defender == null) { hide(); return }
hide(); return
}
simulateBattle(attacker, defender) simulateBattle(attacker, defender)
} }