Compare commits

...

2 Commits

6 changed files with 131 additions and 7 deletions

View File

@ -44,6 +44,11 @@ internal class TransactionParserContext {
/// </summary> /// </summary>
public ulong ThargoidInterceptorKills { get; set; } = 0; public ulong ThargoidInterceptorKills { get; set; } = 0;
/// <summary>
/// Whether we have seen an AX warzone NPC talk to us with ReceiveText
/// </summary>
public bool HaveSeenAXWarzoneNPC { get; set; } = false;
/// <summary> /// <summary>
/// A list of accepted missions index by their mission ID /// A list of accepted missions index by their mission ID
/// </summary> /// </summary>
@ -69,11 +74,8 @@ internal class TransactionParserContext {
public void DiscernCombatZone(TransactionList transactions, Entry e) { public void DiscernCombatZone(TransactionList transactions, Entry e) {
string? grade = CombatZones.DifficultyLow; string? grade = CombatZones.DifficultyLow;
string cztype; string cztype;
ulong? highest = HighestCombatBond; ulong highest = HighestCombatBond ?? 0;
string? faction = LastRecordedAwardingFaction;
if (highest == null || LastRecordedAwardingFaction == null) {
return;
}
if (OnFootKills > 0) { if (OnFootKills > 0) {
cztype = CombatZones.GroundCombatZone; cztype = CombatZones.GroundCombatZone;
@ -110,7 +112,8 @@ internal class TransactionParserContext {
} }
} }
cztype = CombatZones.ShipCombatZone; cztype = CombatZones.ShipCombatZone;
} else if (ThargoidScoutKills > 0 && ThargoidInterceptorKills > 0) { } else if ((ThargoidScoutKills > 0 && ThargoidInterceptorKills > 0) ||
HaveSeenAXWarzoneNPC == true) {
// Could be a thargoid combat zones if interceptors and scouts are there // Could be a thargoid combat zones if interceptors and scouts are there
cztype = CombatZones.AXCombatZone; cztype = CombatZones.AXCombatZone;
// Still unknown // Still unknown
@ -122,7 +125,7 @@ internal class TransactionParserContext {
CombatZone zone = new CombatZone() { CombatZone zone = new CombatZone() {
System = CurrentSystem, System = CurrentSystem,
Faction = LastRecordedAwardingFaction, Faction = faction,
IsLegacy = IsLegacy, IsLegacy = IsLegacy,
Grade = grade, Grade = grade,
Type = cztype, Type = cztype,
@ -161,6 +164,7 @@ internal class TransactionParserContext {
ShipKills = 0; ShipKills = 0;
ThargoidInterceptorKills = 0; ThargoidInterceptorKills = 0;
ThargoidScoutKills = 0; ThargoidScoutKills = 0;
HaveSeenAXWarzoneNPC = false;
} }
public void BoughtCargo(string? cargo, long? cost) { public void BoughtCargo(string? cargo, long? cost) {
@ -856,11 +860,38 @@ internal class FileHeaderParser : TransactionParserPart {
} }
} }
internal class ReceiveTextParser : TransactionParserPart {
public void Parse(Entry entry, TransactionParserContext context, TransactionList transactions) {
ReceiveTextEntry? receivetext = entry as ReceiveTextEntry;
if (receivetext == null) {
return;
}
if (string.Compare(receivetext.Channel, Channels.NPC) != 0) {
return;
}
if (string.Compare(receivetext.NPCCategory, NPCs.AXMilitary) == 0) {
context.HaveSeenAXWarzoneNPC = true;
}
}
}
internal class DiedParser : TransactionParserPart {
public void Parse(Entry entry, TransactionParserContext context, TransactionList transactions) {
// You can't complete a combat zone if you die in it. Others might keep it open
// for you, but still you will not have completed it unless you jump back in.
context.ResetCombatZone();
}
}
public class TransactionParser { public class TransactionParser {
private static Dictionary<string, TransactionParserPart> ParserParts { get; } = new() private static Dictionary<string, TransactionParserPart> ParserParts { get; } = new()
{ {
{ Events.CapShipBond, new CapShipBondParser() }, { Events.CapShipBond, new CapShipBondParser() },
{ Events.CommitCrime, new CommitCrimeParser() }, { Events.CommitCrime, new CommitCrimeParser() },
{ Events.Died, new DiedParser() },
{ Events.Disembark, new EmbarkDisembarkParser() }, { Events.Disembark, new EmbarkDisembarkParser() },
{ Events.Docked, new DockedParser() }, { Events.Docked, new DockedParser() },
{ Events.Embark, new EmbarkDisembarkParser() }, { Events.Embark, new EmbarkDisembarkParser() },
@ -874,6 +905,7 @@ public class TransactionParser {
{ Events.MissionCompleted, new MissionCompletedParser() }, { Events.MissionCompleted, new MissionCompletedParser() },
{ Events.MissionFailed, new MissionFailedParser() }, { Events.MissionFailed, new MissionFailedParser() },
{ Events.MultiSellExplorationData, new MultiSellExplorationDataParser() }, { Events.MultiSellExplorationData, new MultiSellExplorationDataParser() },
{ Events.ReceiveText, new ReceiveTextParser() },
{ Events.RedeemVoucher, new RedeemVoucherParser() }, { Events.RedeemVoucher, new RedeemVoucherParser() },
{ Events.SearchAndRescue, new SearchAndRescueParser() }, { Events.SearchAndRescue, new SearchAndRescueParser() },
{ Events.SellExplorationData, new SellExplorationDataParser() }, { Events.SellExplorationData, new SellExplorationDataParser() },

View File

@ -0,0 +1,8 @@
namespace EDPlayerJournal;
public class Channels {
/// <summary>
/// Channel NPCs use to talk to the commander.
/// </summary>
public static readonly string NPC = "npc";
}

View File

@ -35,6 +35,7 @@ public class Entry {
{ Events.MissionRedirected, typeof(MissionRedirectedEntry) }, { Events.MissionRedirected, typeof(MissionRedirectedEntry) },
{ Events.Missions, typeof(MissionsEntry) }, { Events.Missions, typeof(MissionsEntry) },
{ Events.MultiSellExplorationData, typeof(MultiSellExplorationDataEntry) }, { Events.MultiSellExplorationData, typeof(MultiSellExplorationDataEntry) },
{ Events.ReceiveText, typeof(ReceiveTextEntry) },
{ Events.RedeemVoucher, typeof(RedeemVoucherEntry) }, { Events.RedeemVoucher, typeof(RedeemVoucherEntry) },
{ Events.SearchAndRescue, typeof(SearchAndRescueEntry) }, { Events.SearchAndRescue, typeof(SearchAndRescueEntry) },
{ Events.SellExplorationData, typeof(SellExplorationDataEntry) }, { Events.SellExplorationData, typeof(SellExplorationDataEntry) },

View File

@ -25,6 +25,7 @@ public class Events {
public static readonly string MissionRedirected = "MissionRedirected"; public static readonly string MissionRedirected = "MissionRedirected";
public static readonly string Missions = "Missions"; public static readonly string Missions = "Missions";
public static readonly string MultiSellExplorationData = "MultiSellExplorationData"; public static readonly string MultiSellExplorationData = "MultiSellExplorationData";
public static readonly string ReceiveText = "ReceiveText";
public static readonly string RedeemVoucher = "RedeemVoucher"; public static readonly string RedeemVoucher = "RedeemVoucher";
public static readonly string SearchAndRescue = "SearchAndRescue"; public static readonly string SearchAndRescue = "SearchAndRescue";
public static readonly string SellExplorationData = "SellExplorationData"; public static readonly string SellExplorationData = "SellExplorationData";

View File

@ -0,0 +1,77 @@
namespace EDPlayerJournal.Entries;
public class ReceiveTextEntry : Entry {
/// <summary>
/// From whom this message is
/// </summary>
public string? From { get; set; }
/// <summary>
/// The message, if it is just an NPC text, it will be a message ID
/// </summary>
public string? Message { get; set; }
/// <summary>
/// Message localised
/// </summary>
public string? MessageLocalised { get; set; }
/// <summary>
/// On what channel this was received.
/// </summary>
public string? Channel { get; set; }
public bool HasNPCCategory {
get {
if (From == null) {
return false;
}
if (From.Contains(';') && From.StartsWith("$")) {
return true;
}
return false;
}
}
/// <summary>
/// Returns the NPC's category, if it has one.
/// </summary>
public string? NPCCategory {
get {
if (!HasNPCCategory || From == null) {
return null;
}
string[] parts = From.Split(";", StringSplitOptions.TrimEntries);
if (parts.Length < 2) {
return null;
}
return string.Format("{0};", parts[0]);
}
}
/// <summary>
/// Returns the NPC's category, if it has one.
/// </summary>
public string? NPCName {
get {
if (!HasNPCCategory || From == null) {
return null;
}
string[] parts = From.Split(";", StringSplitOptions.TrimEntries);
if (parts.Length < 2) {
return null;
}
return parts[1];
}
}
protected override void Initialise() {
From = JSON.Value<string>("From");
Message = JSON.Value<string>("Message");
MessageLocalised = JSON.Value<string>("Message_localised");
Channel = JSON.Value<string>("Channel");
}
}

View File

@ -41,6 +41,11 @@ public class NPCs {
/// </summary> /// </summary>
public static string WarzoneCorrespondent = "$LUASC_Scenario_Warzone_NPC_WarzoneCorrespondent;"; public static string WarzoneCorrespondent = "$LUASC_Scenario_Warzone_NPC_WarzoneCorrespondent;";
/// <summary>
/// AX Military NPC
/// </summary>
public static string AXMilitary = "$Name_AX_Military;";
/// <summary> /// <summary>
/// Returns true if the pilotname is either a captain, specops, or correspondent /// Returns true if the pilotname is either a captain, specops, or correspondent
/// </summary> /// </summary>