diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index 24ca4409ba..53f010b296 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -998,6 +998,8 @@ Found Pantheon = Follow [belief] = Religions and Beliefs = Majority Religion: [name] = ++ [amount] pressure = +Pressure = # Religion overview screen Religion Name: = diff --git a/core/src/com/unciv/logic/city/CityInfo.kt b/core/src/com/unciv/logic/city/CityInfo.kt index b6020ae953..3359fe9e98 100644 --- a/core/src/com/unciv/logic/city/CityInfo.kt +++ b/core/src/com/unciv/logic/city/CityInfo.kt @@ -94,7 +94,7 @@ class CityInfo { val startingEra = civInfo.gameInfo.gameParameters.startingEra addStartingBuildings(civInfo, startingEra) - + expansion.reset() tryUpdateRoadStatus() @@ -109,7 +109,7 @@ class CityInfo { if (civInfo.religionManager.religion != null && civInfo.religionManager.religion!!.isPantheon()) { religion.addPressure(civInfo.religionManager.religion!!.name, 100) } - + val ruleset = civInfo.gameInfo.ruleSet workedTiles = hashSetOf() //reassign 1st working tile if (startingEra in ruleset.eras) @@ -163,7 +163,7 @@ class CityInfo { name = cityNamePrefix + cityName } - + private fun borrowCityName(): String { val usedCityNames = civInfo.gameInfo.civilizations.flatMap { it.cities.map { city -> city.name } } @@ -172,12 +172,12 @@ class CityInfo { var newNames = civInfo.gameInfo.civilizations .filter { it.isMajorCiv() && it != civInfo } .mapNotNull { it.nation.cities - .lastOrNull { city -> city !in usedCityNames } + .lastOrNull { city -> city !in usedCityNames } } if (newNames.isNotEmpty()) { return newNames.random() } - + // As per fandom wiki, once the names from the other nations in the game are exhausted, // names are taken from the rest of the nations in the ruleset newNames = getRuleset() @@ -403,7 +403,7 @@ class CityInfo { gppCounter.add(entry) return gppCounter } - + fun addStat(stat: Stat, amount: Int) { when (stat) { Stat.Production -> cityConstructions.addProductionPoints(amount) @@ -411,7 +411,7 @@ class CityInfo { else -> civInfo.addStat(stat, amount) } } - + fun getStatReserve(stat: Stat): Int { return when (stat) { Stat.Food -> population.foodStored @@ -477,7 +477,7 @@ class CityInfo { if (isBeingRazed) { val removedPopulation = 1 + civInfo.getMatchingUniques("Cities are razed [] times as fast").sumBy { it.params[0].toInt() - 1 } population.addPopulation(-1 * removedPopulation) - if (population.population <= 0) { + if (population.population <= 0) { civInfo.addNotification("[$name] has been razed to the ground!", location, "OtherIcons/Fire") destroyCity() } else { //if not razed yet: @@ -500,7 +500,7 @@ class CityInfo { // Original capitals and holy cities cannot be destroyed, // unless, of course, they are captured by a one-city-challenger. if (!canBeDestroyed() && !overrideSafeties) return - + for (airUnit in getCenterTile().airUnits.toList()) airUnit.destroy() //Destroy planes stationed in city // The relinquish ownership MUST come before removing the city, @@ -597,9 +597,9 @@ class CityInfo { "in all cities with a world wonder" -> cityConstructions.getBuiltBuildings().any { it.isWonder } "in all cities connected to capital" -> isConnectedToCapital() "in all cities with a garrison" -> getCenterTile().militaryUnit != null - "in all cities in which the majority religion is a major religion" -> - religion.getMajorityReligion() != null - && civInfo.gameInfo.religions[religion.getMajorityReligion()]!!.isMajorReligion() + "in all cities in which the majority religion is a major religion" -> + religion.getMajorityReligionName() != null + && religion.getMajorityReligion()!!.isMajorReligion() "in non-enemy foreign cities" -> viewingCiv != civInfo && !civInfo.isAtWarWith(viewingCiv) @@ -612,8 +612,8 @@ class CityInfo { else -> false } } - - // So everywhere in the codebase there were continuous calls to either + + // So everywhere in the codebase there were continuous calls to either // `cityConstructions.builtBuildingUniqueMap.getUniques()` or `cityConstructions.builtBuildingMap.getAllUniques()`, // which was fine as long as those were the only uniques that cities could provide. // However, with the introduction of religion, cities might also get uniques from the religion the city follows. @@ -633,7 +633,7 @@ class CityInfo { return civInfo.getMatchingUniques(placeholderText, this) + localUniques.filter { it.placeholderText == placeholderText } } - + // Matching uniques provided by sources in the city itself fun getLocalMatchingUniques(placeholderText: String): Sequence { return cityConstructions.builtBuildingUniqueMap.getUniques(placeholderText) + @@ -644,14 +644,14 @@ class CityInfo { fun getAllLocalUniques(): Sequence { return cityConstructions.builtBuildingUniqueMap.getAllUniques() + religion.getUniques() } - + // Get all matching uniques that don't apply to only this city fun getMatchingUniquesWithNonLocalEffects(placeholderText: String): Sequence { return cityConstructions.builtBuildingUniqueMap.getUniques(placeholderText) .filter { it.params.none { param -> param == "in this city" } } // Note that we don't query religion here, as those only have local effects (for now at least) } - + // Get all uniques that don't apply to only this city fun getAllUniquesWithNonLocalEffects(): Sequence { return cityConstructions.builtBuildingUniqueMap.getAllUniques() @@ -660,9 +660,9 @@ class CityInfo { } fun isHolyCity(): Boolean { - return religion.religionThisIsTheHolyCityOf != null + return religion.religionThisIsTheHolyCityOf != null } - + fun canBeDestroyed(): Boolean { return !isOriginalCapital && !isCapital() && !isHolyCity() } @@ -678,7 +678,7 @@ class CityInfo { cityPositionList.add(tile) return cityPositionList.asSequence() - .map { it.getOwner()?.civName }.filterNotNull().toSet() + .map { it.getOwner()?.civName }.filterNotNull().toSet() .distinct().toList() } fun getImprovableTiles(): Sequence = getTiles() diff --git a/core/src/com/unciv/logic/city/CityReligion.kt b/core/src/com/unciv/logic/city/CityReligion.kt index d188e715e7..0e28b3428b 100644 --- a/core/src/com/unciv/logic/city/CityReligion.kt +++ b/core/src/com/unciv/logic/city/CityReligion.kt @@ -3,6 +3,7 @@ package com.unciv.logic.city import com.unciv.Constants import com.unciv.logic.civilization.NotificationIcon import com.unciv.models.Counter +import com.unciv.models.Religion import com.unciv.models.metadata.GameSpeed import com.unciv.models.ruleset.Unique @@ -37,6 +38,7 @@ class CityInfoReligionManager { fun clone(): CityInfoReligionManager { val toReturn = CityInfoReligionManager() + toReturn.cityInfo = cityInfo toReturn.religionsAtSomePointAdopted.addAll(religionsAtSomePointAdopted) toReturn.pressures.putAll(pressures) toReturn.followers.putAll(followers) @@ -46,7 +48,10 @@ class CityInfoReligionManager { fun setTransients(cityInfo: CityInfo) { this.cityInfo = cityInfo - updateNumberOfFollowers() + // We don't need to check for changes in the majority religion, and as this + // loads in the religion, _of course_ the religion changes, but it shouldn't + // have any effect + updateNumberOfFollowers(false) } fun endTurn() { @@ -56,7 +61,7 @@ class CityInfoReligionManager { fun getUniques(): Sequence { val majorityReligion = getMajorityReligion() if (majorityReligion == null) return sequenceOf() - return cityInfo.civInfo.gameInfo.religions[majorityReligion]!!.getFollowerUniques() + return majorityReligion.getFollowerUniques() } fun getMatchingUniques(unique: String): Sequence { @@ -77,13 +82,13 @@ class CityInfoReligionManager { pressures.add(religionName, amount) if (shouldUpdateFollowers) { - updateNumberOfFollowers() + updateNumberOfFollowers(shouldUpdateFollowers) } } fun updatePressureOnPopulationChange(populationChangeAmount: Int) { val majorityReligion = - if (getMajorityReligion() != null) getMajorityReligion()!! + if (getMajorityReligionName() != null) getMajorityReligionName()!! else Constants.noReligionName if (populationChangeAmount > 0) { @@ -122,8 +127,10 @@ class CityInfoReligionManager { religionsAtSomePointAdopted.add(newMajorityReligion) } - private fun updateNumberOfFollowers() { - val oldMajorityReligion = getMajorityReligion() + private fun updateNumberOfFollowers(checkForReligionAdoption: Boolean = true) { + val oldMajorityReligion = + if (checkForReligionAdoption) getMajorityReligionName() + else null followers.clear() if (cityInfo.population.population <= 0) return @@ -154,18 +161,24 @@ class CityInfoReligionManager { followers.remove(Constants.noReligionName) - val newMajorityReligion = getMajorityReligion() - if (oldMajorityReligion != newMajorityReligion && newMajorityReligion != null) { - triggerReligionAdoption(newMajorityReligion) + if (checkForReligionAdoption) { + val newMajorityReligion = getMajorityReligionName() + if (oldMajorityReligion != newMajorityReligion && newMajorityReligion != null) { + triggerReligionAdoption(newMajorityReligion) + } } } + fun getNumberOfFollowers(): Counter { + return followers.clone() + } + fun getFollowersOf(religion: String): Int? { return followers[religion] } fun getFollowersOfMajorityReligion(): Int { - val majorityReligion = getMajorityReligion() ?: return 0 + val majorityReligion = getMajorityReligionName() ?: return 0 return followers[majorityReligion]!! } @@ -189,12 +202,16 @@ class CityInfoReligionManager { updateNumberOfFollowers() } - fun getMajorityReligion(): String? { + fun getMajorityReligionName(): String? { if (followers.isEmpty()) return null val religionWithMaxFollowers = followers.maxByOrNull { it.value }!! return if (religionWithMaxFollowers.value >= cityInfo.population.population / 2) religionWithMaxFollowers.key else null } + + fun getMajorityReligion(): Religion? { + return cityInfo.civInfo.gameInfo.religions[getMajorityReligionName()] + } private fun getAffectedBySurroundingCities() { // We don't update the amount of followers yet, as only the end result should matter @@ -212,11 +229,31 @@ class CityInfoReligionManager { && it.getCenterTile().aerialDistanceTo(cityInfo.getCenterTile()) <= 10 } for (city in allCitiesWithin10Tiles) { - val majorityReligionOfCity = city.religion.getMajorityReligion() ?: continue + val majorityReligionOfCity = city.religion.getMajorityReligionName() ?: continue if (!cityInfo.civInfo.gameInfo.religions[majorityReligionOfCity]!!.isMajorReligion()) continue addPressure(majorityReligionOfCity, pressureFromAdjacentCities, false) } updateNumberOfFollowers() } + + /** Doesn't update the pressures, only returns what they are if the update were to happen right now */ + fun getPressuresFromSurroundingCities(): Counter { + val addedPressure = Counter() + if (cityInfo.isHolyCity()) { + addedPressure[religionThisIsTheHolyCityOf!!] = 5 * pressureFromAdjacentCities + } + val allCitiesWithin10Tiles = + cityInfo.civInfo.gameInfo.getCities() + .filter { + it != cityInfo + && it.getCenterTile().aerialDistanceTo(cityInfo.getCenterTile()) <= 10 + } + for (city in allCitiesWithin10Tiles) { + val majorityReligionOfCity = city.religion.getMajorityReligion() ?: continue + if (!majorityReligionOfCity.isMajorReligion()) continue + addedPressure.add(majorityReligionOfCity.name, pressureFromAdjacentCities) + } + return addedPressure + } } \ No newline at end of file diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index 3e9910b1a8..4edacae59a 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -802,7 +802,7 @@ class CivilizationInfo { if (placedUnit.hasUnique("Religious Unit")) { placedUnit.religion = - if (city != null) city.cityConstructions.cityInfo.religion.getMajorityReligion() + if (city != null) city.cityConstructions.cityInfo.religion.getMajorityReligionName() else religionManager.religion?.name if (placedUnit.hasUnique("Can spread religion [] times")) placedUnit.abilityUsedCount["Religion Spread"] = 0 diff --git a/core/src/com/unciv/logic/civilization/ReligionManager.kt b/core/src/com/unciv/logic/civilization/ReligionManager.kt index 9c874fb02c..c6a680b004 100644 --- a/core/src/com/unciv/logic/civilization/ReligionManager.kt +++ b/core/src/com/unciv/logic/civilization/ReligionManager.kt @@ -182,7 +182,7 @@ class ReligionManager { fun numberOfCitiesFollowingThisReligion(): Int { if (religion == null) return 0 return civInfo.gameInfo.getCities() - .count { it.religion.getMajorityReligion() == religion!!.name } + .count { it.religion.getMajorityReligion() == religion } } fun numberOfFollowersFollowingThisReligion(cityFilter: String): Int { diff --git a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt index e42f82602b..f5ffea50da 100644 --- a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt +++ b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt @@ -8,7 +8,6 @@ import com.unciv.logic.trade.TradeType import com.unciv.models.ruleset.tile.ResourceSupplyList import com.unciv.models.translations.getPlaceholderParameters import com.unciv.models.translations.getPlaceholderText -import javax.management.relation.Relation import kotlin.math.ceil import kotlin.math.max import kotlin.math.min @@ -201,7 +200,7 @@ class DiplomacyManager() { restingPoint += unique.params[0].toInt() for (unique in otherCiv().getMatchingUniques("Resting point for Influence with City-States following this religion []")) - if (otherCiv().religionManager.religion?.name == civInfo.getCapital().religion.getMajorityReligion()) + if (otherCiv().religionManager.religion?.name == civInfo.getCapital().religion.getMajorityReligionName()) restingPoint += unique.params[0].toInt() if (diplomaticStatus == DiplomaticStatus.Protector) restingPoint += 5 diff --git a/core/src/com/unciv/models/UnitAction.kt b/core/src/com/unciv/models/UnitAction.kt index 9408db18bc..72bbd24f5d 100644 --- a/core/src/com/unciv/models/UnitAction.kt +++ b/core/src/com/unciv/models/UnitAction.kt @@ -35,8 +35,9 @@ data class UnitAction( type == UnitActionType.SpreadReligion && title.equalsPlaceholderText("Spread []") -> { val religionName = title.getPlaceholderParameters()[0] - ImageGetter.getReligionIcon( - if (ImageGetter.religionIconExists(religionName)) religionName else "Pantheon" + ImageGetter.getReligionImage( + if (ImageGetter.religionIconExists(religionName)) religionName + else "Pantheon" ).apply { color = Color.BLACK } } type == UnitActionType.Fortify || type == UnitActionType.FortifyUntilHealed -> { diff --git a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt index d3d6da72df..2846e29161 100644 --- a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt +++ b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt @@ -329,7 +329,7 @@ class BaseUnit : INamed, INonPerpetualConstruction, ICivilopediaText { unit.currentMovement = 0f if (unit.hasUnique("Religious Unit")) { - unit.religion = cityConstructions.cityInfo.religion.getMajorityReligion() + unit.religion = cityConstructions.cityInfo.religion.getMajorityReligionName() if (unit.canSpreadReligion()) unit.abilityUsedCount["Religion Spread"] = 0 } diff --git a/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt b/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt index 59330b8125..1180fd9cba 100644 --- a/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt +++ b/core/src/com/unciv/ui/cityscreen/CityStatsTable.kt @@ -2,13 +2,10 @@ package com.unciv.ui.cityscreen import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.scenes.scene2d.ui.Table -import com.unciv.logic.civilization.ReligionState +import com.badlogic.gdx.utils.Align import com.unciv.models.stats.Stat import com.unciv.models.translations.tr -import com.unciv.ui.utils.ImageGetter -import com.unciv.ui.utils.addSeparator -import com.unciv.ui.utils.colorFromRGB -import com.unciv.ui.utils.toLabel +import com.unciv.ui.utils.* import kotlin.math.ceil import kotlin.math.round @@ -43,10 +40,11 @@ class CityStatsTable(val cityScreen: CityScreen): Table() { addText() if (!cityInfo.population.getMaxSpecialists().isEmpty()) { innerTable.addSeparator() - innerTable.add(SpecialistAllocationTable(cityScreen).apply { update() }) + innerTable.add(SpecialistAllocationTable(cityScreen).apply { update() }).row() } - - addReligionInfo() + + if (cityInfo.religion.getNumberOfFollowers().isNotEmpty()) + addReligionInfo() pack() } @@ -85,11 +83,57 @@ class CityStatsTable(val cityScreen: CityScreen): Table() { } private fun addReligionInfo() { - // This will later become large enough to be its own class, but for now it is small enough to fit inside a single function - if(cityInfo.civInfo.religionManager.religionState == ReligionState.None) return - innerTable.addSeparator() - val label = cityInfo.religion.getMajorityReligion() + val label = cityInfo.religion.getMajorityReligionName() ?: "None" - innerTable.add("Majority Religion: [$label]".toLabel()).padTop(5f) + val expanderTab = + ExpanderTab( + title = "Majority Religion: [$label]", + fontSize = 18, + icon = ImageGetter.getCircledReligionIcon(label, 30f), + defaultPad = 0f, + persistenceID = "CityStatsTable.Religion", + startsOutOpened = false, + onChange = { + pack() + // We have to re-anchor as our position in the city screen, otherwise it expands upwards. + // This probably should be refactored so its placed somewhere else in due time + setPosition(stage.width - CityScreen.posFromEdge, stage.height - CityScreen.posFromEdge, Align.topRight) + } + ) { + it.add(getReligionsTable()).colspan(2).pad(5f) + } + + innerTable.add(expanderTab).growX().row() + } + + private fun getReligionsTable(): Table { + val gridColor = Color.DARK_GRAY + val religionsTable = Table(CameraStageBaseScreen.skin) + val followers = cityInfo.religion.getNumberOfFollowers() + val futurePressures = cityInfo.religion.getPressuresFromSurroundingCities() + + religionsTable.add().pad(5f) + religionsTable.addSeparatorVertical(gridColor) + religionsTable.add("Followers".toLabel()).pad(5f) + religionsTable.addSeparatorVertical(gridColor) + religionsTable.add("Pressure".toLabel()).pad(5f) + religionsTable.row() + religionsTable.addSeparator(gridColor) + + for ((religion, followerCount) in followers) { + religionsTable.add( + ImageGetter.getCircledReligionIcon(cityInfo.civInfo.gameInfo.religions[religion]!!.iconName, 30f) + ).pad(5f) + religionsTable.addSeparatorVertical(gridColor) + religionsTable.add(followerCount.toLabel()).pad(5f) + religionsTable.addSeparatorVertical(gridColor) + if (futurePressures.containsKey(religion)) + religionsTable.add(("+ [${futurePressures[religion]!!}] pressure").toLabel()).pad(5f) + else + religionsTable.add() + religionsTable.row() + } + + return religionsTable } } \ No newline at end of file diff --git a/core/src/com/unciv/ui/civilopedia/CivilopediaCategories.kt b/core/src/com/unciv/ui/civilopedia/CivilopediaCategories.kt index 96c6152320..3ea40117de 100644 --- a/core/src/com/unciv/ui/civilopedia/CivilopediaCategories.kt +++ b/core/src/com/unciv/ui/civilopedia/CivilopediaCategories.kt @@ -78,7 +78,7 @@ object CivilopediaImageGetters { val belief = { name: String, size: Float -> // Kludge until we decide how exactly to show Religions if (ImageGetter.imageExists("ReligionIcons/$name")) { - ImageGetter.getReligionIcon(name).surroundWithCircle(size, color = Color.BLACK) + ImageGetter.getCircledReligionIcon(name, size) } else null } diff --git a/core/src/com/unciv/ui/overviewscreen/CityOverviewTable.kt b/core/src/com/unciv/ui/overviewscreen/CityOverviewTable.kt index 2784a57740..2bbb0395ec 100644 --- a/core/src/com/unciv/ui/overviewscreen/CityOverviewTable.kt +++ b/core/src/com/unciv/ui/overviewscreen/CityOverviewTable.kt @@ -90,7 +90,7 @@ class CityOverviewTable(private val viewingPlayer: CivilizationInfo, private val cityInfoTableTotal.add(viewingPlayer.cities.sumBy { it.population.population }.toString().toLabel()).myAlign(Align.center) for (column in columnsNames.filter { it.isStat() }) { val stat = Stat.valueOf(column) - if (stat == Stat.Food || stat == Stat.Production) cityInfoTableTotal.add() //an intended empty space + if (stat == Stat.Food || stat == Stat.Production) cityInfoTableTotal.add() // an intended empty space else cityInfoTableTotal.add(viewingPlayer.cities.sumBy { getStatOfCity(it, stat) }.toLabel()).myAlign(Align.center) } cityInfoTableTotal.pack() diff --git a/core/src/com/unciv/ui/overviewscreen/ReligionOverviewTable.kt b/core/src/com/unciv/ui/overviewscreen/ReligionOverviewTable.kt index 91346f1be0..61ff846586 100644 --- a/core/src/com/unciv/ui/overviewscreen/ReligionOverviewTable.kt +++ b/core/src/com/unciv/ui/overviewscreen/ReligionOverviewTable.kt @@ -44,10 +44,10 @@ class ReligionOverviewTable( ImageGetter.getRandomNationIndicator(60f) button = Button(image, CameraStageBaseScreen.skin) } else { - val image = ImageGetter.getReligionIcon(religion.iconName) - image.color = Color.BLACK - val icon = image.surroundWithCircle(60f) - button = Button(icon, CameraStageBaseScreen.skin) + button = Button( + ImageGetter.getCircledReligionIcon(religion.iconName, 60f), + CameraStageBaseScreen.skin + ) } button.onClick { diff --git a/core/src/com/unciv/ui/pickerscreens/FoundReligionPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/FoundReligionPickerScreen.kt index 7b932456db..62a90a00b2 100644 --- a/core/src/com/unciv/ui/pickerscreens/FoundReligionPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/FoundReligionPickerScreen.kt @@ -70,15 +70,16 @@ class FoundReligionPickerScreen ( topReligionIcons.clear() // This should later be replaced with a user-modifiable text field, but not in this PR + // Note that this would require replacing 'religion.name' with 'religion.iconName' at many spots val descriptionLabel = "Choose an Icon and name for your Religion".toLabel() val iconsTable = Table() iconsTable.align(Align.center) for (religionName in gameInfo.ruleSet.religions) { - val image = ImageGetter.getReligionIcon(religionName) - image.color = Color.BLACK - val icon = image.surroundWithCircle(60f) - val button = Button(icon, skin) + val button = Button( + ImageGetter.getCircledReligionIcon(religionName, 60f), + skin + ) val translatedReligionName = religionName.tr() button.onClick { if (previouslySelectedIcon != null) { diff --git a/core/src/com/unciv/ui/tilegroups/CityButton.kt b/core/src/com/unciv/ui/tilegroups/CityButton.kt index 758e678aae..66fb569eda 100644 --- a/core/src/com/unciv/ui/tilegroups/CityButton.kt +++ b/core/src/com/unciv/ui/tilegroups/CityButton.kt @@ -253,10 +253,9 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Tab iconTable.add(nationIcon).size(20f) } - val cityReligionName = city.religion.getMajorityReligion() - if (cityReligionName != null) { - val cityReligion = city.civInfo.gameInfo.religions[cityReligionName]!! - val religionImage = ImageGetter.getReligionIcon(cityReligion.iconName) + val cityReligion = city.religion.getMajorityReligion() + if (cityReligion != null) { + val religionImage = ImageGetter.getReligionImage(cityReligion.iconName) iconTable.add(religionImage).size(20f).padLeft(5f).fillY() } diff --git a/core/src/com/unciv/ui/utils/ImageGetter.kt b/core/src/com/unciv/ui/utils/ImageGetter.kt index 10299145ee..bccbd21561 100644 --- a/core/src/com/unciv/ui/utils/ImageGetter.kt +++ b/core/src/com/unciv/ui/utils/ImageGetter.kt @@ -301,9 +301,12 @@ object ImageGetter { } fun religionIconExists(iconName: String) = imageExists("ReligionIcons/$iconName") - fun getReligionIcon(iconName: String): Image { + fun getReligionImage(iconName: String): Image { return getImage("ReligionIcons/$iconName") } + fun getCircledReligionIcon(iconName: String, size: Float): IconCircleGroup { + return getReligionImage(iconName).surroundWithCircle(size, color = Color.BLACK ) + } fun getBlue() = Color(0x004085bf)