Spectator now receives important diplomatic notifications again (#10880)

This commit is contained in:
Oskar Niesen
2024-01-07 08:07:25 -06:00
committed by GitHub
parent 50a6e5bbdb
commit be13394b44
3 changed files with 10 additions and 6 deletions

View File

@ -324,6 +324,9 @@ class Civilization : IsPartOfGameInfoSerialization {
fun getKnownCivs() = diplomacy.values.asSequence().map { it.otherCiv() }
.filter { !it.isDefeated() && !it.isSpectator() }
fun getKnownCivsWithSpectators() = diplomacy.values.asSequence().map { it.otherCiv() }
.filter { !it.isDefeated() }
fun knows(otherCivName: String) = diplomacy.containsKey(otherCivName)
fun knows(otherCiv: Civilization) = knows(otherCiv.civName)

View File

@ -46,7 +46,7 @@ object DeclareWar {
NotificationCategory.Diplomacy, NotificationIcon.War, civInfo.civName)
otherCiv.popupAlerts.add(PopupAlert(AlertType.WarDeclaration, civInfo.civName))
diplomacyManager.getCommonKnownCivs().forEach {
diplomacyManager.getCommonKnownCivsWithSpectators().forEach {
it.addNotification("[${civInfo.civName}] has declared war on [${diplomacyManager.otherCivName}]!",
NotificationCategory.Diplomacy, civInfo.civName, NotificationIcon.War, diplomacyManager.otherCivName)
}
@ -179,7 +179,7 @@ object DeclareWar {
thirdPartyDiploManager.removeFlag(DiplomacyFlags.DefensivePact)
thirdPartyDiploManager.otherCivDiplomacy().removeFlag(DiplomacyFlags.DefensivePact)
}
for (civ in diplomacyManager.getCommonKnownCivs().filter { civ -> civ.isMajorCiv() || civ.isSpectator() }) {
for (civ in diplomacyManager.getCommonKnownCivsWithSpectators()) {
civ.addNotification("[${diplomacyManager.civInfo.civName}] canceled their Defensive Pact with [${thirdPartyDiploManager.otherCivName}]!",
NotificationCategory.Diplomacy, diplomacyManager.civInfo.civName, NotificationIcon.Diplomacy, thirdPartyDiploManager.otherCivName)
}

View File

@ -405,6 +405,7 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization {
/** Returns the [civilizations][Civilization] that know about both sides ([civInfo] and [otherCiv]) */
fun getCommonKnownCivs(): Set<Civilization> = civInfo.getKnownCivs().toSet().intersect(otherCiv().getKnownCivs().toSet())
fun getCommonKnownCivsWithSpectators(): Set<Civilization> = civInfo.getKnownCivsWithSpectators().toSet().intersect(otherCiv().getKnownCivsWithSpectators().toSet())
/** Returns true when the [civInfo]'s territory is considered allied for [otherCiv].
* This includes friendly and allied city-states and the open border treaties.
*/
@ -458,7 +459,7 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization {
makePeaceOneSide()
otherCivDiplomacy().makePeaceOneSide()
for (civ in getCommonKnownCivs()) {
for (civ in getCommonKnownCivsWithSpectators()) {
civ.addNotification(
"[${civInfo.civName}] and [$otherCivName] have signed a Peace Treaty!",
NotificationCategory.Diplomacy, civInfo.civName, NotificationIcon.Diplomacy, otherCivName
@ -501,7 +502,7 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization {
setFlag(DiplomacyFlags.DeclarationOfFriendship, 30)
otherCivDiplomacy().setFlag(DiplomacyFlags.DeclarationOfFriendship, 30)
for (thirdCiv in getCommonKnownCivs().filter { it.isMajorCiv() || it.isSpectator() }) {
for (thirdCiv in getCommonKnownCivsWithSpectators()) {
thirdCiv.addNotification("[${civInfo.civName}] and [$otherCivName] have signed the Declaration of Friendship!",
NotificationCategory.Diplomacy, civInfo.civName, NotificationIcon.Diplomacy, otherCivName)
thirdCiv.getDiplomacyManager(civInfo).setFriendshipBasedModifier()
@ -549,7 +550,7 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization {
otherCivDiplomacy().diplomaticStatus = DiplomaticStatus.DefensivePact
for (thirdCiv in getCommonKnownCivs().filter { it.isMajorCiv() || it.isSpectator() }) {
for (thirdCiv in getCommonKnownCivsWithSpectators()) {
thirdCiv.addNotification("[${civInfo.civName}] and [$otherCivName] have signed the Defensive Pact!",
NotificationCategory.Diplomacy, civInfo.civName, NotificationIcon.Diplomacy, otherCivName)
if (thirdCiv.isSpectator()) return
@ -597,7 +598,7 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization {
NotificationCategory.Diplomacy, NotificationIcon.Diplomacy, civInfo.civName)
// We, A, are denouncing B. What do other major civs (C,D, etc) think of this?
getCommonKnownCivs().filter { it.isMajorCiv() || it.isSpectator() }.forEach { thirdCiv ->
getCommonKnownCivsWithSpectators().forEach { thirdCiv ->
thirdCiv.addNotification("[${civInfo.civName}] has denounced [$otherCivName]!",
NotificationCategory.Diplomacy, civInfo.civName, NotificationIcon.Diplomacy, otherCivName)
if (thirdCiv.isSpectator()) return@forEach