From 61b6e40cdcd5302f1b1db0edc747f6e7990c333e Mon Sep 17 00:00:00 2001 From: yairm210 Date: Tue, 19 Oct 2021 20:26:45 +0300 Subject: [PATCH] Resolved #5520 - no tech icon errors from techs with era errors --- core/src/com/unciv/logic/city/IConstruction.kt | 6 +++--- core/src/com/unciv/models/ruleset/unique/UniqueType.kt | 10 +++++++++- core/src/com/unciv/ui/utils/ImageGetter.kt | 3 ++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/core/src/com/unciv/logic/city/IConstruction.kt b/core/src/com/unciv/logic/city/IConstruction.kt index 274ec33f8d..ec5f245281 100644 --- a/core/src/com/unciv/logic/city/IConstruction.kt +++ b/core/src/com/unciv/logic/city/IConstruction.kt @@ -27,10 +27,10 @@ interface INonPerpetualConstruction : IConstruction, INamed, IHasUniques { fun canBePurchasedWithStat(cityInfo: CityInfo?, stat: Stat): Boolean { if (stat in listOf(Stat.Production, Stat.Happiness)) return false - if ("Cannot be purchased" in uniques) return false + if (hasUnique(UniqueType.CannotBePurchased)) return false if (stat == Stat.Gold) return !hasUnique(UniqueType.Unbuildable) // Can be purchased with [Stat] [cityFilter] - if (getMatchingUniques("Can be purchased with [] []") + if (getMatchingUniques(UniqueType.CanBePurchasedWithStat) .any { it.params[0] == stat.name && (cityInfo != null && cityInfo.matchesFilter(it.params[1])) } ) return true // Can be purchased for [amount] [Stat] [cityFilter] @@ -65,7 +65,7 @@ interface INonPerpetualConstruction : IConstruction, INamed, IHasUniques { if (lowestCostUnique != null) return lowestCostUnique.params[0].toInt() // Can be purchased with [Stat] [cityFilter] - if (getMatchingUniques("Can be purchased with [] []") + if (getMatchingUniques(UniqueType.CanBePurchasedWithStat) .any { it.params[0] == stat.name && cityInfo.matchesFilter(it.params[1])} ) return cityInfo.civInfo.getEra().baseUnitBuyCost return null diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt index 8199c89c5b..d03eedcae8 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt @@ -138,9 +138,17 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) { MayanGainGreatPerson("Receive a free Great Person at the end of every [comment] (every 394 years), after researching [tech]. Each bonus person can only be chosen once.", UniqueTarget.Nation), MayanCalendarDisplay("Once The Long Count activates, the year on the world screen displays as the traditional Mayan Long Count.", UniqueTarget.Nation), - ///////////////////////////////////////// BUILDING UNIQUES ///////////////////////////////////////// + + ///////////////////////////////////////// CONSTRUCTION UNIQUES ///////////////////////////////////////// Unbuildable("Unbuildable", UniqueTarget.Building, UniqueTarget.Unit), + CannotBePurchased("Cannot be purchased", UniqueTarget.Building, UniqueTarget.Unit), + CanBePurchasedWithStat("Can be purchased with [stat] [cityFilter]", UniqueTarget.Building, UniqueTarget.Unit), + + + ///////////////////////////////////////// BUILDING UNIQUES ///////////////////////////////////////// + + CostIncreasesPerCity("Cost increases by [amount] per owned city", UniqueTarget.Building), CannotBeBuiltWith("Cannot be built with [buildingName]", UniqueTarget.Building), RequiresAnotherBuilding("Requires a [buildingName] in this city", UniqueTarget.Building), diff --git a/core/src/com/unciv/ui/utils/ImageGetter.kt b/core/src/com/unciv/ui/utils/ImageGetter.kt index 0b9acb565b..33c73401d4 100644 --- a/core/src/com/unciv/ui/utils/ImageGetter.kt +++ b/core/src/com/unciv/ui/utils/ImageGetter.kt @@ -355,7 +355,8 @@ object ImageGetter { fun getTechIconGroup(techName: String, circleSize: Float) = getTechIcon(techName).surroundWithCircle(circleSize) fun getTechIcon(techName: String): Image { - val techIconColor = ruleset.eras[ruleset.technologies[techName]!!.era()]!!.getColor() + val techIconColor = ruleset.eras[ruleset.technologies[techName]?.era()]?.getColor() + ?: return getWhiteDot() return getImage("TechIcons/$techName").apply { color = techIconColor.lerp(Color.BLACK, 0.6f) } }