mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-07 17:43:54 +07:00
Building uniqueTo can apply to civ *filters*
This commit is contained in:
parent
1cae77d1ad
commit
238e30b86c
@ -164,7 +164,7 @@ class City : IsPartOfGameInfoSerialization, INamed {
|
||||
val indicatorBuildings = getRuleset().buildings.values.asSequence()
|
||||
.filter { it.hasUnique(UniqueType.IndicatesCapital) }
|
||||
|
||||
val civSpecificBuilding = indicatorBuildings.firstOrNull { it.uniqueTo == civ.civName }
|
||||
val civSpecificBuilding = indicatorBuildings.firstOrNull { it.uniqueTo != null && civ.matchesFilter(it.uniqueTo!!) }
|
||||
return civSpecificBuilding ?: indicatorBuildings.firstOrNull()
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ class CivInfoTransientCache(val civInfo: Civilization) {
|
||||
}
|
||||
|
||||
for (building in ruleset.buildings.values) {
|
||||
if (building.uniqueTo == civInfo.civName) {
|
||||
if (building.uniqueTo != null && civInfo.matchesFilter(building.uniqueTo!!)) {
|
||||
uniqueBuildings.add(building)
|
||||
}
|
||||
}
|
||||
|
@ -342,7 +342,7 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
|
||||
}
|
||||
}
|
||||
|
||||
if (uniqueTo != null && uniqueTo != civ.civName)
|
||||
if (uniqueTo != null && !civ.matchesFilter(uniqueTo!!))
|
||||
yield(RejectionReasonType.UniqueToOtherNation.toInstance("Unique to $uniqueTo"))
|
||||
|
||||
if (civ.cache.uniqueBuildings.any { it.replaces == name })
|
||||
|
@ -192,7 +192,8 @@ class Nation : RulesetObject() {
|
||||
|
||||
private fun getUniqueBuildingsText(ruleset: Ruleset) = sequence {
|
||||
for (building in ruleset.buildings.values) {
|
||||
if (building.uniqueTo != name) continue
|
||||
if (building.uniqueTo == null) continue
|
||||
if (!matchesFilter(building.uniqueTo!!)) continue
|
||||
if (building.isHiddenFromCivilopedia(ruleset)) continue
|
||||
yield(FormattedLine(separator = true))
|
||||
yield(FormattedLine("{${building.name}} -", link = building.makeLink()))
|
||||
|
@ -312,7 +312,8 @@ object TechnologyDescriptions {
|
||||
return ruleset.buildings.values.asSequence()
|
||||
.filter {
|
||||
predicate(it) // expected to be the most selective, thus tested first
|
||||
&& (it.uniqueTo == civInfo?.civName || it.uniqueTo == null && civInfo?.getEquivalentBuilding(it) == it)
|
||||
&& (it.uniqueTo != null && civInfo?.matchesFilter(it.uniqueTo!!) == true
|
||||
|| it.uniqueTo == null && civInfo?.getEquivalentBuilding(it) == it)
|
||||
&& !it.isHiddenFromCivilopedia(ruleset)
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.Constants
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.UncivShowableException
|
||||
import com.unciv.models.metadata.BaseRuleset
|
||||
import com.unciv.models.ruleset.Ruleset
|
||||
import com.unciv.models.ruleset.RulesetCache
|
||||
@ -329,16 +328,16 @@ class FormattedLine (
|
||||
|
||||
private fun renderExtraImage(labelWidth: Float): Table {
|
||||
val table = Table(BaseScreen.skin)
|
||||
fun getExtraImage(): Image {
|
||||
fun getExtraImage(): Image? {
|
||||
if (ImageGetter.imageExists(extraImage))
|
||||
return if (centered) ImageGetter.getDrawable(extraImage).cropToContent()
|
||||
else ImageGetter.getImage(extraImage)
|
||||
val externalImage = ImageGetter.findExternalImage(extraImage)
|
||||
?: throw UncivShowableException("Extra image '[$extraImage]' not found") // logged in catch below
|
||||
?: return null
|
||||
return ImageGetter.getExternalImage(externalImage)
|
||||
}
|
||||
try {
|
||||
val image = getExtraImage()
|
||||
val image = getExtraImage() ?: return table
|
||||
// limit larger cordinate to a given max size
|
||||
val maxSize = if (imageSize.isNaN()) labelWidth else imageSize
|
||||
val (width, height) = if (image.width > image.height)
|
||||
|
Loading…
Reference in New Issue
Block a user