mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-21 21:30:20 +07:00
AI now waits a certain number of turns between offering the same trade again - 20 turns for luxury exchange, 5 turns for peace
This commit is contained in:
@ -149,7 +149,8 @@ class NextTurnAutomation{
|
||||
// We should A. add some sort of timer (20? 30 turns?) between luxury trade requests if they're denied
|
||||
// B. have a way for the AI to keep track of the "pending offers" - see DiplomacyManager.resourcesFromTrade
|
||||
|
||||
for (otherCiv in knownCivs.filter { it.isPlayerCivilization() && !it.isAtWarWith(civInfo) }) {
|
||||
for (otherCiv in knownCivs.filter { it.isPlayerCivilization() && !it.isAtWarWith(civInfo)
|
||||
&& !civInfo.diplomacy[it.civName]!!.flagsCountdown.containsKey("DeclinedLuxExchange")}) {
|
||||
val trades = potentialLuxuryTrades(civInfo,otherCiv)
|
||||
for(trade in trades){
|
||||
val tradeRequest = TradeRequest(civInfo.civName, trade.reverse())
|
||||
@ -177,12 +178,14 @@ class NextTurnAutomation{
|
||||
|
||||
private fun offerPeaceTreaty(civInfo: CivilizationInfo) {
|
||||
if (civInfo.cities.isNotEmpty() && civInfo.diplomacy.isNotEmpty()) {
|
||||
val ourMilitaryUnits = civInfo.getCivUnits().filter { !it.type.isCivilian() }.size
|
||||
|
||||
val ourCombatStrength = Automation().evaluteCombatStrength(civInfo)
|
||||
if (civInfo.isAtWar()) { //evaluate peace
|
||||
val enemiesCiv = civInfo.diplomacy.filter{ it.value.diplomaticStatus == DiplomaticStatus.War }
|
||||
.map{ it.value.otherCiv() }
|
||||
.filterNot{ it == civInfo || it.isBarbarianCivilization() || it.cities.isEmpty() }
|
||||
.filter { !civInfo.diplomacy[it.civName]!!.flagsCountdown.containsKey("DeclinedPeace") }
|
||||
|
||||
for (enemy in enemiesCiv) {
|
||||
val enemiesStrength = Automation().evaluteCombatStrength(enemy)
|
||||
if (enemiesStrength < ourCombatStrength * 2) {
|
||||
|
@ -2,6 +2,7 @@ package com.unciv.ui.worldscreen
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.unciv.logic.trade.TradeLogic
|
||||
import com.unciv.logic.trade.TradeType
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.ui.trade.DiplomacyScreen
|
||||
import com.unciv.ui.utils.addSeparator
|
||||
@ -55,6 +56,13 @@ class TradePopup(worldScreen: WorldScreen): PopupTable(worldScreen){
|
||||
}
|
||||
addButton("Not this time.".tr()){
|
||||
currentPlayerCiv.tradeRequests.remove(tradeRequest)
|
||||
|
||||
if(trade.ourOffers.all { it.type==TradeType.Luxury_Resource } && trade.theirOffers.all { it.type==TradeType.Luxury_Resource })
|
||||
requestingCiv.diplomacy[currentPlayerCiv.civName]!!.flagsCountdown["DeclinedLuxExchange"]=20 // offer again in 20 turns
|
||||
|
||||
if(trade.ourOffers.any{ it.type==TradeType.Treaty && it.name=="Peace Treaty" })
|
||||
requestingCiv.diplomacy[currentPlayerCiv.civName]!!.flagsCountdown["DeclinedPeace"]=5 // offer again in 20 turns
|
||||
|
||||
remove()
|
||||
worldScreen.shouldUpdate=true
|
||||
}
|
||||
|
Reference in New Issue
Block a user