Skip to content

Commit

Permalink
Fix failing unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tkael committed May 28, 2024
1 parent 4602aa8 commit 116e6b4
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions JournalMonitor/JournalMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5232,30 +5232,40 @@ private static Faction GetFaction(IDictionary<string, object> data, string type,
};
faction.presences.Add( factionPresense );
}
}

// Since systems can have Thargoid allegiance, treat Thargoids like a faction for the purpose of
// allegiance and government (even when no human faction exists).

// Get the faction allegiance
if ( data.TryGetValue( type + "Allegiance", out _ ) )
// Get the faction allegiance
if ( data.TryGetValue( type + "Allegiance", out _ ) )
{
if ( faction is null ) { faction = new Faction(); }
faction.Allegiance = GetAllegiance( data, type + "Allegiance" );
if ( string.IsNullOrEmpty( faction.name ) && faction.Allegiance != null )
{
faction.Allegiance = GetAllegiance( data, type + "Allegiance" );
faction.name = faction.Allegiance.localizedName;
}
else if ( data.TryGetValue( "Factions", out var val ) )
}
else if ( data.TryGetValue( "Factions", out var val ) && val is List<object> factionsList )
{
// Station controlling faction government is not discretely available in 'Location' event
if ( faction is null ) { faction = new Faction(); }
foreach ( IDictionary<string, object> factionDetail in factionsList )
{
// Station controlling faction government not discretely available in 'Location' event
if ( val is List<object> factionsList )
string fName = JsonParsing.getString( factionDetail, "Name" );
if ( fName == faction.name )
{
foreach ( IDictionary<string, object> factionDetail in factionsList )
{
string fName = JsonParsing.getString( factionDetail, "Name" );
if ( fName == faction.name )
{
faction.Allegiance = GetAllegiance( factionDetail, "Allegiance" );
break;
}
}
faction.Allegiance = GetAllegiance( factionDetail, "Allegiance" );
break;
}
}
}

// Get the controlling faction (system or station) government
// Get the controlling faction (system or station) government
if ( data.TryGetValue( type + "Government", out _ ) )
{
if ( faction is null ) { faction = new Faction(); }
faction.Government = Government.FromEDName( JsonParsing.getString( data, type + "Government" ) ) ?? Government.None;
}

Expand Down

0 comments on commit 116e6b4

Please sign in to comment.