Added "relationship" dependant on the modifiers - this will be the main way we apply user actions to AI consequences

This commit is contained in:
Yair Morgenstern 2019-05-01 00:13:41 +03:00
parent 5952056518
commit b4fc129a9b
2 changed files with 23 additions and 1 deletions

View File

@ -11,6 +11,16 @@ import com.unciv.models.gamebasics.GameBasics
import com.unciv.models.gamebasics.tile.TileResource
import com.unciv.models.gamebasics.tr
enum class RelationshipLevel{
Unforgivable,
Enemy,
Competitor,
Neutral,
Favorable,
Friend,
Ally
}
enum class DiplomacyFlags{
DeclinedLuxExchange,
DeclinedPeace
@ -75,6 +85,17 @@ class DiplomacyManager() {
fun opinionOfOtherCiv() = diplomaticModifiers.values.sum()
fun relationshipLevel(): RelationshipLevel {
val opinion = opinionOfOtherCiv()
if(opinion>80) return RelationshipLevel.Ally
if(opinion>40) return RelationshipLevel.Friend
if(opinion>15) return RelationshipLevel.Favorable
if(opinion<-80) return RelationshipLevel.Unforgivable
if(opinion<-40) return RelationshipLevel.Enemy
if(opinion<-15) return RelationshipLevel.Competitor
return RelationshipLevel.Neutral
}
fun canDeclareWar() = (turnsToPeaceTreaty()==0 && diplomaticStatus != DiplomaticStatus.War)

View File

@ -116,7 +116,8 @@ class DiplomacyScreen:CameraStageBaseScreen() {
if(!otherCiv.isCityState()){
val diplomacyModifiersTable = Table()
val otherCivDiplomacyManager = otherCiv.getDiplomacyManager(currentPlayerCiv)
diplomacyModifiersTable.add(("Current opinion: "+otherCivDiplomacyManager.opinionOfOtherCiv()).toLabel()).row()
val relationshipText = "Our relationship: "+otherCivDiplomacyManager.relationshipLevel()+" ("+otherCivDiplomacyManager.opinionOfOtherCiv()+")"
diplomacyModifiersTable.add(relationshipText.toLabel()).row()
for(modifier in otherCivDiplomacyManager.diplomaticModifiers){
diplomacyModifiersTable.add((modifier.key+" "+modifier.value).toLabel()).row()
}