Resolved #1457 - no AI trades are 'automatically accepted', they all require an active decision of the proposed side and will only happen on their turn
This commit is contained in:
parent
f6b8afc952
commit
eb1ce0f6cb
3 changed files with 20 additions and 40 deletions
|
@ -125,7 +125,7 @@
|
|||
],
|
||||
[
|
||||
"There are three ways to win in Unciv. They are:",
|
||||
" - Cultural Victory: Complete 4 Social Policy Trees",
|
||||
" - Cultural Victory: Complete 5 Social Policy Trees",
|
||||
" - Domination Victory: Survive as the last civilization",
|
||||
" - Science Victory: Be the first to construct a spaceship to Alpha Centauri"
|
||||
],
|
||||
|
|
|
@ -125,7 +125,7 @@ class NextTurnAutomation{
|
|||
private fun exchangeTechs(civInfo: CivilizationInfo) {
|
||||
if(!civInfo.gameInfo.getDifficulty().aisExchangeTechs) return
|
||||
val otherCivList = civInfo.getKnownCivs()
|
||||
.filter { it.playerType == PlayerType.AI && it.isMajorCiv() }
|
||||
.filter { it.playerType == PlayerType.AI && it.isMajorCiv() && !civInfo.isAtWarWith(it) }
|
||||
.sortedBy { it.tech.techsResearched.size }
|
||||
|
||||
for (otherCiv in otherCivList) {
|
||||
|
@ -145,19 +145,17 @@ class NextTurnAutomation{
|
|||
if (ourOfferList.isNotEmpty()) {
|
||||
tradeLogic.currentTrade.ourOffers.add(ourOfferList.random())
|
||||
tradeLogic.currentTrade.theirOffers.add(theirOffer)
|
||||
} else {
|
||||
} else if (ourGold / 2 >= theirValue) {
|
||||
//try to buy tech with money, not spending more than 1/3 of treasury
|
||||
if (ourGold / 2 >= theirValue)
|
||||
{
|
||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer("Gold".tr(), TradeType.Gold, 0, theirValue))
|
||||
tradeLogic.currentTrade.theirOffers.add(theirOffer)
|
||||
ourGold -= theirValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tradeLogic.currentTrade.theirOffers.isNotEmpty()) {
|
||||
tradeLogic.acceptTrade()
|
||||
val tradeRequest = TradeRequest(civInfo.civName, tradeLogic.currentTrade.reverse())
|
||||
otherCiv.tradeRequests.add(tradeRequest)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -266,10 +264,10 @@ class NextTurnAutomation{
|
|||
// When the AI offers a trade, it's not immediately accepted,
|
||||
// so what if it thinks that it has a spare luxury and offers it to two human players?
|
||||
// What's to stop the AI "nagging" the player to accept a luxury trade?
|
||||
// We should A. add some sort of timer (20? 30 turns?) between luxury trade requests if they're denied
|
||||
// We should A. add some sort of timer (20? 30 turns?) between luxury trade requests if they're denied - see DeclinedLuxExchange
|
||||
// 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.isMajorCiv() && !it.isAtWarWith(civInfo)
|
||||
&& !civInfo.getDiplomacyManager(it).hasFlag(DiplomacyFlags.DeclinedLuxExchange)}) {
|
||||
|
||||
val relationshipLevel = civInfo.getDiplomacyManager(otherCiv).relationshipLevel()
|
||||
|
@ -283,18 +281,6 @@ class NextTurnAutomation{
|
|||
}
|
||||
}
|
||||
|
||||
// AI luxury trades are automatically accepted
|
||||
for (otherCiv in knownCivs.filter { !it.isPlayerCivilization() && !it.isAtWarWith(civInfo) }) {
|
||||
val trades = potentialLuxuryTrades(civInfo,otherCiv)
|
||||
for(trade in trades){
|
||||
val tradeLogic = TradeLogic(civInfo,otherCiv)
|
||||
tradeLogic.currentTrade.ourOffers.addAll(trade.ourOffers)
|
||||
tradeLogic.currentTrade.theirOffers.addAll(trade.theirOffers)
|
||||
tradeLogic.acceptTrade()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
fun getMinDistanceBetweenCities(civ1: CivilizationInfo, civ2: CivilizationInfo): Int {
|
||||
|
@ -381,24 +367,17 @@ class NextTurnAutomation{
|
|||
tradeLogic.currentTrade.ourOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty, 30))
|
||||
tradeLogic.currentTrade.theirOffers.add(TradeOffer(Constants.peaceTreaty, TradeType.Treaty, 30))
|
||||
|
||||
if(civInfo.gold>0) {
|
||||
var moneyWeNeedToPay = -TradeEvaluation().evaluatePeaceCostForThem(civInfo, enemy)
|
||||
if (moneyWeNeedToPay > 0) {
|
||||
if (moneyWeNeedToPay > civInfo.gold && civInfo.gold > 0) { // we need to make up for this somehow...
|
||||
if (moneyWeNeedToPay > civInfo.gold) { // we need to make up for this somehow...
|
||||
moneyWeNeedToPay = civInfo.gold
|
||||
}
|
||||
if (civInfo.gold > 0) tradeLogic.currentTrade.ourOffers.add(TradeOffer("Gold".tr(), TradeType.Gold, 0, moneyWeNeedToPay))
|
||||
if (moneyWeNeedToPay > 0) {
|
||||
tradeLogic.currentTrade.ourOffers.add(TradeOffer("Gold".tr(), TradeType.Gold, 0, moneyWeNeedToPay))
|
||||
}
|
||||
}
|
||||
|
||||
if (enemy.isPlayerCivilization())
|
||||
enemy.tradeRequests.add(TradeRequest(civInfo.civName, tradeLogic.currentTrade.reverse()))
|
||||
else {
|
||||
if (enemy.victoryType()!=VictoryType.Cultural
|
||||
&& enemy.getCivUnits().filter { !it.type.isCivilian() }.count() > enemy.cities.size
|
||||
&& enemy.getHappiness() > 0) {
|
||||
continue //enemy AI has too large army and happiness. It continues to fight for profit.
|
||||
}
|
||||
tradeLogic.acceptTrade()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,8 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
|||
else buildableBuildings += productionTextButton
|
||||
}
|
||||
|
||||
for (specialConstruction in SpecialConstruction.getSpecialConstructions().filter { it.shouldBeDisplayed(cityConstructions) }) {
|
||||
for (specialConstruction in SpecialConstruction.getSpecialConstructions()
|
||||
.filter { it.shouldBeDisplayed(cityConstructions) }) {
|
||||
specialConstructions += getProductionButton(specialConstruction.name,
|
||||
"Produce [${specialConstruction.name}]".tr())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue