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
12 changed files with 44 additions and 21 deletions
|
@ -2488,6 +2488,8 @@
|
|||
Portuguese:"Você vai pagar por isso!"
|
||||
Simplified_Chinese:"你会为此付出代价的!"
|
||||
}
|
||||
|
||||
"Negotiate Peace":{}
|
||||
|
||||
"Very well.":{
|
||||
Italian:"Molto bene."
|
||||
|
|
|
@ -21,8 +21,8 @@ android {
|
|||
applicationId "com.unciv.app"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 28
|
||||
versionCode 238
|
||||
versionName "2.16.2"
|
||||
versionCode 240
|
||||
versionName "2.16.4"
|
||||
}
|
||||
|
||||
// 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 jungle = "Jungle"
|
||||
const val hill = "Hill"
|
||||
const val peaceTreaty = "Peace Treaty"
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ class GameParameters{
|
|||
var difficulty="Prince"
|
||||
var mapRadius=20
|
||||
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 numberOfCityStates=0
|
||||
var mapType= MapType.Perlin
|
||||
|
|
|
@ -216,8 +216,8 @@ class NextTurnAutomation{
|
|||
// pay for peace
|
||||
val tradeLogic = TradeLogic(civInfo, enemy)
|
||||
|
||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer("Peace Treaty", TradeType.Treaty, 20))
|
||||
tradeLogic.currentTrade.theirOffers.add(TradeOffer("Peace Treaty", TradeType.Treaty, 20))
|
||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty, 30))
|
||||
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty, 30))
|
||||
|
||||
var moneyWeNeedToPay = -TradeEvaluation().evaluatePeaceCostForThem(civInfo,enemy)
|
||||
if(moneyWeNeedToPay>0) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.unciv.logic.civilization.diplomacy
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.unciv.Constants
|
||||
import com.unciv.logic.civilization.AlertType
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.civilization.PopupAlert
|
||||
|
@ -89,7 +90,7 @@ class DiplomacyManager() {
|
|||
fun turnsToPeaceTreaty(): Int {
|
||||
for(trade in trades)
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.unciv.logic.trade
|
||||
|
||||
import com.unciv.Constants
|
||||
import com.unciv.logic.automation.Automation
|
||||
import com.unciv.logic.automation.ThreatLevel
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
|
@ -29,7 +30,7 @@ class TradeEvaluation{
|
|||
TradeType.Gold -> return offer.amount
|
||||
TradeType.Gold_Per_Turn -> return offer.amount * offer.duration
|
||||
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
|
||||
else return 1000
|
||||
}
|
||||
|
@ -119,7 +120,7 @@ class TradeEvaluation{
|
|||
TradeType.Gold -> return offer.amount
|
||||
TradeType.Gold_Per_Turn -> return offer.amount * offer.duration
|
||||
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
|
||||
else return 1000
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.unciv.logic.trade
|
||||
|
||||
import com.unciv.Constants
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
|
||||
import com.unciv.logic.civilization.diplomacy.RelationshipLevel
|
||||
|
@ -17,7 +18,7 @@ class TradeLogic(val ourCivilization:CivilizationInfo, val otherCivilization: Ci
|
|||
val offers = TradeOffersList()
|
||||
if (civInfo.isCityState() && otherCivilization.isCityState()) return offers
|
||||
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
|
||||
&& !otherCivilization.isCityState()
|
||||
|
@ -101,7 +102,7 @@ class TradeLogic(val ourCivilization:CivilizationInfo, val otherCivilization: Ci
|
|||
from.updateViewableTiles()
|
||||
}
|
||||
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)
|
||||
to.meetCivilization(to.gameInfo.getCivilization(offer.name.split(" ")[2]))
|
||||
|
|
|
@ -177,8 +177,8 @@ class NewGameScreen: PickerScreen(){
|
|||
newGameOptionsTable.add(enemiesSelectBox).pad(10f).row()
|
||||
|
||||
// Todo - re-enable this when city states are fit for players
|
||||
addCityStatesSelectBox(newGameOptionsTable)
|
||||
//newGameParameters.numberOfCityStates = 0
|
||||
// addCityStatesSelectBox(newGameOptionsTable)
|
||||
newGameParameters.numberOfCityStates = 0
|
||||
|
||||
humanPlayers.addListener(object : ChangeListener() {
|
||||
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.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.unciv.Constants
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.logic.civilization.CityStateType
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
|
@ -122,8 +123,8 @@ class DiplomacyScreen:CameraStageBaseScreen() {
|
|||
PeaceButton.onClick {
|
||||
YesNoPopupTable("Peace with [${otherCiv.civName}]?".tr(), {
|
||||
val tradeLogic = TradeLogic(currentPlayerCiv, otherCiv)
|
||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer("Peace Treaty", TradeType.Treaty, 20))
|
||||
tradeLogic.currentTrade.theirOffers.add(TradeOffer("Peace Treaty", TradeType.Treaty, 20))
|
||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty, 30))
|
||||
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty, 30))
|
||||
tradeLogic.acceptTrade()
|
||||
updateLeftSideTable()
|
||||
}, this)
|
||||
|
@ -144,11 +145,25 @@ class DiplomacyScreen:CameraStageBaseScreen() {
|
|||
diplomacyTable.add(otherCiv.getNation().getLeaderDisplayName().toLabel())
|
||||
diplomacyTable.addSeparator()
|
||||
|
||||
val tradeButton = TextButton("Trade".tr(), skin)
|
||||
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()
|
||||
if(!currentPlayerCiv.isAtWarWith(otherCiv)) {
|
||||
val tradeButton = TextButton("Trade".tr(), skin)
|
||||
tradeButton.onClick { setTrade(otherCiv) }
|
||||
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)
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.unciv.ui.trade
|
|||
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.unciv.Constants
|
||||
import com.unciv.logic.trade.TradeOffer
|
||||
import com.unciv.logic.trade.TradeOffersList
|
||||
import com.unciv.logic.trade.TradeType
|
||||
|
@ -52,7 +53,7 @@ class OffersListScroll(val onOfferClicked: (TradeOffer) -> Unit) : ScrollPane(nu
|
|||
val amountPerClick =
|
||||
if (offer.type == Gold) 50
|
||||
else 1
|
||||
if (offer.amount > 0)
|
||||
if (offer.amount > 0 && offer.name != Constants.peaceTreaty) // can't disable peace treaty!
|
||||
tradeButton.onClick {
|
||||
val amountTransferred = min(amountPerClick, offer.amount)
|
||||
onOfferClicked(offer.copy(amount = amountTransferred))
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.unciv.ui.worldscreen
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.unciv.Constants
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomacyFlags
|
||||
import com.unciv.logic.trade.TradeLogic
|
||||
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 })
|
||||
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)
|
||||
|
||||
remove()
|
||||
|
|
Loading…
Reference in a new issue