allow bounties to be collated together if they are the same type
This commit is contained in:
parent
dfd66c9fb6
commit
8796078b67
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
using NonaBGS.Journal;
|
using NonaBGS.Journal;
|
||||||
|
|
||||||
namespace NonaBGS.BGS {
|
namespace NonaBGS.BGS {
|
||||||
public class LogEntry {
|
public class LogEntry : IComparable<LogEntry> {
|
||||||
private List<Entry> entries = new List<Entry>();
|
private List<Entry> entries = new List<Entry>();
|
||||||
|
|
||||||
public List<Entry> Entries => entries;
|
public List<Entry> Entries => entries;
|
||||||
@ -20,5 +20,9 @@ namespace NonaBGS.BGS {
|
|||||||
public virtual bool OnlyControllingFaction {
|
public virtual bool OnlyControllingFaction {
|
||||||
get { return false; }
|
get { return false; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual int CompareTo(LogEntry other) {
|
||||||
|
throw new NotImplementedException("not implemented");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,7 @@ namespace NonaBGS.BGS {
|
|||||||
|
|
||||||
foreach (var e in relevant) {
|
foreach (var e in relevant) {
|
||||||
LogEntry entry = null;
|
LogEntry entry = null;
|
||||||
|
bool collate = false;
|
||||||
|
|
||||||
if (e.Is(Events.Docked)) {
|
if (e.Is(Events.Docked)) {
|
||||||
/* gleem the current station from this message
|
/* gleem the current station from this message
|
||||||
@ -95,6 +96,8 @@ namespace NonaBGS.BGS {
|
|||||||
entry.System = current_system;
|
entry.System = current_system;
|
||||||
entry.Station = current_station;
|
entry.Station = current_station;
|
||||||
entry.Faction = controlling_faction;
|
entry.Faction = controlling_faction;
|
||||||
|
|
||||||
|
collate = true;
|
||||||
} else if (e.Is(Events.SellMicroResources)) {
|
} else if (e.Is(Events.SellMicroResources)) {
|
||||||
entry = new SellMicroResources(current_system, current_station);
|
entry = new SellMicroResources(current_system, current_station);
|
||||||
entry.Entries.Add(e);
|
entry.Entries.Add(e);
|
||||||
@ -122,7 +125,21 @@ namespace NonaBGS.BGS {
|
|||||||
.First()
|
.First()
|
||||||
;
|
;
|
||||||
|
|
||||||
if (objective != null) {
|
if (objective == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
LogEntry existing = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
existing = objective.LogEntries.Find(x => x.CompareTo(entry) == 0);
|
||||||
|
} catch (NotImplementedException) {
|
||||||
|
// Equivalent to not having found anything
|
||||||
|
existing = null;
|
||||||
|
}
|
||||||
|
if (collate && existing != null) {
|
||||||
|
existing.Entries.Add(e);
|
||||||
|
} else if (!collate || existing == null) {
|
||||||
objective.LogEntries.Add(entry);
|
objective.LogEntries.Add(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,19 @@ namespace NonaBGS.BGS {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override int CompareTo(LogEntry other) {
|
||||||
|
if (other.GetType() != typeof(Vouchers)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
var b = other as Vouchers;
|
||||||
|
if (b.Type == Type) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
public override string ToString() {
|
public override string ToString() {
|
||||||
return string.Format("{0} Vouchers: {1}", Type, Credits.FormatCredits(TotalSum));
|
return string.Format("{0} Vouchers: {1}", Type, Credits.FormatCredits(TotalSum));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user