Compare commits
2 Commits
a11d3d10aa
...
f499d7763b
Author | SHA1 | Date | |
---|---|---|---|
f499d7763b | |||
9d81a9ad7d |
@ -5,7 +5,6 @@ namespace EliteBGS.BGS {
|
||||
public class MissionCompleted : LogEntry {
|
||||
public MissionCompleted(MissionCompletedEntry e) {
|
||||
Entries.Add(e);
|
||||
Faction = e.JSON.GetValue("Faction").ToString();
|
||||
}
|
||||
|
||||
public string MissionName {
|
||||
|
@ -28,7 +28,7 @@ namespace EliteBGS.BGS {
|
||||
return added;
|
||||
}
|
||||
|
||||
private bool IsRelevant(Entry e) {
|
||||
public static bool IsRelevant(Entry e) {
|
||||
return e.Is(Events.CommitCrime) ||
|
||||
e.Is(Events.Docked) ||
|
||||
e.Is(Events.FactionKillBond) ||
|
||||
@ -67,12 +67,17 @@ namespace EliteBGS.BGS {
|
||||
.ToList()
|
||||
;
|
||||
|
||||
Dictionary<int, MissionAcceptedEntry> acceptedMissions = new Dictionary<int, MissionAcceptedEntry>();
|
||||
Dictionary<ulong, MissionAcceptedEntry> acceptedMissions = new Dictionary<ulong, 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;
|
||||
@ -177,12 +182,18 @@ namespace EliteBGS.BGS {
|
||||
});
|
||||
collate = true;
|
||||
} else if (e.Is(Events.MissionCompleted)) {
|
||||
var completed = e as MissionCompletedEntry;
|
||||
results.Add(new MissionCompleted(completed) {
|
||||
System = current_system,
|
||||
Station = current_station,
|
||||
SystemAddress = current_system_address,
|
||||
});
|
||||
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;
|
||||
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
|
||||
@ -200,9 +211,51 @@ namespace EliteBGS.BGS {
|
||||
}
|
||||
foreach (var influences in other.Value) {
|
||||
ulong system_address = influences.Key;
|
||||
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 : "";
|
||||
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).
|
||||
*/
|
||||
results.Add(new InfluenceSupport() {
|
||||
Faction = faction,
|
||||
Influence = influences.Value,
|
||||
@ -215,7 +268,16 @@ namespace EliteBGS.BGS {
|
||||
}
|
||||
} else if (e.Is(Events.MissionAccepted)) {
|
||||
MissionAcceptedEntry accepted = e as MissionAcceptedEntry;
|
||||
acceptedMissions[accepted.MissionID] = accepted;
|
||||
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;
|
||||
}
|
||||
} else if (e.Is(Events.MissionFailed)) {
|
||||
var failed = e as MissionFailedEntry;
|
||||
MissionAcceptedEntry accepted = null;
|
||||
|
@ -202,6 +202,7 @@
|
||||
<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" />
|
||||
|
@ -28,11 +28,13 @@
|
||||
<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="Clear" Content="Clear" Grid.Row="0" Height="Auto" Margin="5,5,5,5" Grid.Column="3" Click="Clear_Click" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<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"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
@ -1,9 +1,11 @@
|
||||
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 {
|
||||
@ -73,5 +75,36 @@ 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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
859
TestData/DoubleSupport.txt
Normal file
859
TestData/DoubleSupport.txt
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user