diff --git a/core/src/com/unciv/ui/objectdescriptions/BaseUnitDescriptions.kt b/core/src/com/unciv/ui/objectdescriptions/BaseUnitDescriptions.kt index d043b00539..27f6189cbc 100644 --- a/core/src/com/unciv/ui/objectdescriptions/BaseUnitDescriptions.kt +++ b/core/src/com/unciv/ui/objectdescriptions/BaseUnitDescriptions.kt @@ -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): String { + fun getShortDescription(baseUnit: BaseUnit, exclude: Unique.() -> Boolean = {false}): String { val infoList = mutableListOf() 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) + else baseUnit.uniquesToDescription(infoList, exclude) return infoList.joinToString() } diff --git a/core/src/com/unciv/ui/objectdescriptions/BuildingDescriptions.kt b/core/src/com/unciv/ui/objectdescriptions/BuildingDescriptions.kt index d22568d5b5..b5d28e06a9 100644 --- a/core/src/com/unciv/ui/objectdescriptions/BuildingDescriptions.kt +++ b/core/src/com/unciv/ui/objectdescriptions/BuildingDescriptions.kt @@ -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): String = building.run { + fun getShortDescription(building: Building, multiline: Boolean = false, filterUniques: ((Unique) -> Boolean)? = null): String = building.run { val infoList = mutableListOf() 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() + else infoList += getUniquesStringsWithoutDisablers(filterUniques) } if (cityStrength != 0) infoList += "{City strength} +$cityStrength" if (cityHealth != 0) infoList += "{City health} +$cityHealth" @@ -273,7 +273,7 @@ object BuildingDescriptions { /** * @param filterUniques If provided, include only uniques for which this function returns true. */ - private fun Building.getUniquesStringsWithoutDisablers(filterUniques: ((Unique) -> Boolean)? = null) = getUniquesStrings { + private fun Building.getUniquesStringsWithoutDisablers(filterUniques: ((Unique) -> Boolean)? = null): Sequence = getUniquesStrings { !it.isHiddenToUsers() && (filterUniques?.invoke(it) ?: true) } diff --git a/core/src/com/unciv/ui/objectdescriptions/DescriptionHelpers.kt b/core/src/com/unciv/ui/objectdescriptions/DescriptionHelpers.kt index 3584b10528..5088416ae1 100644 --- a/core/src/com/unciv/ui/objectdescriptions/DescriptionHelpers.kt +++ b/core/src/com/unciv/ui/objectdescriptions/DescriptionHelpers.kt @@ -15,7 +15,7 @@ import com.unciv.ui.screens.civilopediascreen.FormattedLine fun IHasUniques.uniquesToDescription( lineList: MutableCollection, exclude: Unique.() -> Boolean = {false} -) { +): Unit { for (unique in uniqueObjects) { if (unique.isHiddenToUsers()) continue if (unique.exclude()) continue