mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-12 03:48:16 +07:00
Removed edge case option where the AI can trade you all of their cities
This commit is contained in:
parent
1f52a8ad88
commit
98a79f8fb4
@ -43,19 +43,24 @@ class TradeEvaluation{
|
||||
}
|
||||
|
||||
fun isTradeAcceptable(trade: Trade, evaluator: CivilizationInfo, tradePartner: CivilizationInfo): Boolean {
|
||||
// Edge case time! Guess what happens if you offer a peace agreement to the AI for all their cities except for the capital,
|
||||
// and then capture their capital THAT SAME TURN? It can agree, leading to the civilization getting instantly destroyed!
|
||||
if (trade.ourOffers.count { it.type == TradeType.City } == evaluator.cities.size)
|
||||
return false
|
||||
|
||||
var sumOfTheirOffers = trade.theirOffers.asSequence()
|
||||
.filter { it.type!= TradeType.Treaty } // since treaties should only be evaluated once for 2 sides
|
||||
.map { evaluateBuyCost(it,evaluator,tradePartner) }.sum()
|
||||
.filter { it.type != TradeType.Treaty } // since treaties should only be evaluated once for 2 sides
|
||||
.map { evaluateBuyCost(it, evaluator, tradePartner) }.sum()
|
||||
|
||||
// If we're making a peace treaty, don't try to up the bargain for people you don't like.
|
||||
// Leads to spartan behaviour where you demand more, the more you hate the enemy...unhelpful
|
||||
if(trade.ourOffers.none { it.name==Constants.peaceTreaty || it.name==Constants.researchAgreement }) {
|
||||
if (trade.ourOffers.none { it.name == Constants.peaceTreaty || it.name == Constants.researchAgreement }) {
|
||||
val relationshipLevel = evaluator.getDiplomacyManager(tradePartner).relationshipLevel()
|
||||
if (relationshipLevel == RelationshipLevel.Enemy) sumOfTheirOffers = (sumOfTheirOffers * 1.5).toInt()
|
||||
else if (relationshipLevel == RelationshipLevel.Unforgivable) sumOfTheirOffers *= 2
|
||||
}
|
||||
|
||||
val sumOfOurOffers = trade.ourOffers.map { evaluateSellCost(it, evaluator, tradePartner)}.sum()
|
||||
val sumOfOurOffers = trade.ourOffers.map { evaluateSellCost(it, evaluator, tradePartner) }.sum()
|
||||
return sumOfOurOffers <= sumOfTheirOffers
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user