mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-23 21:22:39 +07:00
Don't list Unique requiring a tech in the Civilopedia for that tech (#10650)
* Update BuildingDescriptions.kt * Update BaseUnitDescriptions.kt * Update DescriptionHelpers.kt * Update BuildingDescriptions.kt * Update DescriptionHelpers.kt * Update Technology.kt * Update Technology.kt * Update TechnologyDescriptions.kt * Update BaseUnit.kt * Update BaseUnit.kt * Update Building.kt * Update TechnologyDescriptions.kt * Update Building.kt * Update Building.kt * Update Building.kt * Update BaseUnit.kt * Update BaseUnitDescriptions.kt * Update BuildingDescriptions.kt * Update TechnologyDescriptions.kt
This commit is contained in:
parent
a61e9658ea
commit
18c17e3a18
@ -7,6 +7,7 @@ import com.unciv.logic.civilization.Civilization
|
||||
import com.unciv.models.Counter
|
||||
import com.unciv.models.ruleset.tile.ResourceType
|
||||
import com.unciv.models.ruleset.tile.TileImprovement
|
||||
import com.unciv.models.ruleset.unique.Unique
|
||||
import com.unciv.models.ruleset.unique.LocalUniqueCache
|
||||
import com.unciv.models.ruleset.unique.StateForConditionals
|
||||
import com.unciv.models.ruleset.unique.UniqueParameterType
|
||||
@ -56,7 +57,7 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
|
||||
|
||||
override fun makeLink() = if (isAnyWonder()) "Wonder/$name" else "Building/$name"
|
||||
|
||||
fun getShortDescription(multiline: Boolean = false) = BuildingDescriptions.getShortDescription(this, multiline)
|
||||
fun getShortDescription(multiline: Boolean = false, uniqueInclusionFilter: ((Unique) -> Boolean)? = null) = BuildingDescriptions.getShortDescription(this, multiline, uniqueInclusionFilter)
|
||||
fun getDescription(city: City, showAdditionalInfo: Boolean) = BuildingDescriptions.getDescription(this, city, showAdditionalInfo)
|
||||
override fun getCivilopediaTextLines(ruleset: Ruleset) = BuildingDescriptions.getCivilopediaTextLines(this, ruleset)
|
||||
|
||||
|
@ -3,6 +3,7 @@ package com.unciv.models.ruleset.tech
|
||||
import com.unciv.logic.civilization.Civilization
|
||||
import com.unciv.models.ruleset.Ruleset
|
||||
import com.unciv.models.ruleset.RulesetObject
|
||||
import com.unciv.models.ruleset.unique.Unique
|
||||
import com.unciv.models.ruleset.unique.UniqueTarget
|
||||
import com.unciv.models.ruleset.unique.UniqueType
|
||||
import com.unciv.ui.objectdescriptions.TechnologyDescriptions
|
||||
@ -39,4 +40,16 @@ class Technology: RulesetObject() {
|
||||
else -> uniques.contains(filter)
|
||||
}
|
||||
}
|
||||
|
||||
// Wrapper so that if the way to require a tech with a Unique ever changes, this only needs to change in one place.
|
||||
fun uniqueIsRequirementForThisTech(unique: Unique): Boolean =
|
||||
unique.type == UniqueType.OnlyAvailableWhen
|
||||
// OnlyAvailableWhen can take multiple conditionals, in which case the true conditional is implicitly the conjunction of all those conditionals.
|
||||
// If an OnlyAvailableWhen there are multiple conditionals, one of which requires this tech,
|
||||
// then IHasUniques.techsRequiredByUniques() will list this tech as required (because it is),
|
||||
// but uniqueIsRequirementForThisTech() will *not* identify that OnlyAvailableWhen as a requirement for this tech (because it's more complicated than that).
|
||||
&& unique.conditionals.size == 1
|
||||
&& unique.conditionals[0].params[0] == name
|
||||
|
||||
fun uniqueIsNotRequirementForThisTech(unique: Unique): Boolean = !uniqueIsRequirementForThisTech(unique)
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
||||
|
||||
|
||||
/** Generate short description as comma-separated string for Technology description "Units enabled" and GreatPersonPickerScreen */
|
||||
fun getShortDescription() = BaseUnitDescriptions.getShortDescription(this)
|
||||
fun getShortDescription(uniqueExclusionFilter: Unique.() -> Boolean = {false}) = BaseUnitDescriptions.getShortDescription(this, uniqueExclusionFilter)
|
||||
|
||||
/** Generate description as multi-line string for CityScreen addSelectedConstructionTable
|
||||
* @param city Supplies civInfo to show available resources after resource requirements */
|
||||
|
@ -25,7 +25,7 @@ import com.unciv.ui.screens.civilopediascreen.MarkupRenderer
|
||||
object BaseUnitDescriptions {
|
||||
|
||||
/** Generate short description as comma-separated string for Technology description "Units enabled" and GreatPersonPickerScreen */
|
||||
fun getShortDescription(baseUnit: BaseUnit, exclude: Unique.() -> Boolean = {false}): String {
|
||||
fun getShortDescription(baseUnit: BaseUnit, uniqueExclusionFilter: Unique.() -> Boolean = {false}): String {
|
||||
val infoList = mutableListOf<String>()
|
||||
if (baseUnit.strength != 0) infoList += "${baseUnit.strength}${Fonts.strength}"
|
||||
if (baseUnit.rangedStrength != 0) infoList += "${baseUnit.rangedStrength}${Fonts.rangedStrength}"
|
||||
@ -33,7 +33,7 @@ object BaseUnitDescriptions {
|
||||
for (promotion in baseUnit.promotions)
|
||||
infoList += promotion.tr()
|
||||
if (baseUnit.replacementTextForUniques != "") infoList += baseUnit.replacementTextForUniques
|
||||
else baseUnit.uniquesToDescription(infoList, exclude)
|
||||
else baseUnit.uniquesToDescription(infoList, uniqueExclusionFilter)
|
||||
return infoList.joinToString()
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ object BuildingDescriptions {
|
||||
// To stay consistent, all take the Building as normal parameter instead.
|
||||
|
||||
/** Used for AlertType.WonderBuilt, and as sub-text in Nation and Tech descriptions */
|
||||
fun getShortDescription(building: Building, multiline: Boolean = false, filterUniques: ((Unique) -> Boolean)? = null): String = building.run {
|
||||
fun getShortDescription(building: Building, multiline: Boolean = false, uniqueInclusionFilter: ((Unique) -> Boolean)? = null): String = building.run {
|
||||
val infoList = mutableListOf<String>()
|
||||
this.clone().toString().also { if (it.isNotEmpty()) infoList += it }
|
||||
for ((key, value) in getStatPercentageBonuses(null))
|
||||
@ -30,7 +30,7 @@ object BuildingDescriptions {
|
||||
infoList += "Requires worked [" + requiredNearbyImprovedResources!!.joinToString("/") { it.tr() } + "] near city"
|
||||
if (uniques.isNotEmpty()) {
|
||||
if (replacementTextForUniques.isNotEmpty()) infoList += replacementTextForUniques
|
||||
else infoList += getUniquesStringsWithoutDisablers(filterUniques)
|
||||
else infoList += getUniquesStringsWithoutDisablers(uniqueInclusionFilter)
|
||||
}
|
||||
if (cityStrength != 0) infoList += "{City strength} +$cityStrength"
|
||||
if (cityHealth != 0) infoList += "{City health} +$cityHealth"
|
||||
|
@ -50,7 +50,7 @@ object TechnologyDescriptions {
|
||||
if (enabledUnits.any()) {
|
||||
lineList += "{Units enabled}: "
|
||||
for (unit in enabledUnits)
|
||||
lineList += " • ${unit.name.tr()} (${unit.getShortDescription()})\n"
|
||||
lineList += " • ${unit.name.tr()} (${unit.getShortDescription(uniqueExclusionFilter=technology::uniqueIsRequirementForThisTech)})\n"
|
||||
}
|
||||
|
||||
val (wonders, regularBuildings) = getEnabledBuildings(name, ruleset, viewingCiv)
|
||||
@ -59,13 +59,13 @@ object TechnologyDescriptions {
|
||||
if (regularBuildings.isNotEmpty()) {
|
||||
lineList += "{Buildings enabled}: "
|
||||
for (building in regularBuildings)
|
||||
lineList += " • ${building.name.tr()} (${building.getShortDescription()})\n"
|
||||
lineList += " • ${building.name.tr()} (${building.getShortDescription(uniqueInclusionFilter=technology::uniqueIsNotRequirementForThisTech)})\n"
|
||||
}
|
||||
|
||||
if (wonders.isNotEmpty()) {
|
||||
lineList += "{Wonders enabled}: "
|
||||
for (wonder in wonders)
|
||||
lineList += " • ${wonder.name.tr()} (${wonder.getShortDescription()})\n"
|
||||
lineList += " • ${wonder.name.tr()} (${wonder.getShortDescription(uniqueInclusionFilter=technology::uniqueIsNotRequirementForThisTech)})\n"
|
||||
}
|
||||
|
||||
for (obj in getObsoletedObjects(name, ruleset, viewingCiv))
|
||||
@ -206,7 +206,7 @@ object TechnologyDescriptions {
|
||||
lineList += FormattedLine()
|
||||
lineList += FormattedLine("{Units enabled}:")
|
||||
for (unit in enabledUnits)
|
||||
lineList += FormattedLine(unit.name.tr(true) + " (" + unit.getShortDescription() + ")", link = unit.makeLink())
|
||||
lineList += FormattedLine(unit.name.tr(true) + " (" + unit.getShortDescription(uniqueExclusionFilter=technology::uniqueIsRequirementForThisTech) + ")", link = unit.makeLink())
|
||||
}
|
||||
|
||||
val (wonders, regularBuildings) = getEnabledBuildings(name, ruleset, null)
|
||||
@ -216,14 +216,14 @@ object TechnologyDescriptions {
|
||||
lineList += FormattedLine()
|
||||
lineList += FormattedLine("{Wonders enabled}:")
|
||||
for (wonder in wonders)
|
||||
lineList += FormattedLine(wonder.name.tr(true) + " (" + wonder.getShortDescription() + ")", link = wonder.makeLink())
|
||||
lineList += FormattedLine(wonder.name.tr(true) + " (" + wonder.getShortDescription(uniqueInclusionFilter=technology::uniqueIsNotRequirementForThisTech) + ")", link = wonder.makeLink())
|
||||
}
|
||||
|
||||
if (regularBuildings.isNotEmpty()) {
|
||||
lineList += FormattedLine()
|
||||
lineList += FormattedLine("{Buildings enabled}:")
|
||||
for (building in regularBuildings)
|
||||
lineList += FormattedLine(building.name.tr(true) + " (" + building.getShortDescription() + ")", link = building.makeLink())
|
||||
lineList += FormattedLine(building.name.tr(true) + " (" + building.getShortDescription(uniqueInclusionFilter=technology::uniqueIsNotRequirementForThisTech) + ")", link = building.makeLink())
|
||||
}
|
||||
|
||||
val obsoletedObjects = getObsoletedObjects(name, ruleset, null).toList()
|
||||
|
Loading…
Reference in New Issue
Block a user