using EDPlayerJournal.Entries;

namespace EDPlayerJournal.BGS;

internal class SellExplorationDataParser : ITransactionParserPart {
    public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
        SellExplorationDataEntry? entry = e as SellExplorationDataEntry;
        if (entry == null) {
            throw new NotImplementedException();
        }

        if (context.StationOwner == null) {
            transactions.AddIncomplete(
                new Cartographics(),
                "Could not discern the station owner for cartographics sell.",
                e);
            return;
        }

        // Ignore if its a fleet carrier faction.
        if (string.Compare(context.StationOwner, Factions.FleetCarrier, StringComparison.OrdinalIgnoreCase) == 0 &&
            options.IgnoreFleetCarrierFaction) {
            return;
        }

        transactions.Add(new Cartographics(entry) {
            System = context.CurrentSystem,
            Station = context.CurrentStation,
            Faction = context.StationOwner,
            IsLegacy = context.IsLegacy,
        });
    }
}
