Compare commits
	
		
			No commits in common. "d79ee5a1538f8685cf9d27ef8cc8c44d5b16d8df" and "bb74d72b13c154fb7eaeb46ecd159fae6d992a0c" have entirely different histories.
		
	
	
		
			d79ee5a153
			...
			bb74d72b13
		
	
		
@ -3,52 +3,9 @@ using System.Linq;
 | 
			
		||||
 | 
			
		||||
namespace EDPlayerJournal.BGS; 
 | 
			
		||||
public class CombatZone : Transaction {
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Type, either on foot or ship
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public string Type { get; set; } = "Ship";
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Difficulty type, low, medium or high.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public string Grade { get; set; } = "Low";
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// How many?
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public int Amount { get; set; } = 1;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Whether spec ops were won.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public bool? SpecOps { get; set; }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Whether captain was won
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public bool? Captain { get; set; }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Whether correspondent objective was won
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public bool? Correspondent { get; set; }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Whether cap ship objective was won
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public bool? CapitalShip { get; set; }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// How many optional objectives were completed?
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public int OptionalObjectivesCompleted {
 | 
			
		||||
        get {
 | 
			
		||||
            return new List<bool?>() { SpecOps, Captain, Correspondent, CapitalShip }
 | 
			
		||||
                .Where(x => x != null && x == true)
 | 
			
		||||
                .Count()
 | 
			
		||||
                ;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    public string Type { get; set; } = "";
 | 
			
		||||
    public string Grade { get; set; } = "";
 | 
			
		||||
    public int Amount { get; set; } = 0;
 | 
			
		||||
 | 
			
		||||
    public override int CompareTo(Transaction? obj) {
 | 
			
		||||
        if (obj == null || obj.GetType() != typeof(CombatZone)) {
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,7 @@
 | 
			
		||||
using EDPlayerJournal.Entries;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Reflection.Metadata.Ecma335;
 | 
			
		||||
using System.Transactions;
 | 
			
		||||
 | 
			
		||||
namespace EDPlayerJournal.BGS; 
 | 
			
		||||
 | 
			
		||||
@ -14,10 +17,7 @@ internal class TransactionParserContext {
 | 
			
		||||
 | 
			
		||||
    public ulong? HighestCombatBond { get; set; }
 | 
			
		||||
 | 
			
		||||
    public bool HaveSeenCapShip { get; set; } = false;
 | 
			
		||||
    public bool HaveSeenCaptain { get; set; } = false;
 | 
			
		||||
    public bool HaveSeenSpecOps { get; set; } = false;
 | 
			
		||||
    public bool HaveSeenCorrespondent { get; set; } = false;
 | 
			
		||||
    public bool HaveSeenWarzoneNPC { get; set; } = false;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// How many on foot kills were done.
 | 
			
		||||
@ -65,10 +65,8 @@ internal class TransactionParserContext {
 | 
			
		||||
            // High on foot combat zones have enforcers that bring 80k a pop
 | 
			
		||||
            if (highest >= 80000) {
 | 
			
		||||
                grade = "High";
 | 
			
		||||
            } else if (highest >= 40000) {
 | 
			
		||||
            } else if (highest >= 4000) {
 | 
			
		||||
                grade = "Medium";
 | 
			
		||||
            } else {
 | 
			
		||||
                grade = "Low";
 | 
			
		||||
            }
 | 
			
		||||
        } else if (ShipKills > 0) {
 | 
			
		||||
            // Ship combat zones can be identified by the amount of kills
 | 
			
		||||
@ -77,23 +75,10 @@ internal class TransactionParserContext {
 | 
			
		||||
            } else if (ShipKills > 10) {
 | 
			
		||||
                grade = "Medium";
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // Cap ship, means a high conflict zone
 | 
			
		||||
            if (HaveSeenCapShip) {
 | 
			
		||||
                grade = "High";
 | 
			
		||||
            } else {
 | 
			
		||||
                int warzoneNpcs = new List<bool>() { HaveSeenCaptain, HaveSeenCorrespondent, HaveSeenSpecOps }
 | 
			
		||||
                                    .Where(x => x == true)
 | 
			
		||||
                                    .Count()
 | 
			
		||||
                                    ;
 | 
			
		||||
 | 
			
		||||
                if (warzoneNpcs >= 2 && grade != "High") {
 | 
			
		||||
                    // Only large combat zones have two NPCs
 | 
			
		||||
                    grade = "High";
 | 
			
		||||
                } else if (warzoneNpcs >= 1 && grade == "Low") {
 | 
			
		||||
            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");
 | 
			
		||||
@ -105,11 +90,6 @@ internal class TransactionParserContext {
 | 
			
		||||
            Faction = LastRecordedAwardingFaction,
 | 
			
		||||
            Grade = grade,
 | 
			
		||||
            Type = cztype,
 | 
			
		||||
            // Sad truth is, if HaveSeenXXX is false, we just don't know for certain
 | 
			
		||||
            CapitalShip = HaveSeenCapShip ? true : null,
 | 
			
		||||
            SpecOps = HaveSeenSpecOps ? true : null,
 | 
			
		||||
            Correspondent = HaveSeenCorrespondent ? true : null,
 | 
			
		||||
            Captain = HaveSeenCaptain ? true : null,
 | 
			
		||||
            Amount = 1,
 | 
			
		||||
        };
 | 
			
		||||
        zone.Entries.Add(e);
 | 
			
		||||
@ -132,10 +112,7 @@ internal class TransactionParserContext {
 | 
			
		||||
 | 
			
		||||
    public void ResetCombatZone() {
 | 
			
		||||
        HighestCombatBond = null;
 | 
			
		||||
        HaveSeenCapShip = false;
 | 
			
		||||
        HaveSeenCaptain = false;
 | 
			
		||||
        HaveSeenCorrespondent = false;
 | 
			
		||||
        HaveSeenSpecOps = false;
 | 
			
		||||
        HaveSeenWarzoneNPC = false;
 | 
			
		||||
        LastRecordedAwardingFaction = null;
 | 
			
		||||
        OnFootKills = 0;
 | 
			
		||||
        ShipKills = 0;
 | 
			
		||||
@ -313,19 +290,9 @@ internal class ShipTargetedParser : TransactionParserPart {
 | 
			
		||||
            context.NPCFaction.TryAdd(entry.PilotNameLocalised, entry.Faction);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // We have seen a captain?
 | 
			
		||||
        if (NPCs.IsWarzoneCaptain(entry.PilotName)) {
 | 
			
		||||
            context.HaveSeenCaptain = true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Spec ops?
 | 
			
		||||
        if (NPCs.IsSpecOps(entry.PilotName)) {
 | 
			
		||||
            context.HaveSeenSpecOps = true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Correspondent?
 | 
			
		||||
        if (NPCs.IsWarzoneCorrespondent(entry.PilotName)) {
 | 
			
		||||
            context.HaveSeenCorrespondent = true;
 | 
			
		||||
        // We have seen a spec ops, so we know its medium or higher
 | 
			
		||||
        if (NPCs.IsWarzoneNPC(entry.PilotName)) {
 | 
			
		||||
            context.HaveSeenWarzoneNPC = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -787,20 +754,9 @@ internal class ShutdownParser : TransactionParserPart {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
internal class CapShipBondParser : TransactionParserPart {
 | 
			
		||||
    public void Parse(Entry entry, TransactionParserContext context, TransactionList transactions) {
 | 
			
		||||
        if (entry.GetType() != typeof(CapShipBondEntry)) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        context.HaveSeenCapShip = true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public class TransactionParser {
 | 
			
		||||
    private static Dictionary<string, TransactionParserPart> ParserParts { get; } = new()
 | 
			
		||||
    {
 | 
			
		||||
        { Events.CapShipBond, new CapShipBondParser() },
 | 
			
		||||
        { Events.CommitCrime, new CommitCrimeParser() },
 | 
			
		||||
        { Events.Disembark, new EmbarkDisembarkParser() },
 | 
			
		||||
        { Events.Docked, new DockedParser() },
 | 
			
		||||
 | 
			
		||||
@ -1,24 +0,0 @@
 | 
			
		||||
namespace EDPlayerJournal.Entries;
 | 
			
		||||
 | 
			
		||||
public class CapShipBondEntry : Entry {
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Reward gained
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public ulong Reward { get; set; } = 0;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Victim faction, i.e. to whom the cap ship belongs
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public string? VictimFaction { get; set; }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Awarding faction.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public string? AwardingFaction { get; set; }
 | 
			
		||||
 | 
			
		||||
    protected override void Initialise() {
 | 
			
		||||
        Reward = JSON.Value<ulong?>("Reward") ?? 0;
 | 
			
		||||
        VictimFaction = JSON.Value<string?>("VictimFaction");
 | 
			
		||||
        AwardingFaction = JSON.Value<string?>("AwardingFaction");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -13,7 +13,6 @@ namespace EDPlayerJournal.Entries;
 | 
			
		||||
public class Entry {
 | 
			
		||||
    private static readonly Dictionary<string, Type> classes = new Dictionary<string, Type> {
 | 
			
		||||
        { Events.Bounty, typeof(BountyEntry) },
 | 
			
		||||
        { Events.CapShipBond, typeof(CapShipBondEntry) },
 | 
			
		||||
        { Events.Commander, typeof(CommanderEntry) },
 | 
			
		||||
        { Events.CommitCrime, typeof(CommitCrimeEntry) },
 | 
			
		||||
        { Events.Died, typeof(DiedEntry) },
 | 
			
		||||
 | 
			
		||||
@ -2,7 +2,6 @@
 | 
			
		||||
 | 
			
		||||
public class Events {
 | 
			
		||||
    public static readonly string Bounty = "Bounty";
 | 
			
		||||
    public static readonly string CapShipBond = "CapShipBond";
 | 
			
		||||
    public static readonly string Commander = "Commander";
 | 
			
		||||
    public static readonly string CommitCrime = "CommitCrime";
 | 
			
		||||
    public static readonly string Died = "Died";
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user