From 796284c7e2ff2033c210ff78ceee7159afbdc697 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sun, 10 Feb 2019 19:50:42 +0200 Subject: [PATCH] Added unique civ text for attacking, being attacked, and being defeated --- android/assets/jsons/Nations.json | 30 +++++++++++++++++++ android/assets/jsons/Translations.json | 9 ++++++ .../logic/automation/NextTurnAutomation.kt | 1 + core/src/com/unciv/logic/battle/Battle.kt | 3 ++ .../diplomacy/DiplomaticIncidentType.kt | 2 +- .../src/com/unciv/models/gamebasics/Nation.kt | 5 ++++ core/src/com/unciv/ui/EmpireOverviewScreen.kt | 6 +++- .../src/com/unciv/ui/trade/DiplomacyScreen.kt | 17 +++++++++-- .../com/unciv/ui/worldscreen/WorldScreen.kt | 27 +++++++++-------- .../ui/worldscreen/optionstable/PopupTable.kt | 7 +++++ 10 files changed, 90 insertions(+), 17 deletions(-) diff --git a/android/assets/jsons/Nations.json b/android/assets/jsons/Nations.json index f8c099f47e..deb533e1f0 100644 --- a/android/assets/jsons/Nations.json +++ b/android/assets/jsons/Nations.json @@ -2,6 +2,9 @@ { name:"Babylon", leaderName:"Nebuchadnezzar II", + declaringWar:"The demon wants the blood of soldiers!" + attacked:"Oh well, I presume you know what you're doing." + defeated:"It is over. Perhaps now I shall have peace, at last." mainColor:[27,53,63], secondaryColor:[213,249,255], unique:"Receive free Great Scientist when you discover Writing, Earn Great Scientists 50% faster", @@ -11,6 +14,9 @@ }, { name:"Greece", + declaringWar:"You are in my way, you must be destroyed." + attacked:"As a matter of fact I too grow weary of peace." + defeated:"You have somehow become my undoing! What kind of beast are you?" leaderName:"Alexander", mainColor:[181, 232, 232], secondaryColor:[68,142,249], @@ -21,6 +27,9 @@ { name:"China", leaderName:"Wu Zetian", + declaringWar:"You won't ever be able to bother me again. Go meet Yama." + attacked:"Fool! I will disembowel you all!" + defeated:"You have proven to be a cunning and competent adversary. I congratulate you on your victory." mainColor:[9, 112, 84], secondaryColor:[255,255,255], unique:"Great general provides double combat bonus, and spawns 50% faster" @@ -31,6 +40,9 @@ { name:"Egypt", leaderName:"Ramesses II", + declaringWar:"You are but a pest on this Earth, prepare to be eliminated!", + attacked:"You are a fool who evokes pity. You have brought my hostility upon yourself and your repulsive civilization!" + defeated:"Strike me down and my soul will torment yours forever – you have won nothing." mainColor:[ 231, 213, 0], secondaryColor:[98,10,210], unique:"+20% production towards Wonder construction" @@ -41,6 +53,9 @@ { name:"England", leaderName:"Elizabeth", + declaringWar:"By the grace of God, your days are numbered." + attacked:"We shall never surrender." + defeated:"You have triumphed over us. The day is yours." mainColor:[ 114, 0, 0], secondaryColor:[255,255,255], unique:"+2 movement for all naval units" @@ -51,6 +66,9 @@ { name:"France", leaderName:"Napoleon", + declaringWar:"You're disturbing us, prepare for war.", + attacked:"You've fallen into my trap. I'll bury you.", + defeated:"I congratulate you for your victory." mainColor:[ 38, 98, 255], secondaryColor:[239,236,148], unique:"+2 Culture per turn from cities before discovering Steam Power", @@ -61,6 +79,9 @@ { name:"Russia", leaderName:"Catherine", + declaringWar:"You've behaved yourself very badly, you know it. Now it's payback time.", + attacked:"You've mistaken my passion for a weakness, you'll regret about this." + defeated:"We were defeated, so this makes me your prisoner. I suppose there are worse fates." mainColor:[ 236, 178, 0], secondaryColor:[0,0,0], unique:"Strategic Resources provide +1 Production, and Horses, Iron and Uranium Resources provide double quantity", @@ -71,6 +92,9 @@ { name:"Rome", leaderName:"Augustus Caesar", + declaringWar:"My treasury contains little and my soldiers are getting impatient... ...therefore you must die." + attacked:"So brave, yet so stupid! If only you had a brain similar to your courage." + defeated:"The gods have deprived Rome of their favour. We have been defeated." mainColor:[ 53,0,87], secondaryColor:[238,201,9], unique:"+25% Production towards any buildings that already exist in the Capital", @@ -81,6 +105,9 @@ { name:"Arabia", leaderName:"Harun al-Rashid", + declaringWar:"The world will be more beautiful without you. Prepare for war." + attacked:"Fool! You will soon regret dearly! I swear it!" + defeated:"You have won, congratulations. My palace is now in your possession, and I beg that you care well for the peacock." mainColor:[ 41,83,42], secondaryColor:[146,221,9], cities:["Mecca","Medina","Damascus","Baghdad","Najran","Kufah","Basra","Khurasan","Anjar","Fustat", @@ -90,6 +117,9 @@ { name:"America", leaderName:"Washington", + declaringWar:"Your wanton aggression leaves us no choice. Prepare for war!" + attacked:"You have mistaken our love of peace for weakness. You shall regret this!" + defeated:"The day...is yours. I hope you will be merciful in your triumph." mainColor:[ 28,51,119], secondaryColor:[255,255,255], unique:"All land military units have +1 sight, 50% discount when purchasing tiles", diff --git a/android/assets/jsons/Translations.json b/android/assets/jsons/Translations.json index acfb210ace..c7b8c679cb 100644 --- a/android/assets/jsons/Translations.json +++ b/android/assets/jsons/Translations.json @@ -4019,6 +4019,8 @@ German:"Schwierigkeitsgrad" } + // Diplomacy! + "Diplomacy":{ Italian:"Diplomazia" Russian:"Дипломатия" @@ -4074,6 +4076,10 @@ German:"[civName] hat uns den Krieg erklärt!" } + "You'll pay for this!":{} + "Very well.":{} + "Farewell.":{} + // Overview screen "Overview":{ Italian:"Panoramica" @@ -4275,6 +4281,8 @@ German:"Nächstgelegene Stadt" } + "Defeated":{} + // Buildings! "Palace":{ @@ -7363,4 +7371,5 @@ French:"Détruiser [civName]" } + } diff --git a/core/src/com/unciv/logic/automation/NextTurnAutomation.kt b/core/src/com/unciv/logic/automation/NextTurnAutomation.kt index 4525f9cfdb..b4ab93ad0d 100644 --- a/core/src/com/unciv/logic/automation/NextTurnAutomation.kt +++ b/core/src/com/unciv/logic/automation/NextTurnAutomation.kt @@ -25,6 +25,7 @@ class NextTurnAutomation{ automateUnits(civInfo) reassignWorkedTiles(civInfo) trainSettler(civInfo) + civInfo.diplomaticIncidents.clear() } private fun buyBuildingOrUnit(civInfo: CivilizationInfo) { diff --git a/core/src/com/unciv/logic/battle/Battle.kt b/core/src/com/unciv/logic/battle/Battle.kt index 4ef7ba7c8c..95503d84f1 100644 --- a/core/src/com/unciv/logic/battle/Battle.kt +++ b/core/src/com/unciv/logic/battle/Battle.kt @@ -3,6 +3,8 @@ package com.unciv.logic.battle import com.badlogic.gdx.graphics.Color import com.unciv.logic.GameInfo import com.unciv.logic.city.CityInfo +import com.unciv.logic.civilization.diplomacy.DiplomaticIncident +import com.unciv.logic.civilization.diplomacy.DiplomaticIncidentType import com.unciv.logic.map.TileInfo import com.unciv.models.gamebasics.unit.UnitType import java.util.* @@ -163,6 +165,7 @@ class Battle(val gameInfo:GameInfo) { for(civ in gameInfo.civilizations) civ.addNotification("The civilization of [${enemyCiv.civName}] has been destroyed!", null, Color.RED) enemyCiv.getCivUnits().forEach { it.destroy() } + attacker.getCivInfo().diplomaticIncidents.add(DiplomaticIncident(enemyCiv.civName,DiplomaticIncidentType.Defeated)) } else if(enemyCiv.cities.isNotEmpty()){ enemyCiv.cities.first().cityConstructions.addBuilding("Palace") // relocate palace diff --git a/core/src/com/unciv/logic/civilization/diplomacy/DiplomaticIncidentType.kt b/core/src/com/unciv/logic/civilization/diplomacy/DiplomaticIncidentType.kt index 39ab9654e0..667dec67f7 100644 --- a/core/src/com/unciv/logic/civilization/diplomacy/DiplomaticIncidentType.kt +++ b/core/src/com/unciv/logic/civilization/diplomacy/DiplomaticIncidentType.kt @@ -2,5 +2,5 @@ package com.unciv.logic.civilization.diplomacy enum class DiplomaticIncidentType{ WarDeclaration, - TradeOffer + Defeated } \ No newline at end of file diff --git a/core/src/com/unciv/models/gamebasics/Nation.kt b/core/src/com/unciv/models/gamebasics/Nation.kt index 1839a893ef..898ab32ad3 100644 --- a/core/src/com/unciv/models/gamebasics/Nation.kt +++ b/core/src/com/unciv/models/gamebasics/Nation.kt @@ -7,6 +7,11 @@ import com.unciv.ui.utils.colorFromRGB class Nation : INamed { override lateinit var name: String lateinit var leaderName: String + + lateinit var declaringWar:String + lateinit var attacked:String + lateinit var defeated:String + lateinit var mainColor: List var unique:String?=null var secondaryColor: List?=null diff --git a/core/src/com/unciv/ui/EmpireOverviewScreen.kt b/core/src/com/unciv/ui/EmpireOverviewScreen.kt index ed9c8070c4..c7ec4613c8 100644 --- a/core/src/com/unciv/ui/EmpireOverviewScreen.kt +++ b/core/src/com/unciv/ui/EmpireOverviewScreen.kt @@ -296,10 +296,14 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){ val civGroup = Table() val civGroupBackground = ImageGetter.getDrawable("OtherIcons/civTableBackground.png") - val label = Label(civ.civName.tr(), CameraStageBaseScreen.skin) + var civNameText = civ.civName.tr() + if(civ.isDefeated()) civNameText += "\n({Defeated})".tr() + val label = Label(civNameText, CameraStageBaseScreen.skin) + label.setAlignment(Align.center) if (civ.isDefeated()) { civGroup.background = civGroupBackground.tint(Color.LIGHT_GRAY) + label.setFontColor(Color.BLACK) } else if (playerKnows(civ)) { civGroup.background = civGroupBackground.tint(civ.getNation().getColor()) label.setFontColor(civ.getNation().getSecondaryColor()) diff --git a/core/src/com/unciv/ui/trade/DiplomacyScreen.kt b/core/src/com/unciv/ui/trade/DiplomacyScreen.kt index d6ac2897a7..586ccf0c86 100644 --- a/core/src/com/unciv/ui/trade/DiplomacyScreen.kt +++ b/core/src/com/unciv/ui/trade/DiplomacyScreen.kt @@ -5,6 +5,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.* import com.unciv.UnCivGame import com.unciv.models.gamebasics.tr import com.unciv.ui.utils.* +import com.unciv.ui.worldscreen.optionstable.PopupTable import com.unciv.ui.worldscreen.optionstable.YesNoPopupTable class DiplomacyScreen:CameraStageBaseScreen(){ @@ -62,9 +63,19 @@ class DiplomacyScreen:CameraStageBaseScreen(){ declareWarButton.setText(declareWarButton.text.toString() + " ($turnsToPeaceTreaty)") } declareWarButton.onClick { - YesNoPopupTable("Declare war on [${civ.civName}]?".tr(),{ - civDiplomacy.declareWar() - updateLeftSideTable()}, this@DiplomacyScreen) + YesNoPopupTable("Declare war on [${civ.civName}]?".tr(), { + civDiplomacy.declareWar() + + val responsePopup = PopupTable(this) + val otherCivLeaderName = civ.getNation().leaderName + " of " + civ.civName + responsePopup.add(Label(otherCivLeaderName, skin)) + responsePopup.addSeparator() + responsePopup.addGoodSizedLabel(civ.getNation().attacked).row() + responsePopup.addButton("Very well.".tr()) { responsePopup.remove() } + responsePopup.open() + + updateLeftSideTable() + }, this) } civTable.add(declareWarButton).row() } diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index 3db5387fae..44a68298a6 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -311,27 +311,30 @@ class WorldScreen : CameraStageBaseScreen() { } class DiplomaticIncidentPopup(val worldScreen: WorldScreen, val diplomaticIncident: DiplomaticIncident):PopupTable(worldScreen){ - init{ + fun getCloseButton(text:String): TextButton { + val button = TextButton(text.tr(), skin) + button.onClick { close() } + return button + } + + init { val otherCiv = worldScreen.gameInfo.getCivilization(diplomaticIncident.civName) val otherCivLeaderName = otherCiv.getNation().leaderName+" of "+otherCiv.civName add(Label(otherCivLeaderName,skin)) addSeparator() + when(diplomaticIncident.type){ DiplomaticIncidentType.WarDeclaration -> { - add(Label("We've decided to declare war on you, k?",skin)).row() + addGoodSizedLabel(otherCiv.getNation().declaringWar).row() val responseTable = Table() - - val angryResponse = TextButton("You'll pay for this",skin) - angryResponse.onClick { close() } - - val acceptingResponse= TextButton("This is fine",skin) - acceptingResponse.onClick { close() } - - responseTable.add(angryResponse) - responseTable.add(acceptingResponse) + responseTable.add(getCloseButton("You'll pay for this!")) + responseTable.add(getCloseButton("Very well.")) add(responseTable) } - DiplomaticIncidentType.TradeOffer -> TODO() + DiplomaticIncidentType.Defeated -> { + addGoodSizedLabel(otherCiv.getNation().defeated).row() + add(getCloseButton("Farewell.")) + } } open() isOpen = true diff --git a/core/src/com/unciv/ui/worldscreen/optionstable/PopupTable.kt b/core/src/com/unciv/ui/worldscreen/optionstable/PopupTable.kt index 2c4a575f8c..76dd35bbf5 100644 --- a/core/src/com/unciv/ui/worldscreen/optionstable/PopupTable.kt +++ b/core/src/com/unciv/ui/worldscreen/optionstable/PopupTable.kt @@ -1,6 +1,7 @@ package com.unciv.ui.worldscreen.optionstable import com.badlogic.gdx.graphics.Color +import com.badlogic.gdx.scenes.scene2d.ui.Cell import com.badlogic.gdx.scenes.scene2d.ui.Label import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.ui.TextButton @@ -26,6 +27,12 @@ open class PopupTable(val screen: CameraStageBaseScreen): Table(CameraStageBaseS screen.stage.addActor(this) } + fun addGoodSizedLabel(text: String): Cell