From 39e5d0df0f2de35a3538f1d3ab1a56c4490cf6e2 Mon Sep 17 00:00:00 2001 From: AcridBrimistic Date: Tue, 19 May 2020 21:28:32 +0300 Subject: [PATCH] relationshipLevel() clean-up (#2627) * Diplomacy Clean-up * Better formatting * Quickfix * Fix counterpoint --- .../diplomacy/DiplomacyManager.kt | 37 ++++++++----------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt index b59ab7a3aa..3e55997041 100644 --- a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt +++ b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt @@ -136,15 +136,12 @@ class DiplomacyManager() { if(civInfo.isPlayerCivilization()) return otherCiv().getDiplomacyManager(civInfo).relationshipLevel() - if(civInfo.isCityState()){ - if (influence<=-60) return RelationshipLevel.Unforgivable - if (influence<=-30) return RelationshipLevel.Enemy + if(civInfo.isCityState()) { + if(influence <= -60) return RelationshipLevel.Unforgivable + if(influence <= -30 || civInfo.isAtWarWith(otherCiv())) return RelationshipLevel.Enemy - if(civInfo.isAtWarWith(otherCiv())) - return RelationshipLevel.Enemy // See below, same with major civs - - if(influence>=60) return RelationshipLevel.Ally - if(influence>=30) return RelationshipLevel.Friend + if(influence >= 60) return RelationshipLevel.Ally + if(influence >= 30) return RelationshipLevel.Friend return RelationshipLevel.Neutral } @@ -152,19 +149,16 @@ class DiplomacyManager() { // maybe we need to average their views of each other? That makes sense to me. val opinion = opinionOfOtherCiv() - if(opinion<=-80) return RelationshipLevel.Unforgivable - if(opinion<=-40) return RelationshipLevel.Enemy - - // This is here because when you're at war you can either be enemy OR unforgivable, - // depending on the opinion - if(civInfo.isAtWarWith(otherCiv())) - return RelationshipLevel.Enemy - - if(opinion<=-15) return RelationshipLevel.Competitor - if(opinion>=80) return RelationshipLevel.Ally - if(opinion>=40) return RelationshipLevel.Friend - if(opinion>=15) return RelationshipLevel.Favorable - return RelationshipLevel.Neutral + return when { + opinion <= -80 -> RelationshipLevel.Unforgivable + opinion <= -40 || civInfo.isAtWarWith(otherCiv()) -> RelationshipLevel.Enemy /* During wartime, the estimation in which you are held may be enemy OR unforgivable */ + opinion <= -15 -> RelationshipLevel.Competitor + + opinion >= 80 -> RelationshipLevel.Ally + opinion >= 40 -> RelationshipLevel.Friend + opinion >= 15 -> RelationshipLevel.Favorable + else -> RelationshipLevel.Neutral + } } /** Returns the number of turns to degrade from Ally or from Friend */ @@ -233,7 +227,6 @@ class DiplomacyManager() { fun getCommonKnownCivs(): Set = civInfo.getKnownCivs().intersect(otherCiv().getKnownCivs()) /** Returns true when the [civInfo]'s territory is considered allied for [otherCiv]. - * * This includes friendly and allied city-states and the open border treaties. */ fun isConsideredFriendlyTerritory(): Boolean {