From 186d06faf0e945f98a24fb2e934bed8586ace25c Mon Sep 17 00:00:00 2001 From: Xander Lenstra <71121390+xlenstra@users.noreply.github.com> Date: Wed, 1 Sep 2021 18:21:09 +0200 Subject: [PATCH] When spreading a religion with a great prophet, other religions are now removed (#5055) --- android/assets/jsons/Civ V - Vanilla/Units.json | 6 +++--- core/src/com/unciv/logic/city/CityReligion.kt | 8 +++++--- core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt | 2 ++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/android/assets/jsons/Civ V - Vanilla/Units.json b/android/assets/jsons/Civ V - Vanilla/Units.json index 89afe872bf..3d5a46f964 100644 --- a/android/assets/jsons/Civ V - Vanilla/Units.json +++ b/android/assets/jsons/Civ V - Vanilla/Units.json @@ -1516,9 +1516,9 @@ "name": "Great Prophet", "unitType": "Civilian", "uniques": ["Can construct [Holy site] if it hasn't used other actions yet", "Can [Spread Religion] [4] times", - "May found a religion", "May enhance a religion", "May enter foreign tiles without open borders", - "[-1] Visibility Range", "Great Person - [Faith]", "Unbuildable", "Religious Unit", - "Hidden when religion is disabled"], + "Removes other religions when spreading religion", "May found a religion", "May enhance a religion", + "May enter foreign tiles without open borders", "[-1] Visibility Range", "Great Person - [Faith]", + "Unbuildable", "Religious Unit", "Hidden when religion is disabled"], "movement": 2, "religiousStrength": 1000 }, diff --git a/core/src/com/unciv/logic/city/CityReligion.kt b/core/src/com/unciv/logic/city/CityReligion.kt index dc98b20aff..0e50828871 100644 --- a/core/src/com/unciv/logic/city/CityReligion.kt +++ b/core/src/com/unciv/logic/city/CityReligion.kt @@ -59,8 +59,7 @@ class CityInfoReligionManager { } fun getUniques(): Sequence { - val majorityReligion = getMajorityReligion() - if (majorityReligion == null) return sequenceOf() + val majorityReligion = getMajorityReligion() ?: return sequenceOf() return majorityReligion.getFollowerUniques() } @@ -72,7 +71,7 @@ class CityInfoReligionManager { return pressures.clone() } - fun clearAllPressures() { + private fun clearAllPressures() { pressures.clear() // We add pressure for following no religion // Basically used as a failsafe so that there is always some religion, @@ -92,8 +91,11 @@ class CityInfoReligionManager { fun removeAllPressuresExceptFor(religion: String) { val pressureFromThisReligion = pressures[religion]!! + // Atheism is never removed + val pressureFromAtheism = pressures[Constants.noReligionName] clearAllPressures() pressures.add(religion, pressureFromThisReligion) + if (pressureFromAtheism != null) pressures[Constants.noReligionName] = pressureFromAtheism updateNumberOfFollowers() } diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt index 4dbbb355f1..14d913f446 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt @@ -557,6 +557,8 @@ object UnitActions { unit.civInfo.addStat(Stat.valueOf(unique.params[1]), followersOfOtherReligions * unique.params[0].toInt()) } city.religion.addPressure(unit.religion!!, unit.getPressureAddedFromSpread()) + if (unit.hasUnique("Removes other religions when spreading religion")) + city.religion.removeAllPressuresExceptFor(unit.religion!!) unit.currentMovement = 0f useActionWithLimitedUses(unit, Constants.spreadReligionAbilityCount) }.takeIf { unit.currentMovement > 0 && !blockedByInquisitor }