Compare commits
3 Commits
bf43262a8e
...
44774c5cad
Author | SHA1 | Date | |
---|---|---|---|
44774c5cad | |||
8d3d48d846 | |||
a3b54b1326 |
@ -21,12 +21,12 @@ public class InfluenceSupport : Transaction {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public MissionAcceptedEntry? AcceptedEntry { get; set; }
|
public MissionAcceptedEntry? AcceptedEntry { get; set; }
|
||||||
|
|
||||||
public override string CompletedAt {
|
public override DateTime? CompletedAtDateTime {
|
||||||
get {
|
get {
|
||||||
if (RelevantMission == null) {
|
if (RelevantMission == null) {
|
||||||
return "";
|
return null;
|
||||||
}
|
}
|
||||||
return RelevantMission.Timestamp.ToString("dd.MM.yyyy hh:mm UTC");
|
return RelevantMission.Timestamp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,12 +11,12 @@ public class MissionCompleted : Transaction {
|
|||||||
|
|
||||||
public MissionCompleted() { }
|
public MissionCompleted() { }
|
||||||
|
|
||||||
public override string CompletedAt {
|
public override DateTime? CompletedAtDateTime {
|
||||||
get {
|
get {
|
||||||
if (CompletedEntry == null) {
|
if (CompletedEntry == null) {
|
||||||
return "";
|
return null;
|
||||||
}
|
}
|
||||||
return CompletedEntry.Timestamp.ToString("dd.MM.yyyy HH:mm UTC");
|
return CompletedEntry.Timestamp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
using EDPlayerJournal.Entries;
|
using EDPlayerJournal.Entries;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace EDPlayerJournal.BGS;
|
namespace EDPlayerJournal.BGS;
|
||||||
|
|
||||||
|
@ -6,18 +6,29 @@ namespace EDPlayerJournal.BGS;
|
|||||||
public class Transaction : IComparable<Transaction> {
|
public class Transaction : IComparable<Transaction> {
|
||||||
public List<Entry> Entries { get; } = new List<Entry>();
|
public List<Entry> Entries { get; } = new List<Entry>();
|
||||||
|
|
||||||
public virtual string CompletedAt {
|
public string CompletedAt {
|
||||||
|
get {
|
||||||
|
DateTime? datetime = CompletedAtDateTime;
|
||||||
|
if (datetime == null) {
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
return datetime.Value.ToString("dd.MM.yyyy HH:mm UTC");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual DateTime? CompletedAtDateTime {
|
||||||
get {
|
get {
|
||||||
var items = Entries
|
var items = Entries
|
||||||
.OrderBy(x => x.Timestamp)
|
.OrderBy(x => x.Timestamp)
|
||||||
.ToArray()
|
.ToArray()
|
||||||
;
|
;
|
||||||
if (items == null || items.Length == 0) {
|
if (items == null || items.Length == 0) {
|
||||||
return "Unknown";
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entry last = items.Last();
|
Entry last = items.Last();
|
||||||
return last.Timestamp.ToString("dd.MM.yyyy HH:mm UTC");
|
return last.Timestamp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,8 @@ internal class TransactionParserContext {
|
|||||||
// High on foot combat zones have enforcers that bring 80k a pop
|
// High on foot combat zones have enforcers that bring 80k a pop
|
||||||
if (highest >= 80000) {
|
if (highest >= 80000) {
|
||||||
grade = CombatZones.DifficultyHigh;
|
grade = CombatZones.DifficultyHigh;
|
||||||
} else if (highest >= 40000) {
|
} else if (highest >= 30000) {
|
||||||
|
// In medium conflict zones, the enforcers are worth 30k
|
||||||
grade = CombatZones.DifficultyMedium;
|
grade = CombatZones.DifficultyMedium;
|
||||||
} else {
|
} else {
|
||||||
grade = CombatZones.DifficultyLow;
|
grade = CombatZones.DifficultyLow;
|
||||||
|
@ -65,11 +65,33 @@ public partial class MainWindow : Window {
|
|||||||
GenerateLog();
|
GenerateLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleEntries(List<Entry> entries) {
|
private void Report_OnLog(string message) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
|
builder.Append(DateTime.Now.ToString());
|
||||||
|
builder.Append(": ");
|
||||||
|
builder.Append(message);
|
||||||
|
builder.Append("\n");
|
||||||
|
|
||||||
|
log.AppendText(builder.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Log(string message) {
|
||||||
|
Report_OnLog(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleEntries(List<Entry> entries, DateTime start, DateTime end) {
|
||||||
try {
|
try {
|
||||||
TransactionParser parser = new TransactionParser();
|
TransactionParser parser = new TransactionParser();
|
||||||
List<Transaction> transactions = parser.Parse(entries);
|
List<Transaction> transactions = parser.Parse(entries);
|
||||||
|
|
||||||
|
// Filter the transactions down to the given time frame
|
||||||
|
DateTime actualend = end.AddDays(1);
|
||||||
|
transactions = transactions
|
||||||
|
.Where(t => t.CompletedAtDateTime >= start && t.CompletedAtDateTime <= actualend)
|
||||||
|
.ToList()
|
||||||
|
;
|
||||||
|
|
||||||
List<IncompleteTransaction> incompletes = transactions.OfType<IncompleteTransaction>().ToList();
|
List<IncompleteTransaction> incompletes = transactions.OfType<IncompleteTransaction>().ToList();
|
||||||
// Log incomplete and remove them from the results.
|
// Log incomplete and remove them from the results.
|
||||||
foreach (var incomplete in incompletes) {
|
foreach (var incomplete in incompletes) {
|
||||||
@ -86,25 +108,14 @@ public partial class MainWindow : Window {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void HandleEntries(List<Entry> entries) {
|
||||||
|
HandleEntries(entries, DateTime.Now, DateTime.Now);
|
||||||
|
}
|
||||||
|
|
||||||
private void Loadentries_EntriesLoaded(List<Entry> lines) {
|
private void Loadentries_EntriesLoaded(List<Entry> lines) {
|
||||||
HandleEntries(lines);
|
HandleEntries(lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Report_OnLog(string message) {
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
|
|
||||||
builder.Append(DateTime.Now.ToString());
|
|
||||||
builder.Append(": ");
|
|
||||||
builder.Append(message);
|
|
||||||
builder.Append("\n");
|
|
||||||
|
|
||||||
log.AppendText(builder.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Log(string message) {
|
|
||||||
Report_OnLog(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ParseJournal_Click(object sender, RoutedEventArgs e) {
|
private void ParseJournal_Click(object sender, RoutedEventArgs e) {
|
||||||
try {
|
try {
|
||||||
TransactionParser parser = new TransactionParser();
|
TransactionParser parser = new TransactionParser();
|
||||||
@ -121,21 +132,14 @@ public partial class MainWindow : Window {
|
|||||||
// files have to be read in their entirety to check this). So we assume that you can't play
|
// files have to be read in their entirety to check this). So we assume that you can't play
|
||||||
// three days straight, and keep the code fast.
|
// three days straight, and keep the code fast.
|
||||||
DateTime actualstart = start.AddDays(-3);
|
DateTime actualstart = start.AddDays(-3);
|
||||||
|
DateTime actualend = end.AddDays(1);
|
||||||
List<Entry> entries = journal.Files
|
List<Entry> entries = journal.Files
|
||||||
.Where(f => f.NormalisedDateTime >= actualstart && f.NormalisedDateTime <= end)
|
.Where(f => f.NormalisedDateTime >= actualstart && f.NormalisedDateTime <= actualend)
|
||||||
.SelectMany(e => e.Entries)
|
.SelectMany(e => e.Entries)
|
||||||
.ToList()
|
.ToList()
|
||||||
;
|
;
|
||||||
// Now further sort the list down to entries that are actually within the given datetime
|
|
||||||
// Note that entry datetimes are not normalised, so we have to sort until end + 1 day
|
|
||||||
DateTime actualend = end.AddDays(1);
|
|
||||||
|
|
||||||
entries = entries
|
HandleEntries(entries, start, end);
|
||||||
.Where(e => e.Timestamp >= start && e.Timestamp < actualend)
|
|
||||||
.ToList()
|
|
||||||
;
|
|
||||||
|
|
||||||
HandleEntries(entries);
|
|
||||||
GenerateLog();
|
GenerateLog();
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
Log("Something went terribly wrong while parsing the E:D player journal.");
|
Log("Something went terribly wrong while parsing the E:D player journal.");
|
||||||
|
Loading…
Reference in New Issue
Block a user