diff --git a/android/assets/jsons/Civ V - Gods & Kings/Units.json b/android/assets/jsons/Civ V - Gods & Kings/Units.json index 83ea3e5739..af80738377 100644 --- a/android/assets/jsons/Civ V - Gods & Kings/Units.json +++ b/android/assets/jsons/Civ V - Gods & Kings/Units.json @@ -1638,8 +1638,8 @@ "Can instantly construct a [Holy site] improvement ", "Can Spread Religion <[4] times>", "Removes other religions when spreading religion", - "May found a religion ", - "May enhance a religion", + "May found a religion ", + "May enhance a religion ", "May enter foreign tiles without open borders", "[-1] Sight", "Great Person - [Faith]", "Unbuildable", "Religious Unit", "Hidden when religion is disabled", "Takes your religion over the one in their birth city"], diff --git a/android/assets/jsons/Civ V - Vanilla/Units.json b/android/assets/jsons/Civ V - Vanilla/Units.json index b08baf5241..abbfcd65f2 100644 --- a/android/assets/jsons/Civ V - Vanilla/Units.json +++ b/android/assets/jsons/Civ V - Vanilla/Units.json @@ -1296,8 +1296,8 @@ "Can instantly construct a [Holy site] improvement ", "Can Spread Religion <[4] times>", "Removes other religions when spreading religion", - "May found a religion ", - "May enhance a religion", + "May found a religion ", + "May enhance a religion ", "May enter foreign tiles without open borders", "[-1] Sight", "Great Person - [Faith]", "Unbuildable", "Religious Unit", "Hidden when religion is disabled", "Takes your religion over the one in their birth city"], diff --git a/core/src/com/unciv/logic/automation/unit/SpecificUnitAutomation.kt b/core/src/com/unciv/logic/automation/unit/SpecificUnitAutomation.kt index c200069208..9353b6f453 100644 --- a/core/src/com/unciv/logic/automation/unit/SpecificUnitAutomation.kt +++ b/core/src/com/unciv/logic/automation/unit/SpecificUnitAutomation.kt @@ -18,7 +18,6 @@ import com.unciv.models.ruleset.unique.UniqueType import com.unciv.models.stats.Stat import com.unciv.ui.screens.worldscreen.unit.actions.UnitActions import com.unciv.ui.screens.worldscreen.unit.actions.UnitActionsFromUniques -import com.unciv.ui.screens.worldscreen.unit.actions.UnitActionsReligion object SpecificUnitAutomation { @@ -630,7 +629,7 @@ object SpecificUnitAutomation { if (!unit.getTile().isCityCenter()) return - UnitActionsReligion.getEnhanceReligionAction(unit)() + UnitActions.invokeUnitAction(unit, UnitActionType.EnhanceReligion) } } diff --git a/core/src/com/unciv/logic/civilization/managers/ReligionManager.kt b/core/src/com/unciv/logic/civilization/managers/ReligionManager.kt index 853c16eca0..9bad600483 100644 --- a/core/src/com/unciv/logic/civilization/managers/ReligionManager.kt +++ b/core/src/com/unciv/logic/civilization/managers/ReligionManager.kt @@ -287,11 +287,9 @@ class ReligionManager : IsPartOfGameInfoSerialization { } fun mayEnhanceReligionAtAll(prophet: MapUnit): Boolean { - if (!civInfo.gameInfo.isReligionEnabled()) return false // No religion, no enhancing + if (!civInfo.gameInfo.isReligionEnabled()) return false if (religion == null) return false // First found a pantheon if (religionState != ReligionState.Religion) return false // First found an actual religion - // Already used its power for other things - if (prophet.abilityUsesLeft.any { it.value != prophet.maxAbilityUses[it.key] }) return false if (!civInfo.isMajorCiv()) return false // Only major civs if (numberOfBeliefsAvailable(BeliefType.Follower) == 0) diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt index 6e65d51525..e889d4724c 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt @@ -317,11 +317,10 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags: CanSpreadReligion("Can Spread Religion", UniqueTarget.UnitAction), CanRemoveHeresy("Can remove other religions from cities", UniqueTarget.UnitAction), MayFoundReligion("May found a religion", UniqueTarget.UnitAction), + MayEnhanceReligion("May enhance a religion", UniqueTarget.UnitAction), BuildImprovements("Can build [improvementFilter/terrainFilter] improvements on tiles", UniqueTarget.Unit), - CreateWaterImprovements("May create improvements on water resources", UniqueTarget.Unit), - MayEnhanceReligion("May enhance a religion", UniqueTarget.Unit), AddInCapital("Can be added to [comment] in the Capital", UniqueTarget.Unit), PreventSpreadingReligion("Prevents spreading of religion to the city it is next to", UniqueTarget.Unit), diff --git a/core/src/com/unciv/ui/screens/worldscreen/unit/actions/UnitActionsReligion.kt b/core/src/com/unciv/ui/screens/worldscreen/unit/actions/UnitActionsReligion.kt index c1d333f4f1..3e5c793e3c 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/unit/actions/UnitActionsReligion.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/unit/actions/UnitActionsReligion.kt @@ -42,22 +42,32 @@ object UnitActionsReligion { } internal fun addEnhanceReligionAction(unit: MapUnit, actionList: ArrayList) { - if (!unit.hasUnique(UniqueType.MayEnhanceReligion)) return if (!unit.civ.religionManager.mayEnhanceReligionAtAll(unit)) return + + val unique = UnitActionModifiers.getUsableUnitActionUniques(unit, UniqueType.MayEnhanceReligion) + .firstOrNull() ?: return + + val hasActionModifiers = unique.conditionals.any { it.type?.targetTypes?.contains( + UniqueTarget.UnitActionModifier + ) == true } + + val baseTitle = "Enhance [${unit.civ.religionManager.religion!!.getReligionDisplayName()}]" actionList += UnitAction( UnitActionType.EnhanceReligion, - title = "Enhance [${unit.civ.religionManager.religion!!.getReligionDisplayName()}]", - action = getEnhanceReligionAction(unit).takeIf { unit.civ.religionManager.mayEnhanceReligionNow(unit) } + title = if (hasActionModifiers) UnitActionModifiers.actionTextWithSideEffects( + baseTitle, + unique, + unit + ) + else baseTitle, + action = { + unit.civ.religionManager.useProphetForEnhancingReligion(unit) + if (hasActionModifiers) UnitActionModifiers.activateSideEffects(unit, unique) + else unit.consume() + }.takeIf { unit.civ.religionManager.mayEnhanceReligionNow(unit) } ) } - fun getEnhanceReligionAction(unit: MapUnit): () -> Unit { - return { - unit.civ.religionManager.useProphetForEnhancingReligion(unit) - unit.consume() - } - } - private fun useActionWithLimitedUses(unit: MapUnit, action: String) { unit.abilityUsesLeft[action] = unit.abilityUsesLeft[action]!! - 1 if (unit.abilityUsesLeft[action]!! <= 0) { diff --git a/docs/Modders/uniques.md b/docs/Modders/uniques.md index 1366b7f870..1fd0410640 100644 --- a/docs/Modders/uniques.md +++ b/docs/Modders/uniques.md @@ -1113,6 +1113,9 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl ??? example "May found a religion" Applicable to: UnitAction +??? example "May enhance a religion" + Applicable to: UnitAction + ## Unit uniques !!! note "" @@ -1126,9 +1129,6 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl ??? example "May create improvements on water resources" Applicable to: Unit -??? example "May enhance a religion" - Applicable to: Unit - ??? example "Can be added to [comment] in the Capital" Example: "Can be added to [comment] in the Capital"