From 36da3359dbda6e421dfbd94863228a19a5f22a15 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sat, 1 Jun 2019 23:20:02 +0300 Subject: [PATCH] Added denunceation --- android/assets/jsons/Translations/Other.json | 20 ++++++++++-- .../diplomacy/DiplomacyManager.kt | 32 ++++++++++++++++--- .../src/com/unciv/ui/trade/DiplomacyScreen.kt | 12 +++++++ 3 files changed, 58 insertions(+), 6 deletions(-) diff --git a/android/assets/jsons/Translations/Other.json b/android/assets/jsons/Translations/Other.json index a5fc61cc1c..dbe85acc32 100644 --- a/android/assets/jsons/Translations/Other.json +++ b/android/assets/jsons/Translations/Other.json @@ -2589,6 +2589,14 @@ Portuguese:"Perfeito!" } + // Denunceation flavour texts + "Denounce ([numberOfTurns] turns)":{ + } + + "We will remember this.":{ + } + + // Relationship states, from worst (Unforgivable) to best (Ally) "Unforgivable":{ @@ -2729,11 +2737,19 @@ } - "Your so-called 'friendship' is worth nothing.":{ // When we have a decleration of friendship to someone and we declare war on them - Italian:"La tua cosiddetta 'amicizia' non vale nulla!" + Italian:"La tua cosiddetta 'amicizia' non vale nulla!" Portuguese:"Sua chamada 'amizade' não vale nada." } + + "You have publically denounced us!":{ + } + + "You have denounced our allies":{ + } + + "You have denounced our enemies":{ + } ////// Overview screen diff --git a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt index 2e66701461..ffd7710e6e 100644 --- a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt +++ b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt @@ -27,6 +27,7 @@ enum class DiplomacyFlags{ DeclinedPeace, DeclaredWar, DeclarationOfFriendship, + Denunceation, BorderConflict } @@ -36,11 +37,14 @@ enum class DiplomaticModifiers{ CapturedOurCities, DeclaredFriendshipWithOurEnemies, BetrayedDeclarationOfFriendship, + Denunciation, + DenouncedOurAllies, YearsOfPeace, SharedEnemy, DeclarationOfFriendship, DeclaredFriendshipWithOurAllies, + DenouncedOurEnemies, OpenBorders } @@ -219,8 +223,10 @@ class DiplomacyManager() { removeUntenebleTrades() updateHasOpenBorders() - if(diplomaticStatus==DiplomaticStatus.Peace) - addModifier(DiplomaticModifiers.YearsOfPeace,0.5f) + if(diplomaticStatus==DiplomaticStatus.Peace) { + if(diplomaticModifiers[DiplomaticModifiers.YearsOfPeace.name]!! < 30) + addModifier(DiplomaticModifiers.YearsOfPeace, 0.5f) + } else revertToZero(DiplomaticModifiers.YearsOfPeace,-0.5f) // war makes you forget the good ol' days var openBorders = 0 @@ -351,12 +357,30 @@ class DiplomacyManager() { if(thirdCiv==otherCiv() || !thirdCiv.knows(otherCivName)) continue val thirdCivRelationshipWithOtherCiv = thirdCiv.getDiplomacyManager(otherCiv()).relationshipLevel() when(thirdCivRelationshipWithOtherCiv){ - RelationshipLevel.Unforgivable -> addModifier(DiplomaticModifiers.DeclaredFriendshipWithOurEnemies,15f) - RelationshipLevel.Enemy -> addModifier(DiplomaticModifiers.DeclaredFriendshipWithOurEnemies,5f) + RelationshipLevel.Unforgivable -> addModifier(DiplomaticModifiers.DeclaredFriendshipWithOurEnemies,-15f) + RelationshipLevel.Enemy -> addModifier(DiplomaticModifiers.DeclaredFriendshipWithOurEnemies,-5f) RelationshipLevel.Friend -> addModifier(DiplomaticModifiers.DeclaredFriendshipWithOurAllies,5f) RelationshipLevel.Ally -> addModifier(DiplomaticModifiers.DeclaredFriendshipWithOurAllies,15f) } } } + + fun denounce(){ + setModifier(DiplomaticModifiers.Denunciation,-35f) + otherCivDiplomacy().setModifier(DiplomaticModifiers.Denunciation,-35f) + setFlag(DiplomacyFlags.Denunceation,30) + otherCivDiplomacy().setFlag(DiplomacyFlags.Denunceation,30) + + for(thirdCiv in civInfo.getKnownCivs().filter { it.isMajorCiv() }){ + if(thirdCiv==otherCiv() || !thirdCiv.knows(otherCivName)) continue + val thirdCivRelationshipWithOtherCiv = thirdCiv.getDiplomacyManager(otherCiv()).relationshipLevel() + when(thirdCivRelationshipWithOtherCiv){ + RelationshipLevel.Unforgivable -> addModifier(DiplomaticModifiers.DenouncedOurEnemies,15f) + RelationshipLevel.Enemy -> addModifier(DiplomaticModifiers.DenouncedOurEnemies,5f) + RelationshipLevel.Friend -> addModifier(DiplomaticModifiers.DenouncedOurAllies,-5f) + RelationshipLevel.Ally -> addModifier(DiplomaticModifiers.DenouncedOurAllies,-15f) + } + } + } //endregion } diff --git a/core/src/com/unciv/ui/trade/DiplomacyScreen.kt b/core/src/com/unciv/ui/trade/DiplomacyScreen.kt index 19bd5838f7..2dadfea8e6 100644 --- a/core/src/com/unciv/ui/trade/DiplomacyScreen.kt +++ b/core/src/com/unciv/ui/trade/DiplomacyScreen.kt @@ -209,6 +209,15 @@ class DiplomacyScreen:CameraStageBaseScreen() { diplomacyTable.add(declareFriendshipButton).row() } + if(!diplomacyManager.hasFlag(DiplomacyFlags.Denunceation)){ + val denounceButton = TextButton("Denounce ([30] turns)".tr(),skin) + denounceButton.onClick { + diplomacyManager.denounce() + setRightSideFlavorText(otherCiv,"We will remember this.".tr(),"Very well.".tr()) + } + diplomacyTable.add(denounceButton).row() + } + val declareWarButton = getDeclareWarButton(diplomacyManager, otherCiv) diplomacyTable.add(declareWarButton).row() } @@ -229,6 +238,9 @@ class DiplomacyScreen:CameraStageBaseScreen() { DeclaredFriendshipWithOurAllies -> "You have declared friendship with our allies" OpenBorders -> "Our open borders have brought us closer together." BetrayedDeclarationOfFriendship -> "Your so-called 'friendship' is worth nothing." + Denunciation -> "You have publically denounced us!" + DenouncedOurAllies -> "You have denounced our allies" + DenouncedOurEnemies -> "You have denounced our enemies" } text = text.tr() + " " if (modifier.value > 0) text += "+"