@@ -60,8 +60,34 @@ public FactionsConfigs(AssetHelper assetHelper) {
6060 for (Map .Entry <ResourceUrn , Integer > factionRelation : factionRelations .getValue ().entrySet ()) {
6161 Faction otherFaction = factionConfigs .get (factionRelation .getKey ());
6262 faction .setRelation (otherFaction , factionRelation .getValue ());
63- if (!otherFaction .isAwareOf (faction )) {
64- otherFaction .setRelation (faction , factionRelation .getValue ());
63+ }
64+ }
65+
66+ for (Faction faction : factionConfigs .values ()) {
67+ for (Faction otherFaction : factionConfigs .values ()) {
68+ if (faction .isAwareOf (otherFaction ) && otherFaction .isAwareOf (faction )) {
69+ // Asymmetric relationships are explicitly allowed.
70+ continue ;
71+ }
72+
73+ if (faction .isAwareOf (otherFaction ) && !otherFaction .isAwareOf (faction )) {
74+ otherFaction .setRelation (faction , faction .getRelation (otherFaction ));
75+ } else if (!faction .isAwareOf (otherFaction ) && otherFaction .isAwareOf (faction )) {
76+ faction .setRelation (otherFaction , otherFaction .getRelation (faction ));
77+ } else {
78+ int factionRelation = faction .getRelation (otherFaction );
79+ int otherFactionRelation = otherFaction .getRelation (faction );
80+
81+ // The simplified rules of uncertain Destination Sol diplomacy:
82+ // - If both are friendly, the stronger positivity will prevail.
83+ // - If both are hostile, the stronger hostility will prevail.
84+ // - If your enemy is hostile to you, you must be hostile to your enemy.
85+ // - Neutrality is considered friendly.
86+ int relation = (factionRelation >= 0 && otherFactionRelation >= 0 ) ?
87+ Math .max (factionRelation , otherFactionRelation ) :
88+ Math .min (factionRelation , otherFactionRelation );
89+ faction .setRelation (otherFaction , relation );
90+ otherFaction .setRelation (faction , relation );
6591 }
6692 }
6793 }
0 commit comments