Archived
1
0

Compare commits

...

4 Commits

5 changed files with 59 additions and 27 deletions

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
using NonaBGS.Journal;
namespace NonaBGS.BGS {
public class LogEntry {
public class LogEntry : IComparable<LogEntry> {
private List<Entry> entries = new List<Entry>();
public List<Entry> Entries => entries;
@ -20,5 +20,9 @@ namespace NonaBGS.BGS {
public virtual bool OnlyControllingFaction {
get { return false; }
}
public virtual int CompareTo(LogEntry other) {
throw new NotImplementedException("not implemented");
}
}
}

View File

@ -60,6 +60,7 @@ namespace NonaBGS.BGS {
foreach (var e in relevant) {
LogEntry entry = null;
bool collate = false;
if (e.Is(Events.Docked)) {
/* gleem the current station from this message
@ -95,6 +96,8 @@ namespace NonaBGS.BGS {
entry.System = current_system;
entry.Station = current_station;
entry.Faction = controlling_faction;
collate = true;
} else if (e.Is(Events.SellMicroResources)) {
entry = new SellMicroResources(current_system, current_station);
entry.Entries.Add(e);
@ -122,7 +125,21 @@ namespace NonaBGS.BGS {
.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);
}
}

View File

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

View File

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

View File

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