mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-20 20:59:18 +07:00
Fixed denouncement effects on third-party civs, and trade evaluation for enemy trades - kudos @Chek
This commit is contained in:
@ -656,11 +656,12 @@ class DiplomacyManager() {
|
|||||||
getCommonKnownCivs().filter { it.isMajorCiv() }.forEach { thirdCiv ->
|
getCommonKnownCivs().filter { it.isMajorCiv() }.forEach { thirdCiv ->
|
||||||
thirdCiv.addNotification("[${civInfo.civName}] has denounced [$otherCivName]!", civInfo.civName, NotificationIcon.Diplomacy, otherCivName)
|
thirdCiv.addNotification("[${civInfo.civName}] has denounced [$otherCivName]!", civInfo.civName, NotificationIcon.Diplomacy, otherCivName)
|
||||||
val thirdCivRelationshipWithOtherCiv = thirdCiv.getDiplomacyManager(otherCiv()).relationshipLevel()
|
val thirdCivRelationshipWithOtherCiv = thirdCiv.getDiplomacyManager(otherCiv()).relationshipLevel()
|
||||||
|
val thirdCivDiplomacyManager = civInfo.getDiplomacyManager(thirdCiv)
|
||||||
when (thirdCivRelationshipWithOtherCiv) {
|
when (thirdCivRelationshipWithOtherCiv) {
|
||||||
RelationshipLevel.Unforgivable -> addModifier(DiplomaticModifiers.DenouncedOurEnemies, 15f)
|
RelationshipLevel.Unforgivable -> thirdCivDiplomacyManager.addModifier(DiplomaticModifiers.DenouncedOurEnemies, 15f)
|
||||||
RelationshipLevel.Enemy -> addModifier(DiplomaticModifiers.DenouncedOurEnemies, 5f)
|
RelationshipLevel.Enemy -> thirdCivDiplomacyManager.addModifier(DiplomaticModifiers.DenouncedOurEnemies, 5f)
|
||||||
RelationshipLevel.Friend -> addModifier(DiplomaticModifiers.DenouncedOurAllies, -5f)
|
RelationshipLevel.Friend -> thirdCivDiplomacyManager.addModifier(DiplomaticModifiers.DenouncedOurAllies, -5f)
|
||||||
RelationshipLevel.Ally -> addModifier(DiplomaticModifiers.DenouncedOurAllies, -15f)
|
RelationshipLevel.Ally -> thirdCivDiplomacyManager.addModifier(DiplomaticModifiers.DenouncedOurAllies, -15f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,19 +50,20 @@ class TradeEvaluation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun isTradeAcceptable(trade: Trade, evaluator: CivilizationInfo, tradePartner: CivilizationInfo): Boolean {
|
fun isTradeAcceptable(trade: Trade, evaluator: CivilizationInfo, tradePartner: CivilizationInfo): Boolean {
|
||||||
var sumOfTheirOffers = trade.theirOffers.asSequence()
|
val sumOfTheirOffers = trade.theirOffers.asSequence()
|
||||||
.filter { it.type != TradeType.Treaty } // since treaties should only be evaluated once for 2 sides
|
.filter { it.type != TradeType.Treaty } // since treaties should only be evaluated once for 2 sides
|
||||||
.map { evaluateBuyCost(it, evaluator, tradePartner) }.sum()
|
.map { evaluateBuyCost(it, evaluator, tradePartner) }.sum()
|
||||||
|
|
||||||
|
var sumOfOurOffers = trade.ourOffers.map { evaluateSellCost(it, evaluator, tradePartner) }.sum()
|
||||||
|
|
||||||
// If we're making a peace treaty, don't try to up the bargain for people you don't like.
|
// 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
|
// 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()
|
val relationshipLevel = evaluator.getDiplomacyManager(tradePartner).relationshipLevel()
|
||||||
if (relationshipLevel == RelationshipLevel.Enemy) sumOfTheirOffers = (sumOfTheirOffers * 1.5).toInt()
|
if (relationshipLevel == RelationshipLevel.Enemy) sumOfOurOffers = (sumOfOurOffers * 1.5).toInt()
|
||||||
else if (relationshipLevel == RelationshipLevel.Unforgivable) sumOfTheirOffers *= 2
|
else if (relationshipLevel == RelationshipLevel.Unforgivable) sumOfOurOffers *= 2
|
||||||
}
|
}
|
||||||
|
|
||||||
val sumOfOurOffers = trade.ourOffers.map { evaluateSellCost(it, evaluator, tradePartner) }.sum()
|
|
||||||
return sumOfOurOffers <= sumOfTheirOffers
|
return sumOfOurOffers <= sumOfTheirOffers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user