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
This commit is contained in:
OptimizedForDensity 2023-01-31 16:07:12 -05:00 committed by GitHub
parent 03d5ba0f07
commit 913cb3cf00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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