From 913cb3cf00ba3b69365ef875048908c0399d87f7 Mon Sep 17 00:00:00 2001 From: OptimizedForDensity <105244635+OptimizedForDensity@users.noreply.github.com> Date: Tue, 31 Jan 2023 16:07:12 -0500 Subject: [PATCH] Fix Faith Healers healing enemies (#8522) * Fix faith healers belief and add Friendly/Enemy mapUnitFilter support * Use Ally instead of Friendly since Ally denotes the ally of a CS and not necessarily a friendly civ * Fewer words * Remove mapFilter implementation * Remove nullability --- core/src/com/unciv/logic/map/mapunit/MapUnit.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/src/com/unciv/logic/map/mapunit/MapUnit.kt b/core/src/com/unciv/logic/map/mapunit/MapUnit.kt index e6c2c814c1..2adf48f790 100644 --- a/core/src/com/unciv/logic/map/mapunit/MapUnit.kt +++ b/core/src/com/unciv/logic/map/mapunit/MapUnit.kt @@ -612,7 +612,7 @@ class MapUnit : IsPartOfGameInfoSerialization { }?.getCity() if (healingCity != null) { for (unique in healingCity.getMatchingUniques(UniqueType.CityHealingUnits)) { - if (!matchesFilter(unique.params[0])) continue + if (!matchesFilter(unique.params[0]) || !isAlly(healingCity.civInfo)) continue // only heal our units or allied units healing += unique.params[1].toInt() } } @@ -876,6 +876,12 @@ class MapUnit : IsPartOfGameInfoSerialization { } + private fun isAlly(otherCiv: Civilization): Boolean { + return otherCiv == civInfo + || (otherCiv.isCityState() && otherCiv.getAllyCiv() == civInfo.civName) + || (civInfo.isCityState() && civInfo.getAllyCiv() == otherCiv.civName) + } + /** Implements [UniqueParameterType.MapUnitFilter][com.unciv.models.ruleset.unique.UniqueParameterType.MapUnitFilter] */ fun matchesFilter(filter: String): Boolean { return filter.filterAndLogic { matchesFilter(it) } // multiple types at once - AND logic. Looks like:"{Military} {Land}"