Delete unused var in the method getDescription/getShortDescription of the Class Building (#6117)

This commit is contained in:
lishaoxia1985 2022-02-07 16:11:53 +08:00 committed by GitHub
parent 6403337da6
commit aa11602c9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 15 additions and 11 deletions

View File

@ -51,7 +51,7 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
private var replacementTextForUniques = ""
/** Used for AlertType.WonderBuilt, and as sub-text in Nation and Tech descriptions */
fun getShortDescription(ruleset: Ruleset): String { // should fit in one line
fun getShortDescription(): String { // should fit in one line
val infoList = mutableListOf<String>()
this.clone().toString().also { if (it.isNotEmpty()) infoList += it }
for ((key, value) in getStatPercentageBonuses(null))
@ -99,7 +99,7 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
}
/** used in CityScreen (CityInfoTable and ConstructionInfoTable) */
fun getDescription(cityInfo: CityInfo, ruleset: Ruleset): String {
fun getDescription(cityInfo: CityInfo): String {
val stats = getStats(cityInfo)
val lines = ArrayList<String>()
val isFree = name in cityInfo.civInfo.civConstructions.getFreeBuildings(cityInfo.id)

View File

@ -223,7 +223,7 @@ class Nation : RulesetObject() {
} else if (building.replaces != null) {
yield(FormattedLine("Replaces [${building.replaces}], which is not found in the ruleset!", indent=1))
} else {
yield(FormattedLine(building.getShortDescription(ruleset), indent=1))
yield(FormattedLine(building.getShortDescription(), indent=1))
}
}
}

View File

@ -1,6 +1,5 @@
package com.unciv.models.ruleset.tech
import com.unciv.Constants
import com.unciv.UncivGame
import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.models.ruleset.Building
@ -65,14 +64,14 @@ class Technology: RulesetObject() {
if (regularBuildings.any()) {
lineList += "{Buildings enabled}: "
for (building in regularBuildings)
lineList += "* " + building.name.tr() + " (" + building.getShortDescription(ruleset) + ")"
lineList += "* " + building.name.tr() + " (" + building.getShortDescription() + ")"
}
val wonders = enabledBuildings.filter { it.isAnyWonder() }
if (wonders.any()) {
lineList += "{Wonders enabled}: "
for (wonder in wonders)
lineList += " * " + wonder.name.tr() + " (" + wonder.getShortDescription(ruleset) + ")"
lineList += " * " + wonder.name.tr() + " (" + wonder.getShortDescription() + ")"
}
for (building in getObsoletedBuildings(viewingCiv))
@ -233,13 +232,13 @@ class Technology: RulesetObject() {
lineList += FormattedLine()
lineList += FormattedLine("{Wonders enabled}:")
for (wonder in enabledBuildings.first)
lineList += FormattedLine(wonder.name.tr() + " (" + wonder.getShortDescription(ruleset) + ")", link = wonder.makeLink())
lineList += FormattedLine(wonder.name.tr() + " (" + wonder.getShortDescription() + ")", link = wonder.makeLink())
}
if (enabledBuildings.second.isNotEmpty()) {
lineList += FormattedLine()
lineList += FormattedLine("{Buildings enabled}:")
for (building in enabledBuildings.second)
lineList += FormattedLine(building.name.tr() + " (" + building.getShortDescription(ruleset) + ")", link = building.makeLink())
lineList += FormattedLine(building.name.tr() + " (" + building.getShortDescription() + ")", link = building.makeLink())
}
val obsoletedBuildings = getObsoletedBuildings(viewingCiv)

View File

@ -70,7 +70,7 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(BaseScreen.skin)
val isFree = building.name in cityScreen.city.civInfo.civConstructions.getFreeBuildings(cityScreen.city.id)
val displayName = if (isFree) "{${building.name}} ({Free})" else building.name
val buildingNameAndIconTable = ExpanderTab(displayName, Constants.defaultFontSize, icon, false, 5f) {
val detailsString = building.getDescription(cityScreen.city, cityScreen.city.getRuleset())
val detailsString = building.getDescription(cityScreen.city)
it.add(detailsString.toLabel().apply { wrap = true })
.width(cityScreen.stage.width / 4 - 2 * pad).row() // when you set wrap, then you need to manually set the size of the label
if (building.isSellable() && !isFree) {

View File

@ -59,7 +59,7 @@ class ConstructionInfoTable(val cityScreen: CityScreen): Table() {
val (description, link) = when (construction) {
is BaseUnit -> construction.getDescription() to construction.makeLink()
is Building -> construction.getDescription(city, city.getRuleset()) to construction.makeLink()
is Building -> construction.getDescription(city) to construction.makeLink()
is PerpetualConstruction -> construction.description.replace("[rate]", "[${construction.getConversionRate(city)}]") to ""
else -> "" to "" // Should never happen
}

View File

@ -188,7 +188,7 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
val centerTable = Table()
centerTable.add(wonder.quote.toLabel().apply { wrap = true }).width(worldScreen.stage.width / 3).pad(10f)
centerTable.add(wonder.getShortDescription(worldScreen.gameInfo.ruleSet)
centerTable.add(wonder.getShortDescription()
.toLabel().apply { wrap = true }).width(worldScreen.stage.width / 3).pad(10f)
add(centerTable).row()
add(getCloseButton(Constants.close))

View File

@ -741,6 +741,11 @@ Example: "Requires a [Library] in all cities"
Applicable to: Building
#### Requires a [buildingName] in at least [amount] cities
Example: "Requires a [Library] in at least [20] cities"
Applicable to: Building
#### [stats] with [resource]
Example: "[+1 Gold, +2 Production] with [Iron]"