mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-30 15:30:43 -04:00
Resolved #1936 - can sign Declarations of Friendship in Multiplayer
This commit is contained in:
parent
09bdaeb7a8
commit
b6fc37aad8
@ -723,6 +723,14 @@ Destroying the city instantly razes the city to the ground. =
|
||||
Remove your troops in our border immediately! =
|
||||
Sorry. =
|
||||
Never! =
|
||||
|
||||
Offer Declaration of Friendship ([30] turns) =
|
||||
My friend, shall we declare our friendship to the world? =
|
||||
Sign Declaration of Friendship ([30] turns) =
|
||||
We are not interested. =
|
||||
We have signed a Declaration of Friendship with [otherCiv]! =
|
||||
[otherCiv] has denied our Declaration of Friendship! =
|
||||
|
||||
Basics =
|
||||
Resources =
|
||||
Terrains =
|
||||
|
@ -21,7 +21,7 @@ object NextTurnAutomation{
|
||||
fun automateCivMoves(civInfo: CivilizationInfo) {
|
||||
if (civInfo.isBarbarian()) return BarbarianAutomation(civInfo).automate()
|
||||
|
||||
respondToDemands(civInfo)
|
||||
respondToPopupAlerts(civInfo)
|
||||
respondToTradeRequests(civInfo)
|
||||
|
||||
if(civInfo.isMajorCiv()) {
|
||||
@ -45,7 +45,6 @@ object NextTurnAutomation{
|
||||
reassignWorkedTiles(civInfo)
|
||||
trainSettler(civInfo)
|
||||
|
||||
civInfo.popupAlerts.clear() // AIs don't care about popups.
|
||||
}
|
||||
|
||||
private fun respondToTradeRequests(civInfo: CivilizationInfo) {
|
||||
@ -64,7 +63,7 @@ object NextTurnAutomation{
|
||||
civInfo.tradeRequests.clear()
|
||||
}
|
||||
|
||||
private fun respondToDemands(civInfo: CivilizationInfo) {
|
||||
private fun respondToPopupAlerts(civInfo: CivilizationInfo) {
|
||||
for(popupAlert in civInfo.popupAlerts) {
|
||||
if (popupAlert.type == AlertType.DemandToStopSettlingCitiesNear) { // we're called upon to make a decision
|
||||
val demandingCiv = civInfo.gameInfo.getCivilization(popupAlert.value)
|
||||
@ -73,9 +72,20 @@ object NextTurnAutomation{
|
||||
diploManager.agreeNotToSettleNear()
|
||||
else diploManager.refuseDemandNotToSettleNear()
|
||||
}
|
||||
if (popupAlert.type == AlertType.DeclarationOfFriendship) {
|
||||
val requestingCiv = civInfo.gameInfo.getCivilization(popupAlert.value)
|
||||
val diploManager = civInfo.getDiplomacyManager(requestingCiv)
|
||||
if (diploManager.relationshipLevel() > RelationshipLevel.Neutral
|
||||
&& !diploManager.otherCivDiplomacy().hasFlag(DiplomacyFlags.Denunceation)) {
|
||||
diploManager.signDeclarationOfFriendship()
|
||||
requestingCiv.addNotification("We have signed a Declaration of Friendship with [${civInfo.civName}]!", Color.GOLD)
|
||||
} else requestingCiv.addNotification("[${civInfo.civName}] has denied our Declaration of Friendship!", Color.GOLD)
|
||||
}
|
||||
}
|
||||
|
||||
civInfo.popupAlerts.clear() // AIs don't care about popups.
|
||||
}
|
||||
|
||||
private fun tryGainInfluence(civInfo: CivilizationInfo, cityState:CivilizationInfo) {
|
||||
if (civInfo.gold < 250) return // save up
|
||||
if (cityState.getDiplomacyManager(civInfo).influence < 20) {
|
||||
|
@ -11,6 +11,7 @@ enum class AlertType{
|
||||
DemandToStopSettlingCitiesNear,
|
||||
CitySettledNearOtherCivDespiteOurPromise,
|
||||
GoldenAge,
|
||||
DeclarationOfFriendship,
|
||||
}
|
||||
|
||||
class PopupAlert {
|
||||
|
@ -194,8 +194,7 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() {
|
||||
}
|
||||
diplomacyTable.add(tradeButton).row()
|
||||
if (isNotPlayersTurn()) tradeButton.disable()
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
val negotiatePeaceButton = "Negotiate Peace".toTextButton()
|
||||
negotiatePeaceButton.onClick {
|
||||
val tradeTable = setTrade(otherCiv)
|
||||
@ -212,21 +211,20 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() {
|
||||
|
||||
val diplomacyManager = viewingCiv.getDiplomacyManager(otherCiv)
|
||||
|
||||
|
||||
|
||||
if (!viewingCiv.isAtWarWith(otherCiv)) {
|
||||
if(otherCivDiplomacyManager.relationshipLevel() > RelationshipLevel.Neutral
|
||||
&& !diplomacyManager.hasFlag(DiplomacyFlags.DeclarationOfFriendship)
|
||||
&& !diplomacyManager.hasFlag(DiplomacyFlags.Denunceation)){
|
||||
val declareFriendshipButton = "Declare Friendship ([30] turns)".toTextButton()
|
||||
if(!diplomacyManager.hasFlag(DiplomacyFlags.DeclarationOfFriendship)) {
|
||||
val declareFriendshipButton = "Offer Declaration of Friendship ([30] turns)".toTextButton()
|
||||
declareFriendshipButton.onClick {
|
||||
diplomacyManager.signDeclarationOfFriendship()
|
||||
setRightSideFlavorText(otherCiv,"May our nations forever remain united!","Indeed!")
|
||||
otherCiv.popupAlerts.add(PopupAlert(AlertType.DeclarationOfFriendship, viewingCiv.civName))
|
||||
declareFriendshipButton.disable()
|
||||
}
|
||||
diplomacyTable.add(declareFriendshipButton).row()
|
||||
if(isNotPlayersTurn()) declareFriendshipButton.disable()
|
||||
if (isNotPlayersTurn() || otherCiv.popupAlerts
|
||||
.any { it.type == AlertType.DeclarationOfFriendship && it.value == viewingCiv.civName })
|
||||
declareFriendshipButton.disable()
|
||||
}
|
||||
|
||||
|
||||
if (viewingCiv.canSignResearchAgreementsWith(otherCiv)) {
|
||||
val researchAgreementButton = "Research Agreement".toTextButton()
|
||||
|
||||
|
@ -107,7 +107,8 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
|
||||
city.isBeingRazed = true
|
||||
worldScreen.shouldUpdate = true
|
||||
close()
|
||||
}}).row()
|
||||
}
|
||||
}).row()
|
||||
addGoodSizedLabel("Razing the city annexes it, and starts razing the city to the ground.").row()
|
||||
addGoodSizedLabel("The population will gradually dwindle until the city is destroyed.").row()
|
||||
} else {
|
||||
@ -119,9 +120,7 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
|
||||
close()
|
||||
}).row()
|
||||
addGoodSizedLabel("Destroying the city instantly razes the city to the ground.").row()
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
AlertType.BorderConflict -> {
|
||||
val civInfo = worldScreen.gameInfo.getCivilization(popupAlert.value)
|
||||
@ -180,6 +179,16 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
|
||||
addGoodSizedLabel("Your citizens have been happy with your rule for so long that the empire enters a Golden Age!").row()
|
||||
add(getCloseButton(Constants.close))
|
||||
}
|
||||
AlertType.DeclarationOfFriendship -> {
|
||||
val otherciv = worldScreen.gameInfo.getCivilization(popupAlert.value)
|
||||
val playerDiploManager = worldScreen.viewingCiv.getDiplomacyManager(otherciv)
|
||||
addLeaderName(otherciv)
|
||||
addGoodSizedLabel("My friend, shall we declare our friendship to the world?").row()
|
||||
add(getCloseButton("We are not interested.")).row()
|
||||
add(getCloseButton("Declare Friendship ([30] turns)") {
|
||||
playerDiploManager.signDeclarationOfFriendship()
|
||||
}).row()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user