Compare commits

..

No commits in common. "f499d7763b8d9e7703751d521f543aa8556b3ecb" and "a11d3d10aa38d7104554b88c7c9b09409e1e663d" have entirely different histories.

6 changed files with 14 additions and 970 deletions

View File

@ -5,6 +5,7 @@ namespace EliteBGS.BGS {
public class MissionCompleted : LogEntry {
public MissionCompleted(MissionCompletedEntry e) {
Entries.Add(e);
Faction = e.JSON.GetValue("Faction").ToString();
}
public string MissionName {

View File

@ -28,7 +28,7 @@ namespace EliteBGS.BGS {
return added;
}
public static bool IsRelevant(Entry e) {
private bool IsRelevant(Entry e) {
return e.Is(Events.CommitCrime) ||
e.Is(Events.Docked) ||
e.Is(Events.FactionKillBond) ||
@ -67,17 +67,12 @@ namespace EliteBGS.BGS {
.ToList()
;
Dictionary<ulong, MissionAcceptedEntry> acceptedMissions = new Dictionary<ulong, MissionAcceptedEntry>();
Dictionary<int, MissionAcceptedEntry> acceptedMissions = new Dictionary<int, MissionAcceptedEntry>();
Dictionary<string, long> buyCost = new Dictionary<string, long>();
Dictionary<ulong, string> systems = new Dictionary<ulong, string>();
Dictionary<string, string> npcfactions = new Dictionary<string, string>();
Dictionary<string, List<Faction>> system_factions = new Dictionary<string, List<Faction>>();
// A dictionary resolving to a station at which each mission was accepted
Dictionary<ulong, string> acceptedStations = new Dictionary<ulong, string>();
// A dictionary resolving to a system at which each mission was accepted
Dictionary<ulong, ulong> acceptedSystems = new Dictionary<ulong, ulong>();
string current_system = null;
ulong current_system_address = 0;
string current_station = null;
@ -182,18 +177,12 @@ namespace EliteBGS.BGS {
});
collate = true;
} else if (e.Is(Events.MissionCompleted)) {
MissionCompletedEntry completed = e as MissionCompletedEntry;
MissionAcceptedEntry accepted;
if (!acceptedMissions.TryGetValue(completed.MissionID, out accepted)) {
OnLog?.Invoke(string.Format(
"Unable to find mission acceptance for mission \"{0}\". " +
"Please extend range to include the mission acceptance.", completed.HumanReadableName
));
continue;
}
string mission_giver = completed.Faction;
var completed = e as MissionCompletedEntry;
results.Add(new MissionCompleted(completed) {
System = current_system,
Station = current_station,
SystemAddress = current_system_address,
});
if (completed.HumanReadableNameWasGenerated) {
/* If the human readable name was generated, we send a log message. Because the
* generated names all sort of suck, we should have more human readable names in
@ -211,51 +200,9 @@ namespace EliteBGS.BGS {
}
foreach (var influences in other.Value) {
ulong system_address = influences.Key;
ulong accepted_address = 0;
string system, accepted_station, accepted_system;
if (!systems.TryGetValue(system_address, out system)) {
OnLog?.Invoke(string.Format(
"Unknown system system \"{0}\" unable to assign that mission a target.", system_address
));
continue;
}
if (!acceptedSystems.TryGetValue(completed.MissionID, out accepted_address)) {
OnLog?.Invoke(string.Format(
"Unable to figure out in which system mission \"{0}\" was accepted.", system_address
));
continue;
}
if (!systems.TryGetValue(accepted_address, out accepted_system)) {
OnLog?.Invoke(string.Format(
"Unable to figure out in which system mission \"{0}\" was accepted.", system_address
));
continue;
}
if (!acceptedStations.TryGetValue(completed.MissionID, out accepted_station)) {
OnLog?.Invoke(string.Format(
"Unable to figure out in which station mission \"{0}\" was accepted.", system_address
));
continue;
}
if (faction.Equals(mission_giver) && system_address == accepted_address) {
/* This is the influence block for the origin of the mission.
*/
results.Add(new MissionCompleted(completed) {
System = accepted_system,
Faction = mission_giver,
SystemAddress = accepted_address,
Station = accepted_station,
});
} else if (!faction.Equals(results[0].Faction) ||
(faction.Equals(results[0].Faction) && system_address != accepted_address)) {
/* This block is for secondary factions (first if), or if the secondary faction
* is the same as the mission giver, but in another system (second if).
*/
if (!faction.Equals(results[0].Faction) ||
(faction.Equals(results[0].Faction) && system_address != current_system_address)) {
string system = systems.TryGetValue(system_address, out string sys) ? sys : "";
results.Add(new InfluenceSupport() {
Faction = faction,
Influence = influences.Value,
@ -268,16 +215,7 @@ namespace EliteBGS.BGS {
}
} else if (e.Is(Events.MissionAccepted)) {
MissionAcceptedEntry accepted = e as MissionAcceptedEntry;
ulong id = accepted.MissionID;
if (!acceptedMissions.ContainsKey(id)) {
acceptedMissions[id] = accepted;
}
if (!acceptedStations.ContainsKey(id)) {
acceptedStations[id] = current_station;
}
if (!acceptedSystems.ContainsKey(id)) {
acceptedSystems[id] = current_system_address;
}
acceptedMissions[accepted.MissionID] = accepted;
} else if (e.Is(Events.MissionFailed)) {
var failed = e as MissionFailedEntry;
MissionAcceptedEntry accepted = null;

View File

@ -202,7 +202,6 @@
<Content Include="main-objectives.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="TestData\DoubleSupport.txt" />
<None Include="TestData\MurderOtherThanControllingFaction.txt" />
<None Include="TestData\TestMurder.txt" />
<None Include="TestData\SellOrganicData.txt" />

View File

@ -28,13 +28,11 @@
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button x:Name="Load" Content="Load Entries" Grid.Row="0" Margin="5,5,5,5" Height="Auto" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Click="Load_Click" />
<Button x:Name="LoadFile" Content="Load File" Grid.Row="0" Margin="5,5,5,5" Height="Auto" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" Click="LoadFile_Click" />
<Button x:Name="DeleteUnimportant" Content="Remove Unimportant" Grid.Row="0" Margin="5,5,5,5" Height="Auto" Grid.Column="3" HorizontalAlignment="Center" VerticalAlignment="Center" Click="DeleteUnimportant_Click" />
<Button x:Name="Clear" Content="Clear" Grid.Row="0" Height="Auto" Margin="5,5,5,5" Grid.Column="4" Click="Clear_Click" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<Button x:Name="Clear" Content="Clear" Grid.Row="0" Height="Auto" Margin="5,5,5,5" Grid.Column="3" Click="Clear_Click" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</Grid>
</Window>

View File

@ -1,11 +1,9 @@
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Windows;
using Microsoft.Win32;
using EDJournal;
using EliteBGS.BGS;
using EliteBGS.Util;
namespace EliteBGS {
@ -75,36 +73,5 @@ namespace EliteBGS {
} catch (Exception) {
}
}
private void DeleteUnimportant_Click(object sender, RoutedEventArgs e) {
string lines = Lines.Text.Trim();
if (lines.Length <= 0) {
return;
}
try {
List<Entry> entries = new List<Entry>();
foreach (string line in lines.Split('\n')) {
Entry entry = Entry.Parse(line);
if (Report.IsRelevant(entry)) {
entries.Add(entry);
}
}
if (entries.Count <= 0) {
return;
}
string[] text = entries
.ConvertAll(x => x.JSON.ToString(Newtonsoft.Json.Formatting.None))
.ToArray()
;
Lines.Text = string.Join("\n", text).Trim();
} catch (Exception exception) {
MessageBox.Show(string.Format("There was an error while parsing the JSON: {0}",
exception.ToString()));
}
}
}
}

File diff suppressed because one or more lines are too long