From df853504ae05b11e7da6c98efc6a19ffedbe63dc Mon Sep 17 00:00:00 2001 From: Xander Lenstra <71121390+xlenstra@users.noreply.github.com> Date: Thu, 2 Sep 2021 19:52:24 +0200 Subject: [PATCH] Great Prophets now always have your religion as their religion (#5052) * Great Prophets now always have your religion as their religion * Reworded unique for clarity --- android/assets/jsons/Civ V - Vanilla/Units.json | 3 ++- .../com/unciv/logic/civilization/CivilizationInfo.kt | 8 ++++++-- .../com/unciv/logic/civilization/ReligionManager.kt | 4 ++++ core/src/com/unciv/models/ruleset/unit/BaseUnit.kt | 10 +++++++--- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/android/assets/jsons/Civ V - Vanilla/Units.json b/android/assets/jsons/Civ V - Vanilla/Units.json index 3d5a46f964..5b7189a50d 100644 --- a/android/assets/jsons/Civ V - Vanilla/Units.json +++ b/android/assets/jsons/Civ V - Vanilla/Units.json @@ -1518,7 +1518,8 @@ "uniques": ["Can construct [Holy site] if it hasn't used other actions yet", "Can [Spread Religion] [4] times", "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"], + "Unbuildable", "Religious Unit", "Hidden when religion is disabled", + "Takes your religion over the one in their birth city"], "movement": 2, "religiousStrength": 1000 }, diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index 325c98805e..c9ea7d3ac2 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -820,8 +820,12 @@ class CivilizationInfo { if (placedUnit.hasUnique("Religious Unit")) { placedUnit.religion = - if (city != null) city.cityConstructions.cityInfo.religion.getMajorityReligionName() - else religionManager.religion?.name + when { + placedUnit.hasUnique("Takes your religion over the one in their birth city") -> + religionManager.religion?.name + city != null -> city.cityConstructions.cityInfo.religion.getMajorityReligionName() + else -> religionManager.religion?.name + } placedUnit.setupAbilityUses() } diff --git a/core/src/com/unciv/logic/civilization/ReligionManager.kt b/core/src/com/unciv/logic/civilization/ReligionManager.kt index be026794da..3402e28fc9 100644 --- a/core/src/com/unciv/logic/civilization/ReligionManager.kt +++ b/core/src/com/unciv/logic/civilization/ReligionManager.kt @@ -230,6 +230,10 @@ class ReligionManager { foundingCityId = null shouldChoosePantheonBelief = false + + for (unit in civInfo.getCivUnits()) + if (unit.hasUnique("Religious Unit") && unit.hasUnique("Takes your religion over the one in their birth city")) + unit.religion = newReligion.name } fun mayEnhanceReligionAtAll(prophet: MapUnit): Boolean { diff --git a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt index d10e88be2e..94431993dd 100644 --- a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt +++ b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt @@ -388,17 +388,21 @@ class BaseUnit : INamed, INonPerpetualConstruction, ICivilopediaText { // If this unit has special abilities that need to be kept track of, start doing so here if (unit.hasUnique("Religious Unit")) { - unit.religion = cityConstructions.cityInfo.religion.getMajorityReligionName() + unit.religion = + if (unit.hasUnique("Takes your religion over the one in their birth city")) + civInfo.religionManager.religion?.name + else cityConstructions.cityInfo.religion.getMajorityReligionName() + unit.setupAbilityUses(cityConstructions.cityInfo) } if (boughtWith != null && cityConstructions.cityInfo.civInfo.getMatchingUniques("May buy [] units for [] [] [] starting from the [] at an increasing price ([])") - .filter { + .any { matchesFilter(it.params[0]) && cityConstructions.cityInfo.matchesFilter(it.params[3]) && cityConstructions.cityInfo.civInfo.getEraNumber() >= ruleset.getEraNumber(it.params[4]) && it.params[2] == boughtWith.name - }.any() + } ) { cityConstructions.cityInfo.civInfo.boughtConstructionsWithGloballyIncreasingPrice[name] = (cityConstructions.cityInfo.civInfo.boughtConstructionsWithGloballyIncreasingPrice[name] ?: 0) + 1