Archived
1
0

Compare commits

..

No commits in common. "81e17e770031251e783ceafbcfb4605bae0e6272" and "ef3af72313afe0ff94fafddf9d04ba495d7a09b9" have entirely different histories.

5 changed files with 27 additions and 59 deletions

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
using NonaBGS.Journal; using NonaBGS.Journal;
namespace NonaBGS.BGS { namespace NonaBGS.BGS {
public class LogEntry : IComparable<LogEntry> { public class 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,9 +20,5 @@ 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");
}
} }
} }

View File

@ -60,7 +60,6 @@ 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
@ -96,8 +95,6 @@ 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);
@ -125,21 +122,7 @@ 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);
} }
} }

View File

@ -1,10 +1,12 @@
using System.Linq; using System;
using System.Globalization; using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NonaBGS.Journal; using NonaBGS.Journal;
namespace NonaBGS.BGS { namespace NonaBGS.BGS {
public class Vouchers : LogEntry { public class Vouchers : LogEntry {
private string type = null;
public int TotalSum { public int TotalSum {
get { get {
@ -17,34 +19,21 @@ namespace NonaBGS.BGS {
public string Type { public string Type {
get { get {
if (type == null) { string v = Entries
string v = Entries .Where(x => x.GetType() == typeof(RedeemVoucherEntry))
.Where(x => x.GetType() == typeof(RedeemVoucherEntry)) .GroupBy(x => (x as RedeemVoucherEntry).Type)
.GroupBy(x => (x as RedeemVoucherEntry).Type) .Select(x => x.Key)
.Select(x => x.Key) .First();
.First(); return v;
type = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(v);
}
return type;
} }
} }
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)); StringBuilder builder = new StringBuilder();
builder.AppendFormat("{0} Vouchers: {1}", Type, Credits.FormatCredits(TotalSum));
return builder.ToString();
} }
/// <summary> /// <summary>

View File

@ -1,18 +1,21 @@
using System.Globalization; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NonaBGS.Journal { namespace NonaBGS.Journal {
public class Credits { public class Credits {
public static string FormatCredits(int amount) { public static string FormatCredits(int amount) {
var format = CultureInfo.CurrentCulture.NumberFormat;
if ((amount % 1000000) == 0) { if ((amount % 1000000) == 0) {
amount /= 1000000; amount /= 1000000;
return string.Format("{0}M CR", amount.ToString(format)); return string.Format("{0}M CR", amount);
} else if ((amount % 1000) == 0) { } else if ((amount % 1000) == 0) {
amount /= 1000; amount /= 1000;
return string.Format("{0}K CR", amount.ToString(format)); return string.Format("{0}K CR", amount);
} }
return string.Format("{0} CR", amount.ToString(format)); return string.Format("{0} CR", amount);
} }
} }
} }

View File

@ -21,8 +21,7 @@ namespace NonaBGS.Journal {
private static readonly Dictionary<string, string> humanreadable = new Dictionary<string, string> { private static readonly Dictionary<string, string> humanreadable = new Dictionary<string, string> {
{ "Mission_AltruismCredits_name", "Donate Credits" }, { "Mission_AltruismCredits_name", "Donate Credits" },
{ "Mission_AltruismCredits_Bust_name", "Donate Credits (Bust)" }, { "Mission_AltruismCredits_Bust_name", "Donate Credits (Bust)" },
{ "Mission_Collect_name", "Provide" }, { "Mission_Collect_name", "Collect" },
{ "Mission_Collect_CivilLiberty_name", "Provide (Civil Liberty)" },
{ "Mission_Courier_Democracy_name", "Courier (Democracy)" }, { "Mission_Courier_Democracy_name", "Courier (Democracy)" },
{ "Mission_Courier_Elections_name", "Courier (Elections)" }, { "Mission_Courier_Elections_name", "Courier (Elections)" },
{ "Mission_Courier_name", "Courier" }, { "Mission_Courier_name", "Courier" },
@ -33,9 +32,7 @@ namespace NonaBGS.Journal {
{ "Mission_Delivery_Agriculture_name", "Delivery (Agriculture)" }, { "Mission_Delivery_Agriculture_name", "Delivery (Agriculture)" },
{ "Mission_Delivery_RankEmp_name", "Delivery (Imperial Rank)" }, { "Mission_Delivery_RankEmp_name", "Delivery (Imperial Rank)" },
{ "Mission_HackMegaship_name", "Hack Megaship" }, { "Mission_HackMegaship_name", "Hack Megaship" },
{ "Mission_Hack_BLOPS_Boom_name", "Hack Megaship (Black Ops)" },
{ "Mission_MassacreWing_name", "Massacre (Wing)" }, { "Mission_MassacreWing_name", "Massacre (Wing)" },
{ "Mission_Massacre_RankEmp_name", "Massacre (Imperial Navy)" },
{ "Mission_OnFoot_Onslaught_MB_name", "On Foot Onslaught" }, { "Mission_OnFoot_Onslaught_MB_name", "On Foot Onslaught" },
{ "Mission_OnFoot_Onslaught_Offline_MB_name", "On Foot Onslaught (Offline)" }, { "Mission_OnFoot_Onslaught_Offline_MB_name", "On Foot Onslaught (Offline)" },
{ "Mission_OnFoot_RebootRestore_MB_name", "On Foot Reboot/Restore" }, { "Mission_OnFoot_RebootRestore_MB_name", "On Foot Reboot/Restore" },