Compare commits

..

No commits in common. "44774c5cadfc7c36ae16aa4353635bfd4fa910b1" and "bf43262a8eb107abd6c33021eff3b7f34d0cb40e" have entirely different histories.

6 changed files with 41 additions and 52 deletions

View File

@ -21,12 +21,12 @@ public class InfluenceSupport : Transaction {
/// </summary>
public MissionAcceptedEntry? AcceptedEntry { get; set; }
public override DateTime? CompletedAtDateTime {
public override string CompletedAt {
get {
if (RelevantMission == null) {
return null;
return "";
}
return RelevantMission.Timestamp;
return RelevantMission.Timestamp.ToString("dd.MM.yyyy hh:mm UTC");
}
}

View File

@ -11,12 +11,12 @@ public class MissionCompleted : Transaction {
public MissionCompleted() { }
public override DateTime? CompletedAtDateTime {
public override string CompletedAt {
get {
if (CompletedEntry == null) {
return null;
return "";
}
return CompletedEntry.Timestamp;
return CompletedEntry.Timestamp.ToString("dd.MM.yyyy HH:mm UTC");
}
}

View File

@ -1,4 +1,9 @@
using EDPlayerJournal.Entries;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EDPlayerJournal.BGS;

View File

@ -6,29 +6,18 @@ namespace EDPlayerJournal.BGS;
public class Transaction : IComparable<Transaction> {
public List<Entry> Entries { get; } = new List<Entry>();
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 {
public virtual string CompletedAt {
get {
var items = Entries
.OrderBy(x => x.Timestamp)
.ToArray()
;
if (items == null || items.Length == 0) {
return null;
return "Unknown";
}
Entry last = items.Last();
return last.Timestamp;
return last.Timestamp.ToString("dd.MM.yyyy HH:mm UTC");
}
}

View File

@ -88,8 +88,7 @@ internal class TransactionParserContext {
// High on foot combat zones have enforcers that bring 80k a pop
if (highest >= 80000) {
grade = CombatZones.DifficultyHigh;
} else if (highest >= 30000) {
// In medium conflict zones, the enforcers are worth 30k
} else if (highest >= 40000) {
grade = CombatZones.DifficultyMedium;
} else {
grade = CombatZones.DifficultyLow;

View File

@ -65,33 +65,11 @@ public partial class MainWindow : Window {
GenerateLog();
}
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) {
private void HandleEntries(List<Entry> entries) {
try {
TransactionParser parser = new TransactionParser();
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();
// Log incomplete and remove them from the results.
foreach (var incomplete in incompletes) {
@ -108,14 +86,25 @@ public partial class MainWindow : Window {
}
}
private void HandleEntries(List<Entry> entries) {
HandleEntries(entries, DateTime.Now, DateTime.Now);
}
private void Loadentries_EntriesLoaded(List<Entry> 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) {
try {
TransactionParser parser = new TransactionParser();
@ -132,14 +121,21 @@ public partial class MainWindow : Window {
// 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.
DateTime actualstart = start.AddDays(-3);
DateTime actualend = end.AddDays(1);
List<Entry> entries = journal.Files
.Where(f => f.NormalisedDateTime >= actualstart && f.NormalisedDateTime <= actualend)
.Where(f => f.NormalisedDateTime >= actualstart && f.NormalisedDateTime <= end)
.SelectMany(e => e.Entries)
.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);
HandleEntries(entries, start, end);
entries = entries
.Where(e => e.Timestamp >= start && e.Timestamp < actualend)
.ToList()
;
HandleEntries(entries);
GenerateLog();
} catch (Exception exception) {
Log("Something went terribly wrong while parsing the E:D player journal.");