Added the notification for the third-party civilizations (#1558)

* Added the notification for the third-party civilizations

If a civilizations knows about some two civilizations, it will be notified when:
* They declare the war
* They make a peace
* They sign the declaration of peace
* One denounce the other

Additionally, when civ enters a new era, all civs that know about it get a notification

* Fixed the translation `.properties`

* Cleanup

* Fix: 2 notifications for each peace treaty

Russia and America...
America and Russia...

* Typo

* Code style changes

* Resolved conflicts

* Simple getCommonKnownCivs() tests
This commit is contained in:
lyrjie 2019-12-30 19:12:14 +03:00 committed by Yair Morgenstern
parent 2132c49d55
commit cedb6ff5e3
23 changed files with 331 additions and 12 deletions

View File

@ -316,6 +316,15 @@ Indeed! = Vskutku!
Denounce ([numberOfTurns] turns) = Odsoudit ([numberOfTurns] kol)
We will remember this. = To vám nikdy nezapomeneme!
# Requires translation!
[civName] has declared war on [targetCivName]! =
# Requires translation!
[civName] and [targetCivName] have signed the Peace Treaty! =
# Requires translation!
[civName] and [targetCivName] have signed the Declaration of Friendship! =
# Requires translation!
[civName] has denounced [targetCivName]! =
Unforgivable = Nenávist
Enemy = Nepřátelství
Competitor = Negativní
@ -837,6 +846,8 @@ Your trade mission to [civName] has earned you [goldAmount] gold and [influenceA
Hurry Wonder = Uspíšit stavbu Divu
Your citizens have been happy with your rule for so long that the empire enters a Golden Age! = Naši občané jsou spokojeni s vaší vládou po dlouhou dobu díky čemuž říše vstoupila do Zlatého věku!
You have entered the [newEra]! = Vstoupili jsme do éry [newEra]!
# Requires translation!
[civName] has entered the [eraName]! =
[policyBranch] policy branch unlocked! = Zpřístupněna větev sociální politiky: [policyBranch]
Overview = Přehled
Total = Celkem

View File

@ -529,6 +529,15 @@ Denounce ([numberOfTurns] turns) =
# Requires translation!
We will remember this. =
# Requires translation!
[civName] has declared war on [targetCivName]! =
# Requires translation!
[civName] and [targetCivName] have signed the Peace Treaty! =
# Requires translation!
[civName] and [targetCivName] have signed the Declaration of Friendship! =
# Requires translation!
[civName] has denounced [targetCivName]! =
# Requires translation!
Unforgivable =
# Requires translation!
@ -1353,6 +1362,8 @@ Hurry Wonder =
# Requires translation!
Your citizens have been happy with your rule for so long that the empire enters a Golden Age! =
You have entered the [newEra]! = Jij bent in het/de [newEra] aangekomen!
# Requires translation!
[civName] has entered the [eraName]! =
[policyBranch] policy branch unlocked! = Het/De [policyBranch] beleid is ontgrendeld!
# Requires translation!
Overview =

View File

@ -550,6 +550,15 @@ Denounce ([numberOfTurns] turns) =
# Requires translation!
We will remember this. =
# Requires translation!
[civName] has declared war on [targetCivName]! =
# Requires translation!
[civName] and [targetCivName] have signed the Peace Treaty! =
# Requires translation!
[civName] and [targetCivName] have signed the Declaration of Friendship! =
# Requires translation!
[civName] has denounced [targetCivName]! =
# Requires translation!
Unforgivable =
# Requires translation!
@ -1508,6 +1517,8 @@ Your citizens have been happy with your rule for so long that the empire enters
# Requires translation!
You have entered the [newEra]! =
# Requires translation!
[civName] has entered the [eraName]! =
# Requires translation!
[policyBranch] policy branch unlocked! =
# Requires translation!
Overview =

View File

@ -314,6 +314,15 @@ Indeed! = Parfait!
Denounce ([numberOfTurns] turns) = Dénoncer ([numberOfTurns] tours)
We will remember this. = Nous nous en souviendrons.
# Requires translation!
[civName] has declared war on [targetCivName]! =
# Requires translation!
[civName] and [targetCivName] have signed the Peace Treaty! =
# Requires translation!
[civName] and [targetCivName] have signed the Declaration of Friendship! =
# Requires translation!
[civName] has denounced [targetCivName]! =
Unforgivable = Impardonnable
Enemy = Ennemi
Competitor = Adversaire
@ -827,6 +836,8 @@ Your trade mission to [civName] has earned you [goldAmount] gold and [influenceA
Hurry Wonder = Accélérer la construction
Your citizens have been happy with your rule for so long that the empire enters a Golden Age! = Vos citoyens sont satisfaits de votre gouvernance depuis si longtemps que votre empire débute un Age d'Or !
You have entered the [newEra]! = Vous êtes entré dans l'ère [newEra]!
# Requires translation!
[civName] has entered the [eraName]! =
[policyBranch] policy branch unlocked! = Doctrine [policyBranch] déverrouillée!
Overview = Vue d'ensemble
Total = Total

View File

@ -319,6 +319,15 @@ Indeed! = Auf jeden Fall!
Denounce ([numberOfTurns] turns) = Denunziere ([numberOfTurns] Runden)
We will remember this. = Das werden wir nie vergessen!
# Requires translation!
[civName] has declared war on [targetCivName]! =
# Requires translation!
[civName] and [targetCivName] have signed the Peace Treaty! =
# Requires translation!
[civName] and [targetCivName] have signed the Declaration of Friendship! =
# Requires translation!
[civName] has denounced [targetCivName]! =
Unforgivable = Todfeind
Enemy = Feind
Competitor = Konkurrent
@ -840,6 +849,8 @@ Your trade mission to [civName] has earned you [goldAmount] gold and [influenceA
Hurry Wonder = Wunder beschleunigen
Your citizens have been happy with your rule for so long that the empire enters a Golden Age! = Deine Bevölkerung ist so zufrieden mit deiner Herrschaft, dass dein Imperium in ein Goldenes Zeitalter eintritt!
You have entered the [newEra]! = Zeitalter [newEra] ist eingeläutet!
# Requires translation!
[civName] has entered the [eraName]! =
[policyBranch] policy branch unlocked! = Grundsatzzweig [policyBranch] wurde freigeschaltet
Overview = Überblick
Total = Gesamt

View File

@ -362,6 +362,15 @@ Indeed! = Benar!
Denounce ([numberOfTurns] turns) = Hina ([numberOfTurns] turns)
We will remember this. = Kami akan ingat ini.
# Requires translation!
[civName] has declared war on [targetCivName]! =
# Requires translation!
[civName] and [targetCivName] have signed the Peace Treaty! =
# Requires translation!
[civName] and [targetCivName] have signed the Declaration of Friendship! =
# Requires translation!
[civName] has denounced [targetCivName]! =
Unforgivable = Tak Termaafkan
Enemy = Musuh
Competitor = Saingan
@ -1205,6 +1214,8 @@ Your citizens have been happy with your rule for so long that the empire enters
# Requires translation!
You have entered the [newEra]! =
# Requires translation!
[civName] has entered the [eraName]! =
# Requires translation!
[policyBranch] policy branch unlocked! =
# Requires translation!
Overview =

View File

@ -314,6 +314,15 @@ Indeed! = Perfetto!
Denounce ([numberOfTurns] turns) = Denuncia ([numberOfTurns] turni)
We will remember this. = Non credere che ce lo scorderemo!
# Requires translation!
[civName] has declared war on [targetCivName]! =
# Requires translation!
[civName] and [targetCivName] have signed the Peace Treaty! =
# Requires translation!
[civName] and [targetCivName] have signed the Declaration of Friendship! =
# Requires translation!
[civName] has denounced [targetCivName]! =
Unforgivable = Imperdonabile!
Enemy = Nemici
Competitor = Avversari
@ -826,6 +835,8 @@ Your trade mission to [civName] has earned you [goldAmount] gold and [influenceA
Hurry Wonder = Accellera Meraviglia
Your citizens have been happy with your rule for so long that the empire enters a Golden Age! = I tuoi cittadini sono da tempo contenti del tuo governo! Il tuo impero è entrato in un'Età dell'Oro!
You have entered the [newEra]! = Benvenuto nell'Era [newEra]!
# Requires translation!
[civName] has entered the [eraName]! =
[policyBranch] policy branch unlocked! = Ramo sociale [policyBranch] sbloccato!
Overview = Panoramica
Total = Totale

View File

@ -329,6 +329,15 @@ Indeed! = 좋소!
Denounce ([numberOfTurns] turns) = 비난 ([numberOfTurns] 턴 동안)
We will remember this. = 우리는 이 일을 기억할 것입니다.
# Requires translation!
[civName] has declared war on [targetCivName]! =
# Requires translation!
[civName] and [targetCivName] have signed the Peace Treaty! =
# Requires translation!
[civName] and [targetCivName] have signed the Declaration of Friendship! =
# Requires translation!
[civName] has denounced [targetCivName]! =
Unforgivable = 용서 못함
Enemy = 적대적
Competitor = 경쟁자
@ -861,6 +870,8 @@ Your trade mission to [civName] has earned you [goldAmount] gold and [influenceA
Hurry Wonder = 불가사의 건축 가속
Your citizens have been happy with your rule for so long that the empire enters a Golden Age! = 시민들이 당신의 통치에 행복해하여 국가에 황금기가 시작됩니다!
You have entered the [newEra]! = [newEra]에 온 것을 환영합니다!
# Requires translation!
[civName] has entered the [eraName]! =
[policyBranch] policy branch unlocked! = [policyBranch] 정책을 채택할 수 있습니다!
Overview = 문명 상태
Total = 전체

View File

@ -482,6 +482,15 @@ Indeed! = Sesungguhnya
Denounce ([numberOfTurns] turns) = Kecam ([numberOfTurns] pusingan)
We will remember this. = Kami akan ingat perkara ini
# Requires translation!
[civName] has declared war on [targetCivName]! =
# Requires translation!
[civName] and [targetCivName] have signed the Peace Treaty! =
# Requires translation!
[civName] and [targetCivName] have signed the Declaration of Friendship! =
# Requires translation!
[civName] has denounced [targetCivName]! =
Unforgivable = Tidak dapat dimaafkan
Enemy = Musuh
Competitor = Persaingan
@ -1397,6 +1406,8 @@ Your citizens have been happy with your rule for so long that the empire enters
# Requires translation!
You have entered the [newEra]! =
# Requires translation!
[civName] has entered the [eraName]! =
# Requires translation!
[policyBranch] policy branch unlocked! =
# Requires translation!
Overview =

View File

@ -314,6 +314,15 @@ Indeed! = Wspaniale!
Denounce ([numberOfTurns] turns) = Potęp cywilizację na [numberOfTurns] tur
We will remember this. = Zapamiętamy to sobie!
# Requires translation!
[civName] has declared war on [targetCivName]! =
# Requires translation!
[civName] and [targetCivName] have signed the Peace Treaty! =
# Requires translation!
[civName] and [targetCivName] have signed the Declaration of Friendship! =
# Requires translation!
[civName] has denounced [targetCivName]! =
Unforgivable = Niewybaczlne
Enemy = Wróg
Competitor = Konkurenci
@ -826,6 +835,8 @@ Your trade mission to [civName] has earned you [goldAmount] gold and [influenceA
Hurry Wonder = Przyspiesz Budowanie Cudu
Your citizens have been happy with your rule for so long that the empire enters a Golden Age! = Twoi obywatele są zadowoleni pod twoim panowaniem tak długo że imperium wkracza w Złotą Era
You have entered the [newEra]! = Wkroczyłeś do [newEra]!
# Requires translation!
[civName] has entered the [eraName]! =
[policyBranch] policy branch unlocked! = Odblokowano gałąź ustroju społecznego [policyBranch]
Overview = Przegląd
Total = Łącznie

View File

@ -316,6 +316,15 @@ Indeed! = Perfeito!
Denounce ([numberOfTurns] turns) = Condenar ([numberOfTurns] turnos)
We will remember this. = Nós nos lembraremos disso.
# Requires translation!
[civName] has declared war on [targetCivName]! =
# Requires translation!
[civName] and [targetCivName] have signed the Peace Treaty! =
# Requires translation!
[civName] and [targetCivName] have signed the Declaration of Friendship! =
# Requires translation!
[civName] has denounced [targetCivName]! =
Unforgivable = Imperdoável
Enemy = Inimigos
Competitor = Adversários
@ -889,6 +898,8 @@ Hurry Wonder = Apressar a contrução Maravilha
# Requires translation!
Your citizens have been happy with your rule for so long that the empire enters a Golden Age! =
You have entered the [newEra]! = Voçê entrou na [newEra]!
# Requires translation!
[civName] has entered the [eraName]! =
[policyBranch] policy branch unlocked! = [policyBranch] foi desbloqueado(a)
Overview = Visão geral
Total = Total

View File

@ -432,6 +432,15 @@ Denounce ([numberOfTurns] turns) =
# Requires translation!
We will remember this. =
# Requires translation!
[civName] has declared war on [targetCivName]! =
# Requires translation!
[civName] and [targetCivName] have signed the Peace Treaty! =
# Requires translation!
[civName] and [targetCivName] have signed the Declaration of Friendship! =
# Requires translation!
[civName] has denounced [targetCivName]! =
# Requires translation!
Unforgivable =
# Requires translation!
@ -1204,6 +1213,8 @@ Hurry Wonder = Grăbește minune
# Requires translation!
Your citizens have been happy with your rule for so long that the empire enters a Golden Age! =
You have entered the [newEra]! = Ai intrat în epoca [newEra]!
# Requires translation!
[civName] has entered the [eraName]! =
[policyBranch] policy branch unlocked! = Ramura [policyBranch] deblocată!
Overview = Prezentare generală
Total = Total

View File

@ -315,6 +315,15 @@ Indeed! = Разумеется!
Denounce ([numberOfTurns] turns) = Осуждение на [numberOfTurns] ходов
We will remember this. = Мы это запомним
# Requires translation!
[civName] has declared war on [targetCivName]! =
# Requires translation!
[civName] and [targetCivName] have signed the Peace Treaty! =
# Requires translation!
[civName] and [targetCivName] have signed the Declaration of Friendship! =
# Requires translation!
[civName] has denounced [targetCivName]! =
Unforgivable = Непростительно враждебные
Enemy = Враждебные
Competitor = Соперничающие
@ -827,6 +836,8 @@ Your trade mission to [civName] has earned you [goldAmount] gold and [influenceA
Hurry Wonder = Ускорить постройку чуда
Your citizens have been happy with your rule for so long that the empire enters a Golden Age! = Граждане настолько счастливы при вашей власти, что ваша империя вступает в золотой век!
You have entered the [newEra]! = Вы вошли в эпоху [newEra]!
# Requires translation!
[civName] has entered the [eraName]! =
[policyBranch] policy branch unlocked! = Ветвь общественных институтов [policyBranch] разблокирована!
Overview = Обзор
Total = Всего

View File

@ -315,6 +315,15 @@ Indeed! = 这是无比正确的命运抉择!
Denounce ([numberOfTurns] turns) = 谴责([numberOfTurns]回合)
We will remember this. = 这种侮辱我们绝不会忘记。请好自为之!
# Requires translation!
[civName] has declared war on [targetCivName]! =
# Requires translation!
[civName] and [targetCivName] have signed the Peace Treaty! =
# Requires translation!
[civName] and [targetCivName] have signed the Declaration of Friendship! =
# Requires translation!
[civName] has denounced [targetCivName]! =
Unforgivable = 仇深似海
Enemy = 宿命之敌
Competitor = 瑜亮之争
@ -838,6 +847,8 @@ Your trade mission to [civName] has earned you [goldAmount] gold and [influenceA
Hurry Wonder = 加速奇观建造
Your citizens have been happy with your rule for so long that the empire enters a Golden Age! = 人民为您英明领导下取得的丰功伟绩欢欣鼓舞,您的帝国进入了黄金时代!
You have entered the [newEra]! = 您已进入了[newEra]
# Requires translation!
[civName] has entered the [eraName]! =
[policyBranch] policy branch unlocked! = [policyBranch]分支解锁!
Overview = 概览
Total = 总计

View File

@ -314,6 +314,15 @@ Indeed! = ¡Por supuesto!
Denounce ([numberOfTurns] turns) = Denunciar ([numberOfTurns] turnos)]
We will remember this. = Recordaremos esto.
# Requires translation!
[civName] has declared war on [targetCivName]! =
# Requires translation!
[civName] and [targetCivName] have signed the Peace Treaty! =
# Requires translation!
[civName] and [targetCivName] have signed the Declaration of Friendship! =
# Requires translation!
[civName] has denounced [targetCivName]! =
Unforgivable = Imperdonable
Enemy = Enemigo
Competitor = Competidor
@ -826,6 +835,8 @@ Your trade mission to [civName] has earned you [goldAmount] gold and [influenceA
Hurry Wonder = Acelerar Maravilla
Your citizens have been happy with your rule for so long that the empire enters a Golden Age! = ¡Tus ciudadanos han estado contentos con tu gobierno durante tanto tiempo que el imperio ha entrado en una Edad de Oro!
You have entered the [newEra]! = ¡Has entrado en la [newEra]!
# Requires translation!
[civName] has entered the [eraName]! =
[policyBranch] policy branch unlocked! = ¡Rama política [policyBranch] desbloqueada!
Overview = Visión general
Total = Total

View File

@ -315,6 +315,15 @@ Indeed! = 這是無比正確的選擇!
Denounce ([numberOfTurns] turns) = 譴責([numberOfTurns]回合)
We will remember this. = 這種侮辱我們絕不會忘記。請好自為之!
# Requires translation!
[civName] has declared war on [targetCivName]! =
# Requires translation!
[civName] and [targetCivName] have signed the Peace Treaty! =
# Requires translation!
[civName] and [targetCivName] have signed the Declaration of Friendship! =
# Requires translation!
[civName] has denounced [targetCivName]! =
Unforgivable = 仇深似海
Enemy = 宿命之敵
Competitor = 瑜亮之爭
@ -838,6 +847,8 @@ Your trade mission to [civName] has earned you [goldAmount] gold and [influenceA
Hurry Wonder = 加速奇觀建造
Your citizens have been happy with your rule for so long that the empire enters a Golden Age! = 人民為您英明領導下取得的豐功偉業歡欣鼓舞,您的帝國進入了黃金時代!
You have entered the [newEra]! = 您已進入了[newEra]
# Requires translation!
[civName] has entered the [eraName]! =
[policyBranch] policy branch unlocked! = [policyBranch]分支解鎖!
Overview = 概覽
Total = 總計

View File

@ -314,6 +314,15 @@ Indeed! = Справді!
Denounce ([numberOfTurns] turns) = Звинувачення (Ходів: [numberOfTurns])
We will remember this. = Ми пам’ятатимемо це.
# Requires translation!
[civName] has declared war on [targetCivName]! =
# Requires translation!
[civName] and [targetCivName] have signed the Peace Treaty! =
# Requires translation!
[civName] and [targetCivName] have signed the Declaration of Friendship! =
# Requires translation!
[civName] has denounced [targetCivName]! =
Unforgivable = непрощальні
Enemy = ворожі
Competitor = конкурентні
@ -826,6 +835,8 @@ Your trade mission to [civName] has earned you [goldAmount] gold and [influenceA
Hurry Wonder = Завершити будування дива
Your citizens have been happy with your rule for so long that the empire enters a Golden Age! = Ваші громадяни були задоволені вашим правлінням так довго, що імперія вступає в Золотий вік!
You have entered the [newEra]! = Ви увійшли до епохи [newEra]!
# Requires translation!
[civName] has entered the [eraName]! =
[policyBranch] policy branch unlocked! = Галузь політики [policyBranch] розблоковано
Overview = Огляд
Total = Усього

View File

@ -1,17 +1,17 @@
Traditional_Chinese = 97
Italian = 100
Russian = 99
Traditional_Chinese = 96
Italian = 99
Polish = 99
Russian = 99
Romanian = 48
Korean = 94
Simplified_Chinese = 97
Simplified_Chinese = 96
German = 96
English = 0
Ukrainian = 99
Ukrainian = 98
French = 99
Portuguese = 83
Indonesian = 21
Spanish = 99
Czech = 96
Malay = 13
Czech = 97
Spanish = 99
Dutch = 21

View File

@ -314,6 +314,11 @@ Indeed! =
Denounce ([numberOfTurns] turns) =
We will remember this. =
[civName] has declared war on [targetCivName]! =
[civName] and [targetCivName] have signed the Peace Treaty! =
[civName] and [targetCivName] have signed the Declaration of Friendship! =
[civName] has denounced [targetCivName]! =
Unforgivable =
Enemy =
Competitor =
@ -826,6 +831,7 @@ Your trade mission to [civName] has earned you [goldAmount] gold and [influenceA
Hurry Wonder =
Your citizens have been happy with your rule for so long that the empire enters a Golden Age! =
You have entered the [newEra]! =
[civName] has entered the [eraName]! =
[policyBranch] policy branch unlocked! =
Overview =
Total =

View File

@ -158,6 +158,7 @@ project(":core") {
testImplementation 'junit:junit:4.12'
testImplementation "org.mockito:mockito-all:1.9.5"
testImplementation "io.mockk:mockk:1.9.3"
testImplementation "com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion"
testImplementation "com.badlogicgames.gdx:gdx:$gdxVersion"

View File

@ -206,6 +206,9 @@ class TechManager {
val currentEra = civInfo.getEra()
if (previousEra < currentEra) {
civInfo.addNotification("You have entered the [$currentEra era]!", null, Color.GOLD)
civInfo.getKnownCivs().forEach {
it.addNotification("[${civInfo.civName}] has entered the [$currentEra era]!", null, Color.BLUE)
}
getRuleset().policyBranches.values.filter { it.era == currentEra }
.forEach { civInfo.addNotification("[" + it.name + "] policy branch unlocked!", null, Color.PURPLE) }
}

View File

@ -198,6 +198,10 @@ class DiplomacyManager() {
}
return counter
}
/** Returns the [civilizations][CivilizationInfo] that know about both sides ([civInfo] and [otherCiv]) */
fun getCommonKnownCivs(): Set<CivilizationInfo> = civInfo.getKnownCivs().intersect(otherCiv().getKnownCivs())
//endregion
//region state-changing functions
@ -361,6 +365,10 @@ class DiplomacyManager() {
otherCiv.addNotification("[${civInfo.civName}] has declared war on us!",null, Color.RED)
otherCiv.popupAlerts.add(PopupAlert(AlertType.WarDeclaration,civInfo.civName))
getCommonKnownCivs().forEach {
it.addNotification("[${civInfo.civName}] has declared war on [${otherCiv().civName}]!", null, Color.RED)
}
otherCivDiplomacy.setModifier(DiplomaticModifiers.DeclaredWarOnUs,-20f)
if(otherCiv.isCityState()) otherCivDiplomacy.influence -= 60
@ -406,6 +414,17 @@ class DiplomacyManager() {
fun makePeace(){
diplomaticStatus= DiplomaticStatus.Peace
if (otherCiv().isAtWarWith(civInfo)) {
for (civ in getCommonKnownCivs()) {
civ.addNotification(
"[${civInfo.civName}] and [${otherCiv().civName}] have signed the Peace Treaty!",
null,
Color.WHITE
)
}
}
val otherCiv = otherCiv()
// We get out of their territory
for(unit in civInfo.getCivUnits().filter { it.getTile().getOwner()== otherCiv})
@ -453,8 +472,8 @@ class DiplomacyManager() {
setFlag(DiplomacyFlags.DeclarationOfFriendship,30)
otherCivDiplomacy().setFlag(DiplomacyFlags.DeclarationOfFriendship,30)
for(thirdCiv in civInfo.getKnownCivs().filter { it.isMajorCiv() }){
if(thirdCiv==otherCiv() || !thirdCiv.knows(otherCivName)) continue
for (thirdCiv in getCommonKnownCivs().filter { it.isMajorCiv() }) {
thirdCiv.addNotification("[${civInfo.civName}] and [${otherCiv().civName}] have signed the Declaration of Friendship!", null, Color.WHITE)
val thirdCivRelationshipWithOtherCiv = thirdCiv.getDiplomacyManager(otherCiv()).relationshipLevel()
when(thirdCivRelationshipWithOtherCiv){
RelationshipLevel.Unforgivable -> addModifier(DiplomaticModifiers.DeclaredFriendshipWithOurEnemies,-15f)
@ -464,7 +483,7 @@ class DiplomacyManager() {
}
}
}
fun denounce(){
setModifier(DiplomaticModifiers.Denunciation,-35f)
otherCivDiplomacy().setModifier(DiplomaticModifiers.Denunciation,-35f)
@ -474,8 +493,8 @@ class DiplomacyManager() {
otherCiv().addNotification("[${civInfo.civName}] has denounced us!", Color.RED)
// We, A, are denouncing B. What do other major civs (C,D, etc) think of this?
for(thirdCiv in civInfo.getKnownCivs().filter { it.isMajorCiv() }){
if(thirdCiv==otherCiv() || !thirdCiv.knows(otherCivName)) continue
getCommonKnownCivs().filter { it.isMajorCiv() }.forEach { thirdCiv ->
thirdCiv.addNotification("[${civInfo.civName}] has denounced [${otherCiv().civName}]!", null, Color.RED)
val thirdCivRelationshipWithOtherCiv = thirdCiv.getDiplomacyManager(otherCiv()).relationshipLevel()
when(thirdCivRelationshipWithOtherCiv){
RelationshipLevel.Unforgivable -> addModifier(DiplomaticModifiers.DenouncedOurEnemies,15f)

View File

@ -0,0 +1,103 @@
package com.unciv.logic.civilization.diplomacy
import com.unciv.logic.GameInfo
import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.testing.GdxTestRunner
import io.mockk.every
import io.mockk.mockk
import io.mockk.slot
import org.junit.After
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(GdxTestRunner::class)
class DiplomacyManagerTests {
private val mockGameInfo = mockk<GameInfo>()
private val slot = slot<String>()
private val testCivilizationNames = arrayListOf("Russia", "America", "Germany", "Greece", "Babylon")
private val civilizations = testCivilizationNames.associateWith { CivilizationInfo(it) }
private fun meetByName(civilization: String, civilizationToMeet: String) {
civilizations.getValue(civilization)
.meetCivilization(civilizations.getValue(civilizationToMeet))
}
@Before
fun setup() {
// Setup the GameInfo mock
every { mockGameInfo.getCivilization(capture(slot)) } answers { civilizations.getValue(slot.captured) }
// Just return the default CivilizationInfo, since the .meetCivilization() includes the tutorial logic and crashes otherwise
every { mockGameInfo.getCurrentPlayerCivilization() } returns CivilizationInfo()
for (civ in civilizations.values) {
civ.gameInfo = mockGameInfo
}
}
@After
fun tearDown() {
// Clear the diplomacy
for (civ in civilizations.values) {
civ.diplomacy.clear()
}
}
@Test
fun `getCommonKnownCivs does not include either DiplomacyManagers's civs`() {
val russia = civilizations.getValue("Russia")
val america = civilizations.getValue("America")
meetByName("Russia", "America")
val commonKnownCivs = russia.getDiplomacyManager(america).getCommonKnownCivs()
Assert.assertTrue(russia !in commonKnownCivs)
Assert.assertTrue(america !in commonKnownCivs)
}
@Test
fun `getCommonKnownCivs includes civs met by both civs`() {
val russia = civilizations.getValue("Russia")
val america = civilizations.getValue("America")
meetByName("Russia", "America")
meetByName("Russia", "Germany")
meetByName("America", "Germany")
val commonKnownCivs = russia.getDiplomacyManager(america).getCommonKnownCivs()
Assert.assertTrue(civilizations.getValue("Germany") in commonKnownCivs)
}
@Test
fun `getCommonKnownCivs does not include civs met by only one civ`() {
val russia = civilizations.getValue("Russia")
val america = civilizations.getValue("America")
meetByName("Russia", "America")
meetByName("Russia", "Germany")
val commonKnownCivs = russia.getDiplomacyManager(america).getCommonKnownCivs()
Assert.assertTrue(civilizations.getValue("Germany") !in commonKnownCivs)
}
@Test
fun `getCommonKnownCivs is equal for mirrored DiplomacyManagers`() {
val russia = civilizations.getValue("Russia")
val america = civilizations.getValue("America")
meetByName("Russia", "America")
meetByName("Russia", "Germany")
meetByName("America", "Germany")
meetByName("Russia", "Greece")
meetByName("America", "Greece")
Assert.assertEquals(
america.getDiplomacyManager(russia).getCommonKnownCivs(),
russia.getDiplomacyManager(america).getCommonKnownCivs()
)
}
}