diff --git a/core/src/com/unciv/logic/automation/civilization/DiplomacyAutomation.kt b/core/src/com/unciv/logic/automation/civilization/DiplomacyAutomation.kt index 2f2fe085bc..9edfe797af 100644 --- a/core/src/com/unciv/logic/automation/civilization/DiplomacyAutomation.kt +++ b/core/src/com/unciv/logic/automation/civilization/DiplomacyAutomation.kt @@ -337,7 +337,9 @@ object DiplomacyAutomation { for (enemyCiv in civInfo.getCivsAtWarWith().sortedByDescending { it.getStatForRanking(RankingType.Force) }) { val potentialAllies = enemyCiv.threatManager.getNeighboringCivilizations() - .filter { !it.isAtWarWith(enemyCiv) && civInfo.getDiplomacyManager(it).isRelationshipLevelGE(RelationshipLevel.Friend) + .filter { + civInfo.knows(it) && !it.isAtWarWith(enemyCiv) + && civInfo.getDiplomacyManager(it).isRelationshipLevelGE(RelationshipLevel.Friend) && !it.getDiplomacyManager(civInfo).hasFlag(DiplomacyFlags.DeclinedJoinWarOffer) } .sortedByDescending { it.getStatForRanking(RankingType.Force) } val civToAsk = potentialAllies.firstOrNull { diff --git a/core/src/com/unciv/models/ruleset/unique/StateForConditionals.kt b/core/src/com/unciv/models/ruleset/unique/StateForConditionals.kt index b7eb86b82c..74da9c2387 100644 --- a/core/src/com/unciv/models/ruleset/unique/StateForConditionals.kt +++ b/core/src/com/unciv/models/ruleset/unique/StateForConditionals.kt @@ -54,8 +54,16 @@ data class StateForConditionals( } val relevantCity by lazy { - city - ?: relevantTile?.getCity() + if (city != null) return@lazy city + // Edge case: If we attack a city, the "relevant tile" becomes the attacked tile - + // but we DO NOT want that city to become the relevant city because then *our* conditionals get checked against + // the *other civ's* cities, leading to e.g. resource amounts being defined as the *other civ's* resource amounts + val relevantTileForCity = tile ?: relevantUnit?.run { if (hasTile()) getTile() else null } + val cityForRelevantTile = relevantTileForCity?.getCity() + if (cityForRelevantTile != null && + // ...and we can't use the relevantCiv here either, because that'll cause a loop + (cityForRelevantTile.civ == civInfo || cityForRelevantTile.civ == relevantUnit?.civ)) return@lazy cityForRelevantTile + else return@lazy null } val relevantCiv by lazy {