using EDPlayerJournal.Entries;

namespace EDPlayerJournal.BGS.Parsers;

internal class CarrierJumpParser : ITransactionParserPart {
    public void Parse(Entry entry, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
        CarrierJump? jump = entry as CarrierJump;

        if (jump == null) {
            return;
        }

        if (!jump.Docked) {
            return;
        }

        context.CurrentSystem = jump.StarSystem;
        context.CurrentSystemAddress = jump.SystemAddress;

        context.SystemsByID.TryAdd(jump.SystemAddress, jump.StarSystem);

        if (!string.IsNullOrEmpty(jump.SystemFaction)) {
            context.ControllingFaction = jump.SystemFaction;
        }

        if (jump.SystemFactions != null && jump.SystemFactions.Count > 0) {
            context.SystemFactions[jump.StarSystem] = jump.SystemFactions;
        }
    }
}
