When spreading a religion with a great prophet, other religions are now removed (#5055)

This commit is contained in:
Xander Lenstra 2021-09-01 18:21:09 +02:00 committed by GitHub
parent b347366d50
commit 186d06faf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 6 deletions

View File

@ -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
},

View File

@ -59,8 +59,7 @@ class CityInfoReligionManager {
}
fun getUniques(): Sequence<Unique> {
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()
}

View File

@ -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 }