add an option to ignore Fleet Carrier faction
This commit is contained in:
parent
b3fca4a63e
commit
bec73931b9
44
EDPlayerJournal/BGS/Parsers/MarketBuyParser.cs
Normal file
44
EDPlayerJournal/BGS/Parsers/MarketBuyParser.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using EDPlayerJournal.Entries;
|
||||
|
||||
namespace EDPlayerJournal.BGS;
|
||||
|
||||
internal class MarketBuyParser : ITransactionParserPart {
|
||||
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||
MarketBuyEntry? entry = e as MarketBuyEntry;
|
||||
if (entry == null) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
context.BoughtCargo(entry.Type, entry.BuyPrice);
|
||||
|
||||
// We still want the information on buy price for profit,
|
||||
// but if the option is on, we don't care for parsing it
|
||||
// further.
|
||||
// TODO: might be wise to split this parser into two; one for
|
||||
// determining profit, the other for the BGS information
|
||||
if (options.IgnoreMarketBuy) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (context.StationOwner == null) {
|
||||
transactions.AddIncomplete(
|
||||
new OrganicData(),
|
||||
"Could not discern the station owner for market buy.",
|
||||
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 BuyCargo(entry) {
|
||||
System = context.CurrentSystem,
|
||||
Station = context.CurrentStation,
|
||||
Faction = context.StationOwner,
|
||||
IsLegacy = context.IsLegacy,
|
||||
});
|
||||
}
|
||||
}
|
45
EDPlayerJournal/BGS/Parsers/MarketSellParser.cs
Normal file
45
EDPlayerJournal/BGS/Parsers/MarketSellParser.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using EDPlayerJournal.Entries;
|
||||
|
||||
namespace EDPlayerJournal.BGS;
|
||||
|
||||
internal class MarketSellParser : ITransactionParserPart {
|
||||
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||
long profit = 0;
|
||||
|
||||
if (context.StationOwner == null) {
|
||||
transactions.AddIncomplete(
|
||||
new SellCargo(),
|
||||
"Could not discern the station owner market sell.",
|
||||
e);
|
||||
return;
|
||||
}
|
||||
|
||||
// Ignore if its a fleet carrier faction.
|
||||
if (string.Compare(context.StationOwner, Factions.FleetCarrier, StringComparison.OrdinalIgnoreCase) == 0 &&
|
||||
options.IgnoreFleetCarrierFaction) {
|
||||
return;
|
||||
}
|
||||
|
||||
MarketSellEntry? entry = e as MarketSellEntry;
|
||||
if (entry == null) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
if (entry.Type == null) {
|
||||
throw new InvalidJournalEntryException("market sell contains no cargo type");
|
||||
}
|
||||
|
||||
if (context.BuyCost.ContainsKey(entry.Type)) {
|
||||
long avg = context.BuyCost[entry.Type];
|
||||
profit = (long)entry.TotalSale - (avg * entry.Count);
|
||||
}
|
||||
|
||||
transactions.Add(new SellCargo(entry) {
|
||||
System = context.CurrentSystem,
|
||||
Station = context.CurrentStation,
|
||||
Faction = context.StationOwner,
|
||||
Profit = profit,
|
||||
IsLegacy = context.IsLegacy,
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
using EDPlayerJournal.Entries;
|
||||
|
||||
namespace EDPlayerJournal.BGS;
|
||||
|
||||
internal class MultiSellExplorationDataParser : ITransactionParserPart {
|
||||
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||
MultiSellExplorationDataEntry? entry = e as MultiSellExplorationDataEntry;
|
||||
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,
|
||||
});
|
||||
}
|
||||
}
|
33
EDPlayerJournal/BGS/Parsers/SellExplorationDataParser.cs
Normal file
33
EDPlayerJournal/BGS/Parsers/SellExplorationDataParser.cs
Normal file
@ -0,0 +1,33 @@
|
||||
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,
|
||||
});
|
||||
}
|
||||
}
|
38
EDPlayerJournal/BGS/Parsers/SellOrganicDataParser.cs
Normal file
38
EDPlayerJournal/BGS/Parsers/SellOrganicDataParser.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using EDPlayerJournal.Entries;
|
||||
|
||||
namespace EDPlayerJournal.BGS;
|
||||
|
||||
internal class SellOrganicDataParser : ITransactionParserPart {
|
||||
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||
// If exo biology is ignored, simply do nothing
|
||||
if (options.IgnoreExoBiology) {
|
||||
return;
|
||||
}
|
||||
|
||||
SellOrganicDataEntry? entry = e as SellOrganicDataEntry;
|
||||
if (entry == null) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
if (context.StationOwner == null) {
|
||||
transactions.AddIncomplete(
|
||||
new OrganicData(),
|
||||
"Could not discern the station owner for organic data 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 OrganicData(entry) {
|
||||
System = context.CurrentSystem,
|
||||
Station = context.CurrentStation,
|
||||
Faction = context.StationOwner,
|
||||
IsLegacy = context.IsLegacy,
|
||||
});
|
||||
}
|
||||
}
|
@ -23,6 +23,11 @@ public class TransactionParserOptions {
|
||||
/// disabled.
|
||||
/// </summary>
|
||||
public bool IgnoreMarketBuy { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Whether we should ignore things done for the fleet carrier faction.
|
||||
/// </summary>
|
||||
public bool IgnoreFleetCarrierFaction { get; set; } = true;
|
||||
}
|
||||
|
||||
public class TransactionList : List<Transaction> {
|
||||
@ -452,83 +457,6 @@ internal class MissionFailedParser : ITransactionParserPart {
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
transactions.Add(new Cartographics(entry) {
|
||||
System = context.CurrentSystem,
|
||||
Station = context.CurrentStation,
|
||||
Faction = context.StationOwner,
|
||||
IsLegacy = context.IsLegacy,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
internal class SellOrganicDataParser : ITransactionParserPart {
|
||||
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||
// If exo biology is ignored, simply do nothing
|
||||
if (options.IgnoreExoBiology) {
|
||||
return;
|
||||
}
|
||||
|
||||
SellOrganicDataEntry? entry = e as SellOrganicDataEntry;
|
||||
if (entry == null) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
if (context.StationOwner == null) {
|
||||
transactions.AddIncomplete(
|
||||
new OrganicData(),
|
||||
"Could not discern the station owner for organic data sell.",
|
||||
e);
|
||||
return;
|
||||
}
|
||||
|
||||
transactions.Add(new OrganicData(entry) {
|
||||
System = context.CurrentSystem,
|
||||
Station = context.CurrentStation,
|
||||
Faction = context.StationOwner,
|
||||
IsLegacy = context.IsLegacy,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
internal class MultiSellExplorationDataParser : ITransactionParserPart {
|
||||
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||
MultiSellExplorationDataEntry? entry = e as MultiSellExplorationDataEntry;
|
||||
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;
|
||||
}
|
||||
|
||||
transactions.Add(new Cartographics(entry) {
|
||||
System = context.CurrentSystem,
|
||||
Station = context.CurrentStation,
|
||||
Faction = context.StationOwner,
|
||||
IsLegacy = context.IsLegacy,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
internal class RedeemVoucherParser : ITransactionParserPart {
|
||||
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||
RedeemVoucherEntry? entry = e as RedeemVoucherEntry;
|
||||
@ -634,77 +562,6 @@ internal class SearchAndRescueParser : ITransactionParserPart {
|
||||
}
|
||||
}
|
||||
|
||||
internal class MarketBuyParser : ITransactionParserPart {
|
||||
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||
MarketBuyEntry? entry = e as MarketBuyEntry;
|
||||
if (entry == null) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
context.BoughtCargo(entry.Type, entry.BuyPrice);
|
||||
|
||||
// We still want the information on buy price for profit,
|
||||
// but if the option is on, we don't care for parsing it
|
||||
// further.
|
||||
// TODO: might be wise to split this parser into two; one for
|
||||
// determining profit, the other for the BGS information
|
||||
if (options.IgnoreMarketBuy) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (context.StationOwner == null) {
|
||||
transactions.AddIncomplete(
|
||||
new OrganicData(),
|
||||
"Could not discern the station owner for market buy.",
|
||||
e);
|
||||
return;
|
||||
}
|
||||
|
||||
transactions.Add(new BuyCargo(entry) {
|
||||
System = context.CurrentSystem,
|
||||
Station = context.CurrentStation,
|
||||
Faction = context.StationOwner,
|
||||
IsLegacy = context.IsLegacy,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
internal class MarketSellParser : ITransactionParserPart {
|
||||
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||
long profit = 0;
|
||||
|
||||
if (context.StationOwner == null) {
|
||||
transactions.AddIncomplete(
|
||||
new OrganicData(),
|
||||
"Could not discern the station owner market sell.",
|
||||
e);
|
||||
return;
|
||||
}
|
||||
|
||||
MarketSellEntry? entry = e as MarketSellEntry;
|
||||
if (entry == null) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
if (entry.Type == null) {
|
||||
throw new InvalidJournalEntryException("market sell contains no cargo type");
|
||||
}
|
||||
|
||||
if (context.BuyCost.ContainsKey(entry.Type)) {
|
||||
long avg = context.BuyCost[entry.Type];
|
||||
profit = (long)entry.TotalSale - (avg * entry.Count);
|
||||
}
|
||||
|
||||
transactions.Add(new SellCargo(entry) {
|
||||
System = context.CurrentSystem,
|
||||
Station = context.CurrentStation,
|
||||
Faction = context.StationOwner,
|
||||
Profit = profit,
|
||||
IsLegacy = context.IsLegacy,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
internal class FactionKillBondParser : ITransactionParserPart {
|
||||
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||
FactionKillBondEntry? entry = e as FactionKillBondEntry;
|
||||
|
Loading…
Reference in New Issue
Block a user