From cee834b062cb4573658555a030753d2516c082c3 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Wed, 29 Apr 2020 19:02:18 +0300 Subject: [PATCH] AI war motivation taked relationship level into account --- .../logic/automation/NextTurnAutomation.kt | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/logic/automation/NextTurnAutomation.kt b/core/src/com/unciv/logic/automation/NextTurnAutomation.kt index 63fb8cf9c1..cea5c8f55a 100644 --- a/core/src/com/unciv/logic/automation/NextTurnAutomation.kt +++ b/core/src/com/unciv/logic/automation/NextTurnAutomation.kt @@ -413,6 +413,7 @@ object NextTurnAutomation{ val combatStrengthRatio = ourCombatStrength / theirCombatStrength val combatStrengthModifier = when { combatStrengthRatio > 3f -> 30 + combatStrengthRatio > 2.5f -> 25 combatStrengthRatio > 2f -> 20 combatStrengthRatio > 1.5f -> 10 else -> 0 @@ -436,10 +437,23 @@ object NextTurnAutomation{ if (!landPathBFS.hasReachedTile(theirCity.getCenterTile())) modifierMap["No land path"] = -10 - if(civInfo.getDiplomacyManager(otherCiv).hasFlag(DiplomacyFlags.ResearchAgreement)) + val diplomacyManager = civInfo.getDiplomacyManager(otherCiv) + if(diplomacyManager.hasFlag(DiplomacyFlags.ResearchAgreement)) modifierMap["Research Agreement"] = -5 - if(civInfo.getDiplomacyManager(otherCiv).resourcesFromTrade().any { it.amount > 0 }) + if(diplomacyManager.hasFlag(DiplomacyFlags.DeclarationOfFriendship)) + modifierMap["Declaration of Friendship"] = -10 + + val relationshipModifier = when(diplomacyManager.relationshipLevel()){ + RelationshipLevel.Unforgivable -> 10 + RelationshipLevel.Enemy -> 5 + RelationshipLevel.Ally -> -5 // this is so that ally + DoF is not too unbalanced - + // still possible for AI to declare war for isolated city + else -> 0 + } + modifierMap["Relationship"] = relationshipModifier + + if(diplomacyManager.resourcesFromTrade().any { it.amount > 0 }) modifierMap["Receiving trade resources"] = -5 if(theirCity.getTiles().none { it.neighbors.any { it.getOwner()==theirCity.civInfo && it.getCity() != theirCity } })