diff --git a/android/assets/jsons/Translations/Diplomacy,Trade,Nations.json b/android/assets/jsons/Translations/Diplomacy,Trade,Nations.json index 795de3b930..8a948398b3 100644 --- a/android/assets/jsons/Translations/Diplomacy,Trade,Nations.json +++ b/android/assets/jsons/Translations/Diplomacy,Trade,Nations.json @@ -126,7 +126,7 @@ Portuguese:"Dessa vez não." } - "Excellent!":{ // AI statement after we accept a trade they proposed, and when we meet a city state + "Excellent!":{ // AI statement after we accept a trade they proposed, and when we meet a city state, and our response when they agree to our diplomatic demand Italian:"Eccellente!" Simplified_Chinese:"好极了!和和气气才是生财之道。" French:"Excellent!" @@ -358,8 +358,18 @@ French:"Vous avez dénoncé nos ennemies" } + // Demands + "Demands":{} + "Please don't settle new cities near us.":{} + "Very well, we shall look for new lands to settle.":{} + "We shall do as we please.":{} + "You betrayed your promise to not settle cities near us":{} + "You refused to stop settling cities near us":{} + + "We noticed your new city near our borders, despite your promise. This will have....implications.":{} + ////// Trade diff --git a/core/src/com/unciv/logic/GameInfo.kt b/core/src/com/unciv/logic/GameInfo.kt index 8883047708..8ffde44aff 100644 --- a/core/src/com/unciv/logic/GameInfo.kt +++ b/core/src/com/unciv/logic/GameInfo.kt @@ -147,7 +147,8 @@ class GameInfo { for (civ in civilizations.filter { !it.isBarbarianCivilization() && !it.isDefeated() }) { allResearchedTechs.retainAll(civ.tech.techsResearched) } - val unitList = GameBasics.Units.values.filter { !it.unitType.isCivilian() && it.uniqueTo == null } + val unitList = GameBasics.Units.values + .filter { !it.unitType.isCivilian() && it.uniqueTo == null } .filter{ allResearchedTechs.contains(it.requiredTech) && (it.obsoleteTech == null || !allResearchedTechs.contains(it.obsoleteTech!!)) } diff --git a/core/src/com/unciv/logic/automation/NextTurnAutomation.kt b/core/src/com/unciv/logic/automation/NextTurnAutomation.kt index 1054d712cc..f7a32d6b3c 100644 --- a/core/src/com/unciv/logic/automation/NextTurnAutomation.kt +++ b/core/src/com/unciv/logic/automation/NextTurnAutomation.kt @@ -1,7 +1,6 @@ package com.unciv.logic.automation import com.unciv.Constants -import com.unciv.logic.city.CityInfo import com.unciv.logic.civilization.* import com.unciv.logic.civilization.diplomacy.DiplomacyFlags import com.unciv.logic.civilization.diplomacy.DiplomaticModifiers @@ -22,6 +21,7 @@ class NextTurnAutomation{ offerPeaceTreaty(civInfo) exchangeTechs(civInfo) exchangeLuxuries(civInfo) + issueRequests(civInfo) } chooseTechToResearch(civInfo) @@ -36,6 +36,7 @@ class NextTurnAutomation{ civInfo.popupAlerts.clear() // AIs don't care about popups. } + private fun buyBuildingOrUnit(civInfo: CivilizationInfo) { //allow AI spending money to purchase building & unit for (city in civInfo.cities.sortedByDescending{ it.population.population }) { @@ -349,17 +350,30 @@ class NextTurnAutomation{ } - fun onCitySettledNearBorders(civInfo: CivilizationInfo, newCity: CityInfo){ - val diplomacyManager = civInfo.getDiplomacyManager(newCity.civInfo) - if(diplomacyManager.hasFlag(DiplomacyFlags.IgnoreThemSettlingNearUs)) return - if(diplomacyManager.hasFlag(DiplomacyFlags.AgreedToNotSettleNearUs)){ - newCity.civInfo.popupAlerts.add(PopupAlert(AlertType.CitySettledNearOtherCivDespiteOurPromise, civInfo.civName)) - diplomacyManager.setFlag(DiplomacyFlags.IgnoreThemSettlingNearUs,200) - diplomacyManager.setModifier(DiplomaticModifiers.BetrayedPromiseToNotSettleCitiesNearUs,-20f) - } - else{ - newCity.civInfo.popupAlerts.add(PopupAlert(AlertType.CitySettledNearOtherCiv, civInfo.civName)) + private fun issueRequests(civInfo: CivilizationInfo) { + for(otherCiv in civInfo.getKnownCivs().filter { it.isMajorCiv() }){ + val diploManager = civInfo.getDiplomacyManager(otherCiv) + if(diploManager.hasFlag(DiplomacyFlags.SettledCitiesNearUs)) + onCitySettledNearBorders(civInfo,otherCiv) } } + fun onCitySettledNearBorders(civInfo: CivilizationInfo, otherCiv:CivilizationInfo){ + val diplomacyManager = civInfo.getDiplomacyManager(otherCiv) + when { + diplomacyManager.hasFlag(DiplomacyFlags.IgnoreThemSettlingNearUs) -> {} + diplomacyManager.hasFlag(DiplomacyFlags.AgreedToNotSettleNearUs) -> { + otherCiv.popupAlerts.add(PopupAlert(AlertType.CitySettledNearOtherCivDespiteOurPromise, civInfo.civName)) + diplomacyManager.setFlag(DiplomacyFlags.IgnoreThemSettlingNearUs,200) + diplomacyManager.setModifier(DiplomaticModifiers.BetrayedPromiseToNotSettleCitiesNearUs,-20f) + } + else -> { + val threatLevel = Automation().threatAssessment(civInfo,otherCiv) + if(threatLevel "You have denounced our allies" DenouncedOurEnemies -> "You have denounced our enemies" BetrayedPromiseToNotSettleCitiesNearUs -> "You betrayed your promise to not settle cities near us" + RefusedToNotSettleCitiesNearUs -> "You refused to stop settling cities near us" + FulfilledPromiseToNotSettleCitiesNearUs -> "You fulfilled your promise to stop settling cities near us!" } text = text.tr() + " " if (modifier.value > 0) text += "+" @@ -260,6 +270,23 @@ class DiplomacyScreen:CameraStageBaseScreen() { return diplomacyTable } + private fun getDemandsTable(currentPlayerCiv: CivilizationInfo, otherCiv: CivilizationInfo): Table { + val demandsTable = Table() + demandsTable.defaults().pad(10f) + val dontSettleCitiesButton = TextButton("Please don't settle new cities near us.".tr(),skin) + dontSettleCitiesButton.onClick { + val threatLevel = Automation().threatAssessment(otherCiv,currentPlayerCiv) + if(threatLevel>ThreatLevel.Medium){ + setRightSideFlavorText(otherCiv,"Very well, we shall look for new lands to settle.","Excellent!") + otherCiv.getDiplomacyManager(currentPlayerCiv).setFlag(DiplomacyFlags.WeAgreedNotToSettleNearThem,100) + } + else setRightSideFlavorText(otherCiv,"We shall do as we please.","Very well.") + } + demandsTable.add(dontSettleCitiesButton).row() + demandsTable.add(TextButton("Close".tr(),skin).onClick { updateRightSide(otherCiv) }) + return demandsTable + } + fun getRelationshipTable(otherCivDiplomacyManager: DiplomacyManager): Table { val relationshipTable = Table() @@ -305,7 +332,7 @@ class DiplomacyScreen:CameraStageBaseScreen() { diplomacyTable.addSeparator() diplomacyTable.add(flavorText.toLabel()).row() - val responseButton = TextButton(response,skin) + val responseButton = TextButton(response.tr(),skin) responseButton.onClick { updateRightSide(otherCiv) } diplomacyTable.add(responseButton) diff --git a/core/src/com/unciv/ui/worldscreen/AlertPopup.kt b/core/src/com/unciv/ui/worldscreen/AlertPopup.kt index cede34f65d..057bdd2980 100644 --- a/core/src/com/unciv/ui/worldscreen/AlertPopup.kt +++ b/core/src/com/unciv/ui/worldscreen/AlertPopup.kt @@ -4,17 +4,24 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.ui.TextButton import com.unciv.logic.civilization.AlertType import com.unciv.logic.civilization.PopupAlert +import com.unciv.logic.civilization.diplomacy.DiplomacyFlags +import com.unciv.logic.civilization.diplomacy.DiplomaticModifiers import com.unciv.models.gamebasics.Nation import com.unciv.models.gamebasics.tr import com.unciv.ui.utils.addSeparator import com.unciv.ui.utils.onClick import com.unciv.ui.utils.toLabel import com.unciv.ui.worldscreen.optionstable.PopupTable +import kotlin.random.Random class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): PopupTable(worldScreen){ - fun getCloseButton(text:String): TextButton { + fun getCloseButton(text: String, action: (() -> Unit)?=null): TextButton { val button = TextButton(text.tr(), skin) - button.onClick { close(); worldScreen.shouldUpdate=true } + button.onClick { + if(action!=null) action() + worldScreen.shouldUpdate=true + close() + } return button } @@ -47,7 +54,6 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu val translatedNation = civ.getTranslatedNation() if (civ.isCityState()) { addLeaderName(translatedNation) - val cityStateType = civ.getCityStateType() addGoodSizedLabel("We have encountered the City-State of [${translatedNation.getNameTranslation()}]!").row() add(getCloseButton("Excellent!")) } else { @@ -74,7 +80,26 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu responseTable.add(getCloseButton("Never!")) add(responseTable) } - + AlertType.CitySettledNearOtherCiv -> { + val otherciv= worldScreen.gameInfo.getCivilization(popupAlert.value) + val otherCivDiploManager = otherciv.getDiplomacyManager(worldScreen.currentPlayerCiv) + val translatedNation = otherciv.getTranslatedNation() + addLeaderName(translatedNation) + addGoodSizedLabel("Please don't settle new cities near us.").row() + add(getCloseButton("Very well, we shall look for new lands to settle."){ + otherCivDiploManager.setFlag(DiplomacyFlags.AgreedToNotSettleNearUs,100+ Random.nextInt(-20,20)) + }).row() + add(getCloseButton("We shall do as we please.") { + otherCivDiploManager.addModifier(DiplomaticModifiers.RefusedToNotSettleCitiesNearUs,-10f) + }).row() + } + AlertType.CitySettledNearOtherCivDespiteOurPromise -> { + val otherciv= worldScreen.gameInfo.getCivilization(popupAlert.value) + val translatedNation = otherciv.getTranslatedNation() + addLeaderName(translatedNation) + addGoodSizedLabel("We noticed your new city near our borders, despite your promise. This will have....implications.").row() + add(getCloseButton("Very well.")) + } } open() isOpen = true