Cannot trade screen for civs you're at war with through notification action

This commit is contained in:
yairm210 2024-04-08 17:56:41 +03:00
parent 7dfa6682e0
commit 2251bf7595

View File

@ -83,16 +83,21 @@ class DiplomacyAction(
private var showTrade: Boolean = false
) : NotificationAction {
override fun execute(worldScreen: WorldScreen) {
val currentCiv = worldScreen.selectedCiv
val otherCiv = worldScreen.gameInfo.getCivilization(otherCivName)
if (showTrade && otherCiv == worldScreen.gameInfo.getCurrentPlayerCivilization())
if (showTrade && otherCiv == currentCiv)
// Because TradeTable will set up otherCiv against that one,
// not the one we pass below, and two equal civs will crash - can't look up a DiplomacyManager.
return
// We should not be able to trade with city-states
if (showTrade && (otherCiv.isCityState() || worldScreen.gameInfo.getCurrentPlayerCivilization().isCityState()))
if (showTrade && (otherCiv.isCityState() || currentCiv.isCityState()))
showTrade = false
if (showTrade && currentCiv.isAtWarWith(otherCiv))
showTrade = false // Can't trade right now
worldScreen.game.pushScreen(DiplomacyScreen(worldScreen.selectedCiv, otherCiv, showTrade = showTrade))
worldScreen.game.pushScreen(DiplomacyScreen(currentCiv, otherCiv, showTrade = showTrade))
}
}