mirror of
https://github.com/yairm210/Unciv.git
synced 2025-03-13 19:39:34 +07:00
Allows inquisitors to block holy cities (#7521)
* Inquisitors can disable holy cities * Templates and notifications * Combined with changes of previous religious PR * Reviews
This commit is contained in:
parent
af6ab8e4e5
commit
4eb0038d10
@ -858,6 +858,8 @@ You gained [Stats] as your religion was spread to [cityName] =
|
||||
You gained [Stats] as your religion was spread to an unknown city =
|
||||
Your city [cityName] was converted to [religionName]! =
|
||||
Your [unitName] lost its faith after spending too long inside enemy territory! =
|
||||
An [unitName] has removed your religion [religionName] from its Holy City [cityName]! =
|
||||
An [unitName] has restored [cityName] as the Holy City of your religion [religionName]! =
|
||||
You have unlocked [ability] =
|
||||
A new b'ak'tun has just begun! =
|
||||
A Great Person joins you! =
|
||||
@ -1401,7 +1403,8 @@ Follow [belief] =
|
||||
Religions and Beliefs =
|
||||
Majority Religion: [name] =
|
||||
+ [amount] pressure =
|
||||
Holy city of: [religionName] =
|
||||
Holy City of: [religionName] =
|
||||
Former Holy City of: [religionName] =
|
||||
Followers =
|
||||
Pressure =
|
||||
|
||||
|
@ -127,7 +127,7 @@ object ReligionAutomation {
|
||||
val citiesWithBonusCharges = validCitiesToBuy.filter { city ->
|
||||
city.getLocalMatchingUniques(UniqueType.UnitStartingActions).filter { it.params[2] == Constants.spreadReligion }.any()
|
||||
}
|
||||
val holyCity = validCitiesToBuy.firstOrNull { it.religion.religionThisIsTheHolyCityOf == civInfo.religionManager.religion!!.name }
|
||||
val holyCity = validCitiesToBuy.firstOrNull { it.isHolyCityOf(civInfo.religionManager.religion!!.name) }
|
||||
|
||||
val cityToBuyMissionary = when {
|
||||
citiesWithBonusCharges.any() -> citiesWithBonusCharges.first()
|
||||
|
@ -331,17 +331,19 @@ object SpecificUnitAutomation {
|
||||
}
|
||||
|
||||
fun automateInquisitor(unit: MapUnit) {
|
||||
if (unit.religion != unit.civInfo.religionManager.religion?.name || unit.religion == null)
|
||||
val civReligion = unit.civInfo.religionManager.religion
|
||||
|
||||
if (unit.religion != civReligion?.name || unit.religion == null)
|
||||
return unit.disband() // No need to keep a unit we can't use, as it only blocks religion spreads of religions other that its own
|
||||
|
||||
val holyCity = unit.civInfo.religionManager.getHolyCity()
|
||||
val cityToConvert = determineBestInquisitorCityToConvert(unit) // Also returns null if the inquisitor can't convert cities
|
||||
val pressureDeficit =
|
||||
if (cityToConvert == null) 0
|
||||
else cityToConvert.religion.getPressureDeficit(unit.civInfo.religionManager.religion?.name)
|
||||
else cityToConvert.religion.getPressureDeficit(civReligion?.name)
|
||||
|
||||
val citiesToProtect = unit.civInfo.cities.asSequence()
|
||||
.filter { it.religion.getMajorityReligion() == unit.civInfo.religionManager.religion }
|
||||
.filter { it.religion.getMajorityReligion() == civReligion }
|
||||
// We only look at cities that are not currently protected or are protected by us
|
||||
.filter { !it.religion.isProtectedByInquisitor() || unit.getTile() in it.getCenterTile().getTilesInDistance(1) }
|
||||
|
||||
@ -352,8 +354,10 @@ object SpecificUnitAutomation {
|
||||
|
||||
destination = when {
|
||||
cityToConvert != null
|
||||
&& (cityToConvert == holyCity || pressureDeficit > Constants.aiPreferInquisitorOverMissionaryPressureDifference)
|
||||
&& unit.canDoReligiousAction(Constants.removeHeresy) -> {
|
||||
&& (cityToConvert == holyCity
|
||||
|| pressureDeficit > Constants.aiPreferInquisitorOverMissionaryPressureDifference
|
||||
|| cityToConvert.religion.isBlockedHolyCity && cityToConvert.religion.religionThisIsTheHolyCityOf == civReligion?.name
|
||||
) && unit.canDoReligiousAction(Constants.removeHeresy) -> {
|
||||
cityToConvert.getCenterTile()
|
||||
}
|
||||
cityToProtect != null && unit.hasUnique(UniqueType.PreventSpreadingReligion) -> {
|
||||
@ -392,6 +396,10 @@ object SpecificUnitAutomation {
|
||||
if (holyCity != null && holyCity.religion.getMajorityReligion() != unit.civInfo.religionManager.religion!!)
|
||||
return holyCity
|
||||
|
||||
val blockedHolyCity = unit.civInfo.cities.firstOrNull { it.religion.isBlockedHolyCity && it.religion.religionThisIsTheHolyCityOf == unit.religion }
|
||||
if (blockedHolyCity != null)
|
||||
return blockedHolyCity
|
||||
|
||||
return unit.civInfo.cities.asSequence()
|
||||
.filter { it.religion.getMajorityReligion() != null }
|
||||
.filter { it.religion.getMajorityReligion()!! != unit.civInfo.religionManager.religion }
|
||||
|
@ -584,7 +584,8 @@ class CityInfo : IsPartOfGameInfoSerialization {
|
||||
|
||||
override fun toString() = name // for debug
|
||||
|
||||
fun isHolyCity(): Boolean = religion.religionThisIsTheHolyCityOf != null
|
||||
fun isHolyCity(): Boolean = religion.religionThisIsTheHolyCityOf != null && !religion.isBlockedHolyCity
|
||||
fun isHolyCityOf(religionName: String?) = isHolyCity() && religion.religionThisIsTheHolyCityOf == religionName
|
||||
|
||||
fun canBeDestroyed(justCaptured: Boolean = false): Boolean {
|
||||
return !isOriginalCapital && !isHolyCity() && (!isCapital() || justCaptured)
|
||||
@ -919,7 +920,7 @@ class CityInfo : IsPartOfGameInfoSerialization {
|
||||
"in foreign cities" -> viewingCiv != civInfo
|
||||
"in annexed cities" -> foundingCiv != civInfo.civName && !isPuppet
|
||||
"in puppeted cities" -> isPuppet
|
||||
"in holy cities" -> religion.religionThisIsTheHolyCityOf != null
|
||||
"in holy cities" -> isHolyCity()
|
||||
"in City-State cities" -> civInfo.isCityState()
|
||||
// This is only used in communication to the user indicating that only in cities with this
|
||||
// religion a unique is active. However, since religion uniques only come from the city itself,
|
||||
|
@ -26,6 +26,7 @@ class CityInfoReligionManager : IsPartOfGameInfoSerialization {
|
||||
private val pressureFromAdjacentCities: Int by lazy { cityInfo.civInfo.gameInfo.speed.religiousPressureAdjacentCity }
|
||||
|
||||
var religionThisIsTheHolyCityOf: String? = null
|
||||
var isBlockedHolyCity = false
|
||||
|
||||
init {
|
||||
clearAllPressures()
|
||||
@ -38,6 +39,7 @@ class CityInfoReligionManager : IsPartOfGameInfoSerialization {
|
||||
toReturn.pressures.putAll(pressures)
|
||||
toReturn.followers.putAll(followers)
|
||||
toReturn.religionThisIsTheHolyCityOf = religionThisIsTheHolyCityOf
|
||||
toReturn.isBlockedHolyCity = isBlockedHolyCity
|
||||
return toReturn
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ class ReligionManager : IsPartOfGameInfoSerialization {
|
||||
if (Random(civInfo.gameInfo.turns).nextFloat() < prophetSpawnChange) {
|
||||
val birthCity =
|
||||
if (religionState <= ReligionState.Pantheon) civInfo.getCapital()
|
||||
else civInfo.cities.firstOrNull { it.religion.religionThisIsTheHolyCityOf == religion!!.name }
|
||||
else civInfo.religionManager.getHolyCity()
|
||||
val prophet = civInfo.addUnit(prophetUnitName, birthCity) ?: return
|
||||
prophet.religion = religion!!.name
|
||||
storedFaith -= faithForNextGreatProphet()
|
||||
@ -362,7 +362,7 @@ class ReligionManager : IsPartOfGameInfoSerialization {
|
||||
|
||||
fun getHolyCity(): CityInfo? {
|
||||
if (religion == null) return null
|
||||
return civInfo.gameInfo.getCities().firstOrNull { it.religion.religionThisIsTheHolyCityOf == religion!!.name }
|
||||
return civInfo.gameInfo.getCities().firstOrNull { it.isHolyCityOf(religion!!.name) }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,11 @@ class CityReligionInfoTable(
|
||||
val (iconName, label) = getIconAndLabel(religionManager.religionThisIsTheHolyCityOf)
|
||||
add(linkedReligionIcon(iconName, religionManager.religionThisIsTheHolyCityOf)).pad(5f)
|
||||
add()
|
||||
add("Holy city of: [$label]".toLabel()).colspan(3).center().row()
|
||||
if (!religionManager.isBlockedHolyCity) {
|
||||
add("Holy City of: [$label]".toLabel()).colspan(3).center().row()
|
||||
} else {
|
||||
add("Former Holy City of: [$label]".toLabel()).colspan(3).center().row()
|
||||
}
|
||||
}
|
||||
|
||||
if (!followers.isEmpty()) {
|
||||
|
@ -142,7 +142,7 @@ class ReligionOverviewTab(
|
||||
else Constants.unknownNationName
|
||||
statsTable.add(foundingCivName.toLabel()).right().row()
|
||||
if (religion.isMajorReligion()) {
|
||||
val holyCity = gameInfo.getCities().firstOrNull { it.religion.religionThisIsTheHolyCityOf == religion.name }
|
||||
val holyCity = gameInfo.getCities().firstOrNull { it.isHolyCityOf(religion.name) }
|
||||
if (holyCity != null) {
|
||||
statsTable.add("Holy City:".toLabel())
|
||||
val cityName =
|
||||
|
@ -684,6 +684,16 @@ object UnitActions {
|
||||
title = "Remove Heresy",
|
||||
action = {
|
||||
city.religion.removeAllPressuresExceptFor(unit.religion!!)
|
||||
if (city.religion.religionThisIsTheHolyCityOf != null) {
|
||||
val religion = unit.civInfo.gameInfo.religions[city.religion.religionThisIsTheHolyCityOf]!!
|
||||
if (city.religion.religionThisIsTheHolyCityOf != unit.religion && !city.religion.isBlockedHolyCity) {
|
||||
religion.getFounder().addNotification("An [${unit.baseUnit.name}] has removed your religion [${religion.getReligionDisplayName()}] from its Holy City [${city.name}]!")
|
||||
city.religion.isBlockedHolyCity = false
|
||||
} else if (city.religion.religionThisIsTheHolyCityOf == unit.religion && city.religion.isBlockedHolyCity) {
|
||||
religion.getFounder().addNotification("An [${unit.baseUnit.name}] has restored [${city.name}] as the Holy City of your religion [${religion.getReligionDisplayName()}]!")
|
||||
city.religion.isBlockedHolyCity = true
|
||||
}
|
||||
}
|
||||
unit.currentMovement = 0f
|
||||
useActionWithLimitedUses(unit, Constants.removeHeresy)
|
||||
}.takeIf { unit.currentMovement > 0f }
|
||||
|
Loading…
Reference in New Issue
Block a user