Compare commits

..

2 Commits

4 changed files with 134 additions and 10 deletions

View File

@ -6,13 +6,6 @@ public class CombatZone : Transaction {
public string Type { get; set; } = "";
public string Grade { get; set; } = "";
public int Amount { get; set; } = 0;
public DateTime Completed { get; set; } = DateTime.UtcNow;
public override string CompletedAt {
get {
return Completed.ToString("dd.MM.yyyy HH:mm UTC");
}
}
public override int CompareTo(Transaction? obj) {
if (obj == null || obj.GetType() != typeof(CombatZone)) {

View File

@ -1,4 +1,5 @@
using EDPlayerJournal.Entries;
using System.ComponentModel.DataAnnotations.Schema;
namespace EDPlayerJournal.BGS;

View File

@ -17,6 +17,8 @@ internal class TransactionParserContext {
public ulong? HighestCombatBond { get; set; }
public bool HaveSeenWarzoneNPC { get; set; } = false;
/// <summary>
/// How many on foot kills were done.
/// </summary>
@ -49,7 +51,7 @@ internal class TransactionParserContext {
/// </summary>
public Dictionary<string, long> BuyCost = new();
public void DiscernCombatZone(TransactionList transactions) {
public void DiscernCombatZone(TransactionList transactions, Entry e) {
string grade = "Low";
string cztype;
ulong? highest = HighestCombatBond;
@ -73,6 +75,10 @@ internal class TransactionParserContext {
} else if (ShipKills > 10) {
grade = "Medium";
}
if (HaveSeenWarzoneNPC && grade == "Low") {
// We have seen a warzone NPC so we know its at least medium
grade = "Medium";
}
cztype = "Ship";
} else {
transactions.AddIncomplete(new CombatZone(), "Failed to discern combat zone type");
@ -86,6 +92,7 @@ internal class TransactionParserContext {
Type = cztype,
Amount = 1,
};
zone.Entries.Add(e);
transactions.Add(zone);
}
@ -105,6 +112,7 @@ internal class TransactionParserContext {
public void ResetCombatZone() {
HighestCombatBond = null;
HaveSeenWarzoneNPC = false;
LastRecordedAwardingFaction = null;
OnFootKills = 0;
ShipKills = 0;
@ -275,6 +283,11 @@ internal class ShipTargetedParser : TransactionParserPart {
!string.IsNullOrEmpty(entry.Faction)) {
context.NPCFaction.TryAdd(entry.PilotNameLocalised, entry.Faction);
}
// We have seen a spec ops, so we know its medium or higher
if (NPCs.IsWarzoneNPC(entry.PilotName)) {
context.HaveSeenWarzoneNPC = true;
}
}
}
@ -709,14 +722,14 @@ internal class EmbarkDisembarkParser : TransactionParserPart {
internal class SupercruiseEntryParser : TransactionParserPart {
public void Parse(Entry entry, TransactionParserContext context, TransactionList transactions) {
context.DiscernCombatZone(transactions);
context.DiscernCombatZone(transactions, entry);
context.ResetCombatZone();
}
}
internal class ShutdownParser : TransactionParserPart {
public void Parse(Entry entry, TransactionParserContext context, TransactionList transactions) {
context.DiscernCombatZone(transactions);
context.DiscernCombatZone(transactions, entry);
context.ResetCombatZone();
}
}

117
EDPlayerJournal/NPC.cs Normal file
View File

@ -0,0 +1,117 @@
namespace EDPlayerJournal;
public class NPCs {
/// <summary>
/// Internal name of Spec Ops Wing Alpha
/// </summary>
public static string SpecOpsAInternal = "$LUASC_Scenario_Warzone_NPC_SpecOps_A;";
/// <summary>
/// Internal name of Spec Ops Wing Beta
/// </summary>
public static string SpecOpsBInternal = "$LUASC_Scenario_Warzone_NPC_SpecOps_B;";
/// <summary>
/// Internal name of Spec Ops Wing Gamma
/// </summary>
public static string SpecOpsGInternal = "$LUASC_Scenario_Warzone_NPC_SpecOps_G;";
/// <summary>
/// Internal name of Spec Ops Wing Delta
/// </summary>
public static string SpecOpsDInternal = "$LUASC_Scenario_Warzone_NPC_SpecOps_D;";
/// <summary>
/// Empire captain
/// </summary>
public static string EmpireCaptain = "$LUASC_Scenario_Warzone_NPC_WarzoneGeneral_Emp;";
/// <summary>
/// Federation captain
/// </summary>
public static string FederationCaptain = "$LUASC_Scenario_Warzone_NPC_WarzoneGeneral_Fed;";
/// <summary>
/// Federation captain
/// </summary>
public static string IndependentCaptain = "$LUASC_Scenario_Warzone_NPC_WarzoneGeneral_Ind;";
/// <summary>
/// Warzone correspondant
/// </summary>
public static string WarzoneCorrespondent = "$LUASC_Scenario_Warzone_NPC_WarzoneCorrespondent;";
/// <summary>
/// Returns true if the pilotname is either a captain, specops, or correspondent
/// </summary>
/// <param name="pilotname"></param>
/// <returns></returns>
public static bool IsWarzoneNPC(string? pilotname) {
if (IsWarzoneCaptain(pilotname) ||
IsWarzoneCorrespondent(pilotname) ||
IsSpecOps(pilotname)) {
return true;
}
return false;
}
/// <summary>
/// Returns true if the given pilot name is a warzone correspondent
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public static bool IsWarzoneCorrespondent(string? pilotname) {
if (pilotname == null) {
return false;
}
if (string.Compare(pilotname, WarzoneCorrespondent) == 0) {
return true;
}
return false;
}
/// <summary>
/// Returns true if the given pilot name is a spec ops wing.
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public static bool IsSpecOps(string? pilotname) {
if (pilotname == null) {
return false;
}
if (string.Compare(pilotname, SpecOpsAInternal) == 0 ||
string.Compare(pilotname, SpecOpsBInternal) == 0 ||
string.Compare(pilotname, SpecOpsGInternal) == 0 ||
string.Compare(pilotname, SpecOpsDInternal) == 0) {
return true;
}
return false;
}
/// <summary>
/// Returns true if the given pilot name is a warzone captain
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public static bool IsWarzoneCaptain(string? pilotname) {
if (pilotname == null) {
return false;
}
if (string.Compare(pilotname, EmpireCaptain) == 0 ||
string.Compare(pilotname, FederationCaptain) == 0 ||
string.Compare(pilotname, IndependentCaptain) == 0) {
return true;
}
return false;
}
}
public class NPC {
}