mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-30 23:41:03 -04:00
Resolved #1936 - can sign Declarations of Friendship in Multiplayer
This commit is contained in:
parent
09bdaeb7a8
commit
b6fc37aad8
@ -677,7 +677,7 @@ Tiles =
|
|||||||
Natural Wonders =
|
Natural Wonders =
|
||||||
Treasury deficit =
|
Treasury deficit =
|
||||||
|
|
||||||
#Victory
|
# Victory
|
||||||
|
|
||||||
Science victory =
|
Science victory =
|
||||||
Cultural victory =
|
Cultural victory =
|
||||||
@ -723,6 +723,14 @@ Destroying the city instantly razes the city to the ground. =
|
|||||||
Remove your troops in our border immediately! =
|
Remove your troops in our border immediately! =
|
||||||
Sorry. =
|
Sorry. =
|
||||||
Never! =
|
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 =
|
Basics =
|
||||||
Resources =
|
Resources =
|
||||||
Terrains =
|
Terrains =
|
||||||
|
@ -21,7 +21,7 @@ object NextTurnAutomation{
|
|||||||
fun automateCivMoves(civInfo: CivilizationInfo) {
|
fun automateCivMoves(civInfo: CivilizationInfo) {
|
||||||
if (civInfo.isBarbarian()) return BarbarianAutomation(civInfo).automate()
|
if (civInfo.isBarbarian()) return BarbarianAutomation(civInfo).automate()
|
||||||
|
|
||||||
respondToDemands(civInfo)
|
respondToPopupAlerts(civInfo)
|
||||||
respondToTradeRequests(civInfo)
|
respondToTradeRequests(civInfo)
|
||||||
|
|
||||||
if(civInfo.isMajorCiv()) {
|
if(civInfo.isMajorCiv()) {
|
||||||
@ -45,7 +45,6 @@ object NextTurnAutomation{
|
|||||||
reassignWorkedTiles(civInfo)
|
reassignWorkedTiles(civInfo)
|
||||||
trainSettler(civInfo)
|
trainSettler(civInfo)
|
||||||
|
|
||||||
civInfo.popupAlerts.clear() // AIs don't care about popups.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun respondToTradeRequests(civInfo: CivilizationInfo) {
|
private fun respondToTradeRequests(civInfo: CivilizationInfo) {
|
||||||
@ -64,16 +63,27 @@ object NextTurnAutomation{
|
|||||||
civInfo.tradeRequests.clear()
|
civInfo.tradeRequests.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun respondToDemands(civInfo: CivilizationInfo) {
|
private fun respondToPopupAlerts(civInfo: CivilizationInfo) {
|
||||||
for(popupAlert in civInfo.popupAlerts){
|
for(popupAlert in civInfo.popupAlerts) {
|
||||||
if(popupAlert.type==AlertType.DemandToStopSettlingCitiesNear){ // we're called upon to make a decision
|
if (popupAlert.type == AlertType.DemandToStopSettlingCitiesNear) { // we're called upon to make a decision
|
||||||
val demandingCiv = civInfo.gameInfo.getCivilization(popupAlert.value)
|
val demandingCiv = civInfo.gameInfo.getCivilization(popupAlert.value)
|
||||||
val diploManager = civInfo.getDiplomacyManager(demandingCiv)
|
val diploManager = civInfo.getDiplomacyManager(demandingCiv)
|
||||||
if(Automation.threatAssessment(civInfo,demandingCiv) >= ThreatLevel.High)
|
if (Automation.threatAssessment(civInfo, demandingCiv) >= ThreatLevel.High)
|
||||||
diploManager.agreeNotToSettleNear()
|
diploManager.agreeNotToSettleNear()
|
||||||
else diploManager.refuseDemandNotToSettleNear()
|
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) {
|
private fun tryGainInfluence(civInfo: CivilizationInfo, cityState:CivilizationInfo) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.unciv.logic.civilization
|
package com.unciv.logic.civilization
|
||||||
|
|
||||||
enum class AlertType{
|
enum class AlertType {
|
||||||
Defeated,
|
Defeated,
|
||||||
WonderBuilt,
|
WonderBuilt,
|
||||||
TechResearched,
|
TechResearched,
|
||||||
@ -11,6 +11,7 @@ enum class AlertType{
|
|||||||
DemandToStopSettlingCitiesNear,
|
DemandToStopSettlingCitiesNear,
|
||||||
CitySettledNearOtherCivDespiteOurPromise,
|
CitySettledNearOtherCivDespiteOurPromise,
|
||||||
GoldenAge,
|
GoldenAge,
|
||||||
|
DeclarationOfFriendship,
|
||||||
}
|
}
|
||||||
|
|
||||||
class PopupAlert {
|
class PopupAlert {
|
||||||
|
@ -177,29 +177,28 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() {
|
|||||||
diplomacyTable.defaults().pad(10f)
|
diplomacyTable.defaults().pad(10f)
|
||||||
|
|
||||||
diplomacyTable.add(otherCiv.getLeaderDisplayName().toLabel(fontSize = 24)).row()
|
diplomacyTable.add(otherCiv.getLeaderDisplayName().toLabel(fontSize = 24)).row()
|
||||||
if(otherCivDiplomacyManager.relationshipLevel()<=RelationshipLevel.Enemy)
|
if (otherCivDiplomacyManager.relationshipLevel() <= RelationshipLevel.Enemy)
|
||||||
diplomacyTable.add(otherCiv.nation.hateHello.toLabel()).row()
|
diplomacyTable.add(otherCiv.nation.hateHello.toLabel()).row()
|
||||||
else
|
else
|
||||||
diplomacyTable.add(otherCiv.nation.neutralHello.toLabel()).row()
|
diplomacyTable.add(otherCiv.nation.neutralHello.toLabel()).row()
|
||||||
diplomacyTable.addSeparator()
|
diplomacyTable.addSeparator()
|
||||||
|
|
||||||
if(!viewingCiv.isAtWarWith(otherCiv)) {
|
if (!viewingCiv.isAtWarWith(otherCiv)) {
|
||||||
val tradeButton = "Trade".toTextButton()
|
val tradeButton = "Trade".toTextButton()
|
||||||
tradeButton.onClick {
|
tradeButton.onClick {
|
||||||
setTrade(otherCiv).apply {
|
setTrade(otherCiv).apply {
|
||||||
tradeLogic.ourAvailableOffers.apply { remove(firstOrNull { it.type==TradeType.Treaty }) }
|
tradeLogic.ourAvailableOffers.apply { remove(firstOrNull { it.type == TradeType.Treaty }) }
|
||||||
tradeLogic.theirAvailableOffers.apply { remove(firstOrNull { it.type==TradeType.Treaty }) }
|
tradeLogic.theirAvailableOffers.apply { remove(firstOrNull { it.type == TradeType.Treaty }) }
|
||||||
offerColumnsTable.update()
|
offerColumnsTable.update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
diplomacyTable.add(tradeButton).row()
|
diplomacyTable.add(tradeButton).row()
|
||||||
if(isNotPlayersTurn()) tradeButton.disable()
|
if (isNotPlayersTurn()) tradeButton.disable()
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
val negotiatePeaceButton = "Negotiate Peace".toTextButton()
|
val negotiatePeaceButton = "Negotiate Peace".toTextButton()
|
||||||
negotiatePeaceButton.onClick {
|
negotiatePeaceButton.onClick {
|
||||||
val tradeTable = setTrade(otherCiv)
|
val tradeTable = setTrade(otherCiv)
|
||||||
val peaceTreaty = TradeOffer(Constants.peaceTreaty,TradeType.Treaty)
|
val peaceTreaty = TradeOffer(Constants.peaceTreaty, TradeType.Treaty)
|
||||||
tradeTable.tradeLogic.currentTrade.theirOffers.add(peaceTreaty)
|
tradeTable.tradeLogic.currentTrade.theirOffers.add(peaceTreaty)
|
||||||
tradeTable.tradeLogic.currentTrade.ourOffers.add(peaceTreaty)
|
tradeTable.tradeLogic.currentTrade.ourOffers.add(peaceTreaty)
|
||||||
tradeTable.offerColumnsTable.update()
|
tradeTable.offerColumnsTable.update()
|
||||||
@ -212,22 +211,21 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() {
|
|||||||
|
|
||||||
val diplomacyManager = viewingCiv.getDiplomacyManager(otherCiv)
|
val diplomacyManager = viewingCiv.getDiplomacyManager(otherCiv)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!viewingCiv.isAtWarWith(otherCiv)) {
|
if (!viewingCiv.isAtWarWith(otherCiv)) {
|
||||||
if(otherCivDiplomacyManager.relationshipLevel() > RelationshipLevel.Neutral
|
if(!diplomacyManager.hasFlag(DiplomacyFlags.DeclarationOfFriendship)) {
|
||||||
&& !diplomacyManager.hasFlag(DiplomacyFlags.DeclarationOfFriendship)
|
val declareFriendshipButton = "Offer Declaration of Friendship ([30] turns)".toTextButton()
|
||||||
&& !diplomacyManager.hasFlag(DiplomacyFlags.Denunceation)){
|
|
||||||
val declareFriendshipButton = "Declare Friendship ([30] turns)".toTextButton()
|
|
||||||
declareFriendshipButton.onClick {
|
declareFriendshipButton.onClick {
|
||||||
diplomacyManager.signDeclarationOfFriendship()
|
otherCiv.popupAlerts.add(PopupAlert(AlertType.DeclarationOfFriendship, viewingCiv.civName))
|
||||||
setRightSideFlavorText(otherCiv,"May our nations forever remain united!","Indeed!")
|
declareFriendshipButton.disable()
|
||||||
}
|
}
|
||||||
diplomacyTable.add(declareFriendshipButton).row()
|
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)){
|
|
||||||
|
if (viewingCiv.canSignResearchAgreementsWith(otherCiv)) {
|
||||||
val researchAgreementButton = "Research Agreement".toTextButton()
|
val researchAgreementButton = "Research Agreement".toTextButton()
|
||||||
|
|
||||||
val requiredGold = viewingCiv.getResearchAgreementCost(otherCiv)
|
val requiredGold = viewingCiv.getResearchAgreementCost(otherCiv)
|
||||||
@ -248,31 +246,31 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() {
|
|||||||
diplomacyTable.add(researchAgreementButton).row()
|
diplomacyTable.add(researchAgreementButton).row()
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!diplomacyManager.hasFlag(DiplomacyFlags.Denunceation)
|
if (!diplomacyManager.hasFlag(DiplomacyFlags.Denunceation)
|
||||||
&& !diplomacyManager.hasFlag(DiplomacyFlags.DeclarationOfFriendship)){
|
&& !diplomacyManager.hasFlag(DiplomacyFlags.DeclarationOfFriendship)) {
|
||||||
val denounceButton = "Denounce ([30] turns)".toTextButton()
|
val denounceButton = "Denounce ([30] turns)".toTextButton()
|
||||||
denounceButton.onClick {
|
denounceButton.onClick {
|
||||||
diplomacyManager.denounce()
|
diplomacyManager.denounce()
|
||||||
setRightSideFlavorText(otherCiv,"We will remember this.","Very well.")
|
setRightSideFlavorText(otherCiv, "We will remember this.", "Very well.")
|
||||||
}
|
}
|
||||||
diplomacyTable.add(denounceButton).row()
|
diplomacyTable.add(denounceButton).row()
|
||||||
if(isNotPlayersTurn()) denounceButton.disable()
|
if (isNotPlayersTurn()) denounceButton.disable()
|
||||||
}
|
}
|
||||||
|
|
||||||
val declareWarButton = getDeclareWarButton(diplomacyManager, otherCiv)
|
val declareWarButton = getDeclareWarButton(diplomacyManager, otherCiv)
|
||||||
diplomacyTable.add(declareWarButton).row()
|
diplomacyTable.add(declareWarButton).row()
|
||||||
if(isNotPlayersTurn()) declareWarButton.disable()
|
if (isNotPlayersTurn()) declareWarButton.disable()
|
||||||
}
|
}
|
||||||
|
|
||||||
val demandsButton = "Demands".toTextButton()
|
val demandsButton = "Demands".toTextButton()
|
||||||
demandsButton.onClick {
|
demandsButton.onClick {
|
||||||
rightSideTable.clear()
|
rightSideTable.clear()
|
||||||
rightSideTable.add(getDemandsTable(viewingCiv,otherCiv))
|
rightSideTable.add(getDemandsTable(viewingCiv, otherCiv))
|
||||||
}
|
}
|
||||||
diplomacyTable.add(demandsButton).row()
|
diplomacyTable.add(demandsButton).row()
|
||||||
if(isNotPlayersTurn()) demandsButton.disable()
|
if (isNotPlayersTurn()) demandsButton.disable()
|
||||||
|
|
||||||
if(!otherCiv.isPlayerCivilization()) { // human players make their own choices
|
if (!otherCiv.isPlayerCivilization()) { // human players make their own choices
|
||||||
diplomacyTable.add(getRelationshipTable(otherCivDiplomacyManager)).row()
|
diplomacyTable.add(getRelationshipTable(otherCivDiplomacyManager)).row()
|
||||||
diplomacyTable.add(getDiplomacyModifiersTable(otherCivDiplomacyManager)).row()
|
diplomacyTable.add(getDiplomacyModifiersTable(otherCivDiplomacyManager)).row()
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
|
|||||||
}
|
}
|
||||||
AlertType.CityConquered -> {
|
AlertType.CityConquered -> {
|
||||||
val city = worldScreen.gameInfo.getCities().first { it.id == popupAlert.value }
|
val city = worldScreen.gameInfo.getCities().first { it.id == popupAlert.value }
|
||||||
addGoodSizedLabel("What would you like to do with the city?",24)
|
addGoodSizedLabel("What would you like to do with the city?", 24)
|
||||||
.padBottom(20f).row()
|
.padBottom(20f).row()
|
||||||
val conqueringCiv = worldScreen.gameInfo.currentPlayerCiv
|
val conqueringCiv = worldScreen.gameInfo.currentPlayerCiv
|
||||||
|
|
||||||
@ -68,19 +68,19 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
|
|||||||
&& conqueringCiv.civName != city.foundingCiv) { // or belongs originally to us
|
&& conqueringCiv.civName != city.foundingCiv) { // or belongs originally to us
|
||||||
add("Liberate".toTextButton().onClick {
|
add("Liberate".toTextButton().onClick {
|
||||||
city.liberateCity(conqueringCiv)
|
city.liberateCity(conqueringCiv)
|
||||||
worldScreen.shouldUpdate=true
|
worldScreen.shouldUpdate = true
|
||||||
close()
|
close()
|
||||||
}).row()
|
}).row()
|
||||||
addGoodSizedLabel("Liberating a city returns it to its original owner, giving you a massive relationship boost with them!")
|
addGoodSizedLabel("Liberating a city returns it to its original owner, giving you a massive relationship boost with them!")
|
||||||
addSeparator()
|
addSeparator()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!conqueringCiv.isOneCityChallenger()){
|
if (!conqueringCiv.isOneCityChallenger()) {
|
||||||
|
|
||||||
add("Annex".toTextButton().onClick {
|
add("Annex".toTextButton().onClick {
|
||||||
city.puppetCity(conqueringCiv)
|
city.puppetCity(conqueringCiv)
|
||||||
city.annexCity()
|
city.annexCity()
|
||||||
worldScreen.shouldUpdate=true
|
worldScreen.shouldUpdate = true
|
||||||
close()
|
close()
|
||||||
}).row()
|
}).row()
|
||||||
addGoodSizedLabel("Annexed cities become part of your regular empire.").row()
|
addGoodSizedLabel("Annexed cities become part of your regular empire.").row()
|
||||||
@ -89,7 +89,7 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
|
|||||||
|
|
||||||
add("Puppet".toTextButton().onClick {
|
add("Puppet".toTextButton().onClick {
|
||||||
city.puppetCity(conqueringCiv)
|
city.puppetCity(conqueringCiv)
|
||||||
worldScreen.shouldUpdate=true
|
worldScreen.shouldUpdate = true
|
||||||
close()
|
close()
|
||||||
}).row()
|
}).row()
|
||||||
addGoodSizedLabel("Puppeted cities do not increase your tech or policy cost, but their citizens generate 1.5x the regular unhappiness.").row()
|
addGoodSizedLabel("Puppeted cities do not increase your tech or policy cost, but their citizens generate 1.5x the regular unhappiness.").row()
|
||||||
@ -102,12 +102,13 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
|
|||||||
add("Raze".toTextButton().apply {
|
add("Raze".toTextButton().apply {
|
||||||
if (city.isOriginalCapital) disable()
|
if (city.isOriginalCapital) disable()
|
||||||
else onClick {
|
else onClick {
|
||||||
city.puppetCity(conqueringCiv)
|
city.puppetCity(conqueringCiv)
|
||||||
city.annexCity()
|
city.annexCity()
|
||||||
city.isBeingRazed = true
|
city.isBeingRazed = true
|
||||||
worldScreen.shouldUpdate=true
|
worldScreen.shouldUpdate = true
|
||||||
close()
|
close()
|
||||||
}}).row()
|
}
|
||||||
|
}).row()
|
||||||
addGoodSizedLabel("Razing the city annexes it, and starts razing the city to the ground.").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()
|
addGoodSizedLabel("The population will gradually dwindle until the city is destroyed.").row()
|
||||||
} else {
|
} else {
|
||||||
@ -115,13 +116,11 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
|
|||||||
add("Destroy".toTextButton().onClick {
|
add("Destroy".toTextButton().onClick {
|
||||||
city.puppetCity(conqueringCiv)
|
city.puppetCity(conqueringCiv)
|
||||||
city.destroyCity()
|
city.destroyCity()
|
||||||
worldScreen.shouldUpdate=true
|
worldScreen.shouldUpdate = true
|
||||||
close()
|
close()
|
||||||
}).row()
|
}).row()
|
||||||
addGoodSizedLabel("Destroying the city instantly razes the city to the ground.").row()
|
addGoodSizedLabel("Destroying the city instantly razes the city to the ground.").row()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
AlertType.BorderConflict -> {
|
AlertType.BorderConflict -> {
|
||||||
val civInfo = worldScreen.gameInfo.getCivilization(popupAlert.value)
|
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()
|
addGoodSizedLabel("Your citizens have been happy with your rule for so long that the empire enters a Golden Age!").row()
|
||||||
add(getCloseButton(Constants.close))
|
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