Skip to content

Commit 52b23c4

Browse files
authored
fix: fix default faction dispositions not being applied (#710)
1 parent f68940d commit 52b23c4

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

engine/src/main/java/org/destinationsol/game/FactionManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public boolean areEnemies(SolShip s1, SolShip s2) {
217217
* @return true, if f1 and f2 are enemies, otherwise false.
218218
*/
219219
public boolean areEnemies(Faction f1, Faction f2) {
220-
return f1 != null && f2 != null && f1.getRelation(f2) < 0;
220+
return f1 != null && f2 != null && (f1.getRelation(f2) < 0 || f2.getRelation(f1) < 0);
221221
}
222222

223223
private static class MyRayBack implements RayCastCallback {

engine/src/main/java/org/destinationsol/game/faction/FactionsConfigs.java

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)