allow each step to generate more than one result
This commit is contained in:
parent
7274436ff2
commit
3e15096dfc
@ -4,10 +4,8 @@ using EDJournal;
|
||||
|
||||
namespace EliteBGS.BGS {
|
||||
public class Cartographics : LogEntry {
|
||||
public Cartographics(MultiSellExplorationDataEntry e, string current_system, string current_station) {
|
||||
public Cartographics(MultiSellExplorationDataEntry e) {
|
||||
Entries.Add(e);
|
||||
System = current_system;
|
||||
Station = current_station;
|
||||
}
|
||||
|
||||
public int TotalSum {
|
||||
|
@ -35,6 +35,6 @@ namespace EliteBGS.BGS {
|
||||
throw new NotImplementedException("not implemented");
|
||||
}
|
||||
|
||||
public string Name => this.ToString();
|
||||
public string Name => ToString();
|
||||
}
|
||||
}
|
||||
|
111
BGS/Report.cs
111
BGS/Report.cs
@ -65,7 +65,7 @@ namespace EliteBGS.BGS {
|
||||
objectives.ForEach(x => x.Clear());
|
||||
|
||||
foreach (var e in relevant) {
|
||||
LogEntry entry = null;
|
||||
List<LogEntry> results = new List<LogEntry>();
|
||||
bool collate = false;
|
||||
|
||||
if (e.Is(Events.Docked)) {
|
||||
@ -94,10 +94,10 @@ namespace EliteBGS.BGS {
|
||||
}
|
||||
} else if (e.Is(Events.MissionCompleted)) {
|
||||
var completed = e as MissionCompletedEntry;
|
||||
entry = new MissionCompleted(completed) {
|
||||
results.Add(new MissionCompleted(completed) {
|
||||
System = current_system,
|
||||
Station = current_station
|
||||
};
|
||||
});
|
||||
if (completed.HumanReadableNameWasGenerated) {
|
||||
/* If the human readable name was generated, we send a log message. Because the
|
||||
* generated names all sort of suck, we should have more human readable names in
|
||||
@ -118,7 +118,7 @@ namespace EliteBGS.BGS {
|
||||
"Please adjust start date to when the mission was accepted to include it in the list.");
|
||||
continue;
|
||||
}
|
||||
entry = new MissionFailed(accepted) { Failed = failed, System = current_system };
|
||||
results.Add(new MissionFailed(accepted) { Failed = failed, System = current_system });
|
||||
if (failed.HumanReadableName == null) {
|
||||
OnLog?.Invoke("Human readable name for mission \"" +
|
||||
failed.Name +
|
||||
@ -131,27 +131,28 @@ namespace EliteBGS.BGS {
|
||||
} else if (e.Is(Events.MultiSellExplorationData)) {
|
||||
/* For multi-sell-exploraton-data only the controlling faction of the station sold to matters.
|
||||
*/
|
||||
entry = new Cartographics(e as MultiSellExplorationDataEntry, current_system, current_station);
|
||||
entry.Faction = controlling_faction;
|
||||
results.Add(new Cartographics(e as MultiSellExplorationDataEntry) {
|
||||
System = current_system,
|
||||
Station = current_station,
|
||||
Faction = controlling_faction
|
||||
});
|
||||
} else if (e.Is(Events.RedeemVoucher)) {
|
||||
/* Same for selling combat vouchers. Only the current controlling faction matters here.
|
||||
*/
|
||||
entry = new Vouchers();
|
||||
entry.Entries.Add(e);
|
||||
entry.System = current_system;
|
||||
entry.Station = current_station;
|
||||
entry.Faction = (e as RedeemVoucherEntry).Factions.FirstOrDefault() ?? "";
|
||||
entry.ControllingFaction = controlling_faction;
|
||||
results.Add(new Vouchers(e as RedeemVoucherEntry) {
|
||||
System = current_system,
|
||||
Station = current_station,
|
||||
Faction = (e as RedeemVoucherEntry).Factions.FirstOrDefault() ?? "",
|
||||
ControllingFaction = controlling_faction,
|
||||
});
|
||||
|
||||
collate = true;
|
||||
} else if (e.Is(Events.SellMicroResources)) {
|
||||
entry = new SellMicroResources() {
|
||||
results.Add(new SellMicroResources(e as SellMicroResourcesEntry) {
|
||||
Faction = controlling_faction,
|
||||
Station = current_station,
|
||||
System = current_system
|
||||
};
|
||||
|
||||
entry.Entries.Add(e);
|
||||
});
|
||||
} else if (e.Is(Events.MarketBuy)) {
|
||||
MarketBuyEntry buy = e as MarketBuyEntry;
|
||||
if (string.IsNullOrEmpty(buy.Type) || buy.BuyPrice == 0) {
|
||||
@ -169,60 +170,60 @@ namespace EliteBGS.BGS {
|
||||
profit = sell.TotalSale - (avg * sell.Count);
|
||||
}
|
||||
|
||||
entry = new SellCargo() {
|
||||
results.Add(new SellCargo(e as MarketSellEntry) {
|
||||
Faction = controlling_faction,
|
||||
Station = current_station,
|
||||
System = current_system,
|
||||
Profit = profit
|
||||
};
|
||||
|
||||
entry.Entries.Add(e);
|
||||
});
|
||||
}
|
||||
|
||||
if (entry == null) {
|
||||
if (results == null || results.Count <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Find all objectives that generally match.
|
||||
*/
|
||||
var matches = objectives
|
||||
.Where(x => x.Matches(entry) > 0)
|
||||
.OrderBy(x => x.Matches(entry))
|
||||
;
|
||||
|
||||
Objective objective = null;
|
||||
if (matches != null && matches.Count() > 0) {
|
||||
/* Then select the one that matches the most.
|
||||
foreach (LogEntry entry in results) {
|
||||
/* Find all objectives that generally match.
|
||||
*/
|
||||
objective = matches
|
||||
var matches = objectives
|
||||
.Where(x => x.Matches(entry) > 0)
|
||||
.OrderBy(x => x.Matches(entry))
|
||||
.Reverse()
|
||||
.First()
|
||||
;
|
||||
} else {
|
||||
/* create a new objective if we don't have one */
|
||||
objective = new Objective() {
|
||||
Station = entry.Station,
|
||||
Faction = entry.Faction,
|
||||
System = entry.System,
|
||||
};
|
||||
objectives.Add(objective);
|
||||
}
|
||||
|
||||
LogEntry existing = null;
|
||||
|
||||
existing = objective.LogEntries.Find(x => {
|
||||
try {
|
||||
return x.CompareTo(entry) == 0;
|
||||
} catch (NotImplementedException) {
|
||||
return false;
|
||||
Objective objective = null;
|
||||
if (matches != null && matches.Count() > 0) {
|
||||
/* Then select the one that matches the most.
|
||||
*/
|
||||
objective = matches
|
||||
.OrderBy(x => x.Matches(entry))
|
||||
.Reverse()
|
||||
.First()
|
||||
;
|
||||
} else {
|
||||
/* create a new objective if we don't have one */
|
||||
objective = new Objective() {
|
||||
Station = entry.Station,
|
||||
Faction = entry.Faction,
|
||||
System = entry.System,
|
||||
};
|
||||
objectives.Add(objective);
|
||||
}
|
||||
});
|
||||
|
||||
if (collate && existing != null) {
|
||||
existing.Entries.Add(e);
|
||||
} else if (!collate || existing == null) {
|
||||
objective.LogEntries.Add(entry);
|
||||
LogEntry existing = null;
|
||||
|
||||
existing = objective.LogEntries.Find(x => {
|
||||
try {
|
||||
return x.CompareTo(entry) == 0;
|
||||
} catch (NotImplementedException) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (collate && existing != null) {
|
||||
existing.Entries.Add(e);
|
||||
} else if (!collate || existing == null) {
|
||||
objective.LogEntries.Add(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,13 @@ using EDJournal;
|
||||
namespace EliteBGS.BGS {
|
||||
public class SellCargo : LogEntry {
|
||||
public int Profit { get; set; }
|
||||
|
||||
public SellCargo() { }
|
||||
|
||||
public SellCargo(MarketSellEntry e) {
|
||||
Entries.Add(e);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
var sold = Entries.OfType<MarketSellEntry>().ToArray();
|
||||
|
@ -12,6 +12,12 @@ namespace EliteBGS.BGS {
|
||||
}
|
||||
}
|
||||
|
||||
public SellMicroResources() { }
|
||||
|
||||
public SellMicroResources(SellMicroResourcesEntry e) {
|
||||
Entries.Add(e);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format("Sell Micro Resources: {0}", Credits.FormatCredits(TotalSum));
|
||||
}
|
||||
|
@ -6,6 +6,13 @@ namespace EliteBGS.BGS {
|
||||
public class Vouchers : LogEntry {
|
||||
private string type = null;
|
||||
|
||||
public Vouchers() {
|
||||
}
|
||||
|
||||
public Vouchers(RedeemVoucherEntry e) {
|
||||
Entries.Add(e);
|
||||
}
|
||||
|
||||
public int TotalSum {
|
||||
get {
|
||||
return Entries
|
||||
|
Loading…
Reference in New Issue
Block a user