Compare commits
2 Commits
8dea9fd094
...
123fa15884
Author | SHA1 | Date | |
---|---|---|---|
123fa15884 | |||
43ae93658f |
@ -44,6 +44,11 @@ internal class TransactionParserContext {
|
||||
/// </summary>
|
||||
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>
|
||||
/// A list of accepted missions index by their mission ID
|
||||
/// </summary>
|
||||
@ -69,11 +74,8 @@ internal class TransactionParserContext {
|
||||
public void DiscernCombatZone(TransactionList transactions, Entry e) {
|
||||
string? grade = CombatZones.DifficultyLow;
|
||||
string cztype;
|
||||
ulong? highest = HighestCombatBond;
|
||||
|
||||
if (highest == null || LastRecordedAwardingFaction == null) {
|
||||
return;
|
||||
}
|
||||
ulong highest = HighestCombatBond ?? 0;
|
||||
string? faction = LastRecordedAwardingFaction;
|
||||
|
||||
if (OnFootKills > 0) {
|
||||
cztype = CombatZones.GroundCombatZone;
|
||||
@ -110,7 +112,8 @@ internal class TransactionParserContext {
|
||||
}
|
||||
}
|
||||
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
|
||||
cztype = CombatZones.AXCombatZone;
|
||||
// Still unknown
|
||||
@ -122,7 +125,7 @@ internal class TransactionParserContext {
|
||||
|
||||
CombatZone zone = new CombatZone() {
|
||||
System = CurrentSystem,
|
||||
Faction = LastRecordedAwardingFaction,
|
||||
Faction = faction,
|
||||
IsLegacy = IsLegacy,
|
||||
Grade = grade,
|
||||
Type = cztype,
|
||||
@ -161,6 +164,7 @@ internal class TransactionParserContext {
|
||||
ShipKills = 0;
|
||||
ThargoidInterceptorKills = 0;
|
||||
ThargoidScoutKills = 0;
|
||||
HaveSeenAXWarzoneNPC = false;
|
||||
}
|
||||
|
||||
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 {
|
||||
private static Dictionary<string, TransactionParserPart> ParserParts { get; } = new()
|
||||
{
|
||||
{ Events.CapShipBond, new CapShipBondParser() },
|
||||
{ Events.CommitCrime, new CommitCrimeParser() },
|
||||
{ Events.Died, new DiedParser() },
|
||||
{ Events.Disembark, new EmbarkDisembarkParser() },
|
||||
{ Events.Docked, new DockedParser() },
|
||||
{ Events.Embark, new EmbarkDisembarkParser() },
|
||||
@ -874,6 +905,7 @@ public class TransactionParser {
|
||||
{ Events.MissionCompleted, new MissionCompletedParser() },
|
||||
{ Events.MissionFailed, new MissionFailedParser() },
|
||||
{ Events.MultiSellExplorationData, new MultiSellExplorationDataParser() },
|
||||
{ Events.ReceiveText, new ReceiveTextParser() },
|
||||
{ Events.RedeemVoucher, new RedeemVoucherParser() },
|
||||
{ Events.SearchAndRescue, new SearchAndRescueParser() },
|
||||
{ Events.SellExplorationData, new SellExplorationDataParser() },
|
||||
|
8
EDPlayerJournal/Channels.cs
Normal file
8
EDPlayerJournal/Channels.cs
Normal 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";
|
||||
}
|
@ -35,6 +35,7 @@ public class Entry {
|
||||
{ Events.MissionRedirected, typeof(MissionRedirectedEntry) },
|
||||
{ Events.Missions, typeof(MissionsEntry) },
|
||||
{ Events.MultiSellExplorationData, typeof(MultiSellExplorationDataEntry) },
|
||||
{ Events.ReceiveText, typeof(ReceiveTextEntry) },
|
||||
{ Events.RedeemVoucher, typeof(RedeemVoucherEntry) },
|
||||
{ Events.SearchAndRescue, typeof(SearchAndRescueEntry) },
|
||||
{ Events.SellExplorationData, typeof(SellExplorationDataEntry) },
|
||||
|
@ -25,6 +25,7 @@ public class Events {
|
||||
public static readonly string MissionRedirected = "MissionRedirected";
|
||||
public static readonly string Missions = "Missions";
|
||||
public static readonly string MultiSellExplorationData = "MultiSellExplorationData";
|
||||
public static readonly string ReceiveText = "ReceiveText";
|
||||
public static readonly string RedeemVoucher = "RedeemVoucher";
|
||||
public static readonly string SearchAndRescue = "SearchAndRescue";
|
||||
public static readonly string SellExplorationData = "SellExplorationData";
|
||||
|
77
EDPlayerJournal/Entries/ReceiveTextEntry.cs
Normal file
77
EDPlayerJournal/Entries/ReceiveTextEntry.cs
Normal 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");
|
||||
}
|
||||
}
|
@ -41,6 +41,11 @@ public class NPCs {
|
||||
/// </summary>
|
||||
public static string WarzoneCorrespondent = "$LUASC_Scenario_Warzone_NPC_WarzoneCorrespondent;";
|
||||
|
||||
/// <summary>
|
||||
/// AX Military NPC
|
||||
/// </summary>
|
||||
public static string AXMilitary = "$Name_AX_Military;";
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the pilotname is either a captain, specops, or correspondent
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user