mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 06:51:30 -04:00
Trade button changed to "Negotiate Peace" when at war, and peace treaties are a must when "trading" in this situation
This commit is contained in:
parent
20d05aa8e0
commit
24a71b16f2
@ -2489,6 +2489,8 @@
|
|||||||
Simplified_Chinese:"你会为此付出代价的!"
|
Simplified_Chinese:"你会为此付出代价的!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"Negotiate Peace":{}
|
||||||
|
|
||||||
"Very well.":{
|
"Very well.":{
|
||||||
Italian:"Molto bene."
|
Italian:"Molto bene."
|
||||||
French:"Très bien."
|
French:"Très bien."
|
||||||
|
@ -21,8 +21,8 @@ android {
|
|||||||
applicationId "com.unciv.app"
|
applicationId "com.unciv.app"
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode 238
|
versionCode 240
|
||||||
versionName "2.16.2"
|
versionName "2.16.4"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Had to add this crap for Travis to build, it wanted to sign the app
|
// Had to add this crap for Travis to build, it wanted to sign the app
|
||||||
|
@ -9,5 +9,6 @@ class Constants{
|
|||||||
const val forest = "Forest"
|
const val forest = "Forest"
|
||||||
const val jungle = "Jungle"
|
const val jungle = "Jungle"
|
||||||
const val hill = "Hill"
|
const val hill = "Hill"
|
||||||
|
const val peaceTreaty = "Peace Treaty"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,7 +17,7 @@ class GameParameters{
|
|||||||
var difficulty="Prince"
|
var difficulty="Prince"
|
||||||
var mapRadius=20
|
var mapRadius=20
|
||||||
var numberOfHumanPlayers=1
|
var numberOfHumanPlayers=1
|
||||||
var humanNations=ArrayList<String>().apply { add("Babylon") }
|
var humanNations=ArrayList<String>().apply { add("Babylon") } // Good default starting civ
|
||||||
var numberOfEnemies=3
|
var numberOfEnemies=3
|
||||||
var numberOfCityStates=0
|
var numberOfCityStates=0
|
||||||
var mapType= MapType.Perlin
|
var mapType= MapType.Perlin
|
||||||
|
@ -216,8 +216,8 @@ class NextTurnAutomation{
|
|||||||
// pay for peace
|
// pay for peace
|
||||||
val tradeLogic = TradeLogic(civInfo, enemy)
|
val tradeLogic = TradeLogic(civInfo, enemy)
|
||||||
|
|
||||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer("Peace Treaty", TradeType.Treaty, 20))
|
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty, 30))
|
||||||
tradeLogic.currentTrade.theirOffers.add(TradeOffer("Peace Treaty", TradeType.Treaty, 20))
|
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty, 30))
|
||||||
|
|
||||||
var moneyWeNeedToPay = -TradeEvaluation().evaluatePeaceCostForThem(civInfo,enemy)
|
var moneyWeNeedToPay = -TradeEvaluation().evaluatePeaceCostForThem(civInfo,enemy)
|
||||||
if(moneyWeNeedToPay>0) {
|
if(moneyWeNeedToPay>0) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.unciv.logic.civilization.diplomacy
|
package com.unciv.logic.civilization.diplomacy
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
|
import com.unciv.Constants
|
||||||
import com.unciv.logic.civilization.AlertType
|
import com.unciv.logic.civilization.AlertType
|
||||||
import com.unciv.logic.civilization.CivilizationInfo
|
import com.unciv.logic.civilization.CivilizationInfo
|
||||||
import com.unciv.logic.civilization.PopupAlert
|
import com.unciv.logic.civilization.PopupAlert
|
||||||
@ -89,7 +90,7 @@ class DiplomacyManager() {
|
|||||||
fun turnsToPeaceTreaty(): Int {
|
fun turnsToPeaceTreaty(): Int {
|
||||||
for(trade in trades)
|
for(trade in trades)
|
||||||
for(offer in trade.ourOffers)
|
for(offer in trade.ourOffers)
|
||||||
if(offer.name=="Peace Treaty" && offer.duration > 0) return offer.duration
|
if(offer.name == Constants.peaceTreaty && offer.duration > 0) return offer.duration
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.unciv.logic.trade
|
package com.unciv.logic.trade
|
||||||
|
|
||||||
|
import com.unciv.Constants
|
||||||
import com.unciv.logic.automation.Automation
|
import com.unciv.logic.automation.Automation
|
||||||
import com.unciv.logic.automation.ThreatLevel
|
import com.unciv.logic.automation.ThreatLevel
|
||||||
import com.unciv.logic.civilization.CivilizationInfo
|
import com.unciv.logic.civilization.CivilizationInfo
|
||||||
@ -29,7 +30,7 @@ class TradeEvaluation{
|
|||||||
TradeType.Gold -> return offer.amount
|
TradeType.Gold -> return offer.amount
|
||||||
TradeType.Gold_Per_Turn -> return offer.amount * offer.duration
|
TradeType.Gold_Per_Turn -> return offer.amount * offer.duration
|
||||||
TradeType.Treaty -> {
|
TradeType.Treaty -> {
|
||||||
if (offer.name == "Peace Treaty")
|
if (offer.name == Constants.peaceTreaty)
|
||||||
return evaluatePeaceCostForThem(civInfo,tradePartner) // Since it will be evaluated twice, once when they evaluate our offer and once when they evaluate theirs
|
return evaluatePeaceCostForThem(civInfo,tradePartner) // Since it will be evaluated twice, once when they evaluate our offer and once when they evaluate theirs
|
||||||
else return 1000
|
else return 1000
|
||||||
}
|
}
|
||||||
@ -119,7 +120,7 @@ class TradeEvaluation{
|
|||||||
TradeType.Gold -> return offer.amount
|
TradeType.Gold -> return offer.amount
|
||||||
TradeType.Gold_Per_Turn -> return offer.amount * offer.duration
|
TradeType.Gold_Per_Turn -> return offer.amount * offer.duration
|
||||||
TradeType.Treaty -> {
|
TradeType.Treaty -> {
|
||||||
if (offer.name == "Peace Treaty")
|
if (offer.name == Constants.peaceTreaty)
|
||||||
return evaluatePeaceCostForThem(civInfo,tradePartner) // Since it will be evaluated twice, once when they evaluate our offer and once when they evaluate theirs
|
return evaluatePeaceCostForThem(civInfo,tradePartner) // Since it will be evaluated twice, once when they evaluate our offer and once when they evaluate theirs
|
||||||
else return 1000
|
else return 1000
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.unciv.logic.trade
|
package com.unciv.logic.trade
|
||||||
|
|
||||||
|
import com.unciv.Constants
|
||||||
import com.unciv.logic.civilization.CivilizationInfo
|
import com.unciv.logic.civilization.CivilizationInfo
|
||||||
import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
|
import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
|
||||||
import com.unciv.logic.civilization.diplomacy.RelationshipLevel
|
import com.unciv.logic.civilization.diplomacy.RelationshipLevel
|
||||||
@ -17,7 +18,7 @@ class TradeLogic(val ourCivilization:CivilizationInfo, val otherCivilization: Ci
|
|||||||
val offers = TradeOffersList()
|
val offers = TradeOffersList()
|
||||||
if (civInfo.isCityState() && otherCivilization.isCityState()) return offers
|
if (civInfo.isCityState() && otherCivilization.isCityState()) return offers
|
||||||
if(civInfo.isAtWarWith(otherCivilization))
|
if(civInfo.isAtWarWith(otherCivilization))
|
||||||
offers.add(TradeOffer("Peace Treaty", TradeType.Treaty, 20))
|
offers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty, 30))
|
||||||
|
|
||||||
if(!otherCivilization.getDiplomacyManager(civInfo).hasOpenBorders
|
if(!otherCivilization.getDiplomacyManager(civInfo).hasOpenBorders
|
||||||
&& !otherCivilization.isCityState()
|
&& !otherCivilization.isCityState()
|
||||||
@ -101,7 +102,7 @@ class TradeLogic(val ourCivilization:CivilizationInfo, val otherCivilization: Ci
|
|||||||
from.updateViewableTiles()
|
from.updateViewableTiles()
|
||||||
}
|
}
|
||||||
if(offer.type== TradeType.Treaty){
|
if(offer.type== TradeType.Treaty){
|
||||||
if(offer.name=="Peace Treaty") to.getDiplomacyManager(from).makePeace()
|
if(offer.name==Constants.peaceTreaty) to.getDiplomacyManager(from).makePeace()
|
||||||
}
|
}
|
||||||
if(offer.type==TradeType.Introduction)
|
if(offer.type==TradeType.Introduction)
|
||||||
to.meetCivilization(to.gameInfo.getCivilization(offer.name.split(" ")[2]))
|
to.meetCivilization(to.gameInfo.getCivilization(offer.name.split(" ")[2]))
|
||||||
|
@ -177,8 +177,8 @@ class NewGameScreen: PickerScreen(){
|
|||||||
newGameOptionsTable.add(enemiesSelectBox).pad(10f).row()
|
newGameOptionsTable.add(enemiesSelectBox).pad(10f).row()
|
||||||
|
|
||||||
// Todo - re-enable this when city states are fit for players
|
// Todo - re-enable this when city states are fit for players
|
||||||
addCityStatesSelectBox(newGameOptionsTable)
|
// addCityStatesSelectBox(newGameOptionsTable)
|
||||||
//newGameParameters.numberOfCityStates = 0
|
newGameParameters.numberOfCityStates = 0
|
||||||
|
|
||||||
humanPlayers.addListener(object : ChangeListener() {
|
humanPlayers.addListener(object : ChangeListener() {
|
||||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||||
|
@ -5,6 +5,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.SplitPane
|
import com.badlogic.gdx.scenes.scene2d.ui.SplitPane
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||||
|
import com.unciv.Constants
|
||||||
import com.unciv.UnCivGame
|
import com.unciv.UnCivGame
|
||||||
import com.unciv.logic.civilization.CityStateType
|
import com.unciv.logic.civilization.CityStateType
|
||||||
import com.unciv.logic.civilization.CivilizationInfo
|
import com.unciv.logic.civilization.CivilizationInfo
|
||||||
@ -122,8 +123,8 @@ class DiplomacyScreen:CameraStageBaseScreen() {
|
|||||||
PeaceButton.onClick {
|
PeaceButton.onClick {
|
||||||
YesNoPopupTable("Peace with [${otherCiv.civName}]?".tr(), {
|
YesNoPopupTable("Peace with [${otherCiv.civName}]?".tr(), {
|
||||||
val tradeLogic = TradeLogic(currentPlayerCiv, otherCiv)
|
val tradeLogic = TradeLogic(currentPlayerCiv, otherCiv)
|
||||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer("Peace Treaty", TradeType.Treaty, 20))
|
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty, 30))
|
||||||
tradeLogic.currentTrade.theirOffers.add(TradeOffer("Peace Treaty", TradeType.Treaty, 20))
|
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty, 30))
|
||||||
tradeLogic.acceptTrade()
|
tradeLogic.acceptTrade()
|
||||||
updateLeftSideTable()
|
updateLeftSideTable()
|
||||||
}, this)
|
}, this)
|
||||||
@ -144,11 +145,25 @@ class DiplomacyScreen:CameraStageBaseScreen() {
|
|||||||
diplomacyTable.add(otherCiv.getNation().getLeaderDisplayName().toLabel())
|
diplomacyTable.add(otherCiv.getNation().getLeaderDisplayName().toLabel())
|
||||||
diplomacyTable.addSeparator()
|
diplomacyTable.addSeparator()
|
||||||
|
|
||||||
|
if(!currentPlayerCiv.isAtWarWith(otherCiv)) {
|
||||||
val tradeButton = TextButton("Trade".tr(), skin)
|
val tradeButton = TextButton("Trade".tr(), skin)
|
||||||
tradeButton.onClick { setTrade(otherCiv) }
|
tradeButton.onClick { setTrade(otherCiv) }
|
||||||
if(otherCiv.getDiplomacyManager(currentPlayerCiv).hasFlag(DiplomacyFlags.DeclaredWar))
|
|
||||||
tradeButton.disable() // Can't trade for 10 turns after war was declared
|
|
||||||
diplomacyTable.add(tradeButton).row()
|
diplomacyTable.add(tradeButton).row()
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
val negotiatePeaceButton = TextButton("Negotiate Peace".tr(),skin)
|
||||||
|
negotiatePeaceButton.onClick {
|
||||||
|
val tradeTable = setTrade(otherCiv)
|
||||||
|
val peaceTreaty = TradeOffer(Constants.peaceTreaty,TradeType.Treaty,30)
|
||||||
|
tradeTable.tradeLogic.currentTrade.theirOffers.add(peaceTreaty)
|
||||||
|
tradeTable.tradeLogic.currentTrade.ourOffers.add(peaceTreaty)
|
||||||
|
tradeTable.offerColumnsTable.update()
|
||||||
|
}
|
||||||
|
if (otherCiv.getDiplomacyManager(currentPlayerCiv).hasFlag(DiplomacyFlags.DeclaredWar))
|
||||||
|
negotiatePeaceButton.disable() // Can't trade for 10 turns after war was declared
|
||||||
|
|
||||||
|
diplomacyTable.add(negotiatePeaceButton).row()
|
||||||
|
}
|
||||||
|
|
||||||
val diplomacyManager = currentPlayerCiv.getDiplomacyManager(otherCiv)
|
val diplomacyManager = currentPlayerCiv.getDiplomacyManager(otherCiv)
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package com.unciv.ui.trade
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
|
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||||
|
import com.unciv.Constants
|
||||||
import com.unciv.logic.trade.TradeOffer
|
import com.unciv.logic.trade.TradeOffer
|
||||||
import com.unciv.logic.trade.TradeOffersList
|
import com.unciv.logic.trade.TradeOffersList
|
||||||
import com.unciv.logic.trade.TradeType
|
import com.unciv.logic.trade.TradeType
|
||||||
@ -52,7 +53,7 @@ class OffersListScroll(val onOfferClicked: (TradeOffer) -> Unit) : ScrollPane(nu
|
|||||||
val amountPerClick =
|
val amountPerClick =
|
||||||
if (offer.type == Gold) 50
|
if (offer.type == Gold) 50
|
||||||
else 1
|
else 1
|
||||||
if (offer.amount > 0)
|
if (offer.amount > 0 && offer.name != Constants.peaceTreaty) // can't disable peace treaty!
|
||||||
tradeButton.onClick {
|
tradeButton.onClick {
|
||||||
val amountTransferred = min(amountPerClick, offer.amount)
|
val amountTransferred = min(amountPerClick, offer.amount)
|
||||||
onOfferClicked(offer.copy(amount = amountTransferred))
|
onOfferClicked(offer.copy(amount = amountTransferred))
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.unciv.ui.worldscreen
|
package com.unciv.ui.worldscreen
|
||||||
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
|
import com.unciv.Constants
|
||||||
import com.unciv.logic.civilization.diplomacy.DiplomacyFlags
|
import com.unciv.logic.civilization.diplomacy.DiplomacyFlags
|
||||||
import com.unciv.logic.trade.TradeLogic
|
import com.unciv.logic.trade.TradeLogic
|
||||||
import com.unciv.logic.trade.TradeType
|
import com.unciv.logic.trade.TradeType
|
||||||
@ -62,7 +63,7 @@ class TradePopup(worldScreen: WorldScreen): PopupTable(worldScreen){
|
|||||||
if(trade.ourOffers.all { it.type==TradeType.Luxury_Resource } && trade.theirOffers.all { it.type==TradeType.Luxury_Resource })
|
if(trade.ourOffers.all { it.type==TradeType.Luxury_Resource } && trade.theirOffers.all { it.type==TradeType.Luxury_Resource })
|
||||||
diplomacyManager.setFlag(DiplomacyFlags.DeclinedLuxExchange,20) // offer again in 20 turns
|
diplomacyManager.setFlag(DiplomacyFlags.DeclinedLuxExchange,20) // offer again in 20 turns
|
||||||
|
|
||||||
if(trade.ourOffers.any{ it.type==TradeType.Treaty && it.name=="Peace Treaty" })
|
if(trade.ourOffers.any{ it.type==TradeType.Treaty && it.name== Constants.peaceTreaty })
|
||||||
diplomacyManager.setFlag(DiplomacyFlags.DeclinedPeace,5)
|
diplomacyManager.setFlag(DiplomacyFlags.DeclinedPeace,5)
|
||||||
|
|
||||||
remove()
|
remove()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user