diff --git a/BGS/DiscordLogGenerator.cs b/BGS/DiscordLogGenerator.cs index 7e2c9a6..b9d6e40 100644 --- a/BGS/DiscordLogGenerator.cs +++ b/BGS/DiscordLogGenerator.cs @@ -33,7 +33,7 @@ namespace EliteBGS.BGS { StringBuilder log = new StringBuilder(); log.AppendFormat("**Date:** {0}\n", DateTime.Now.ToString("dd/MM/yyyy")); - log.AppendFormat("**Location:** {0}\n", objective.ToShortString()); + log.AppendFormat("**Location:** {0}\n", objective.ToLocationString()); log.AppendFormat("**Faction:** {0}\n", objective.Faction); log.AppendLine(""); log.AppendLine("```"); diff --git a/BGS/NonaDiscordLog.cs b/BGS/NonaDiscordLog.cs index 59ab23a..c4b9935 100644 --- a/BGS/NonaDiscordLog.cs +++ b/BGS/NonaDiscordLog.cs @@ -33,7 +33,7 @@ namespace EliteBGS.BGS { protected override string GenerateObjectiveHeader(Objective objective) { StringBuilder log = new StringBuilder(); - log.AppendFormat(":globe_with_meridians: `Location:` {0}\n", objective.ToShortString()); + log.AppendFormat(":globe_with_meridians: `Location:` {0}\n", objective.ToLocationString()); log.Append(":clipboard: `Conducted:`\n"); log.Append("```"); diff --git a/BGS/Objective.cs b/BGS/Objective.cs index d60cc7e..1aa6333 100644 --- a/BGS/Objective.cs +++ b/BGS/Objective.cs @@ -5,37 +5,30 @@ using Newtonsoft.Json; namespace EliteBGS.BGS { public class Objective : IComparable { - private string system; - private string station; - private string faction; - - private List entries = new List(); - [JsonIgnore] public bool IsEnabled { get; set; } [JsonIgnore] - public List Children { - get => entries; - } + public List Children { get; } = new List(); [JsonIgnore] - public string Name => this.ToString(); + public string Name { + get { return this.ToString(); } + } [JsonIgnore] public bool IsExpanded { get; set; } [JsonIgnore] public List LogEntries { - get => entries; - set => entries = value; + get => Children; } public void Clear() { - if (entries == null) { + if (LogEntries == null) { return; } - entries.RemoveAll(x => !x.ManuallyAdded); + LogEntries.RemoveAll(x => !x.ManuallyAdded); } public bool ManuallyAdded { get; set; } @@ -49,8 +42,8 @@ namespace EliteBGS.BGS { } } - if (e.Faction != null && faction != null) { - if (string.Compare(e.Faction, faction, true) != 0) { + if (e.Faction != null && Faction != null) { + if (string.Compare(e.Faction, Faction, true) != 0) { /* if we have a faction, and it doesn't match we don't care. * faction is the most important comparision, so if it doesn't match * it is not the right objective @@ -62,18 +55,13 @@ namespace EliteBGS.BGS { } /* system and station only add to the match strength though */ - if (e.System != null && system != null) { - if (string.Compare(e.System, system, true) == 0) { + if (e.System != null && System != null) { + if (string.Compare(e.System, System, true) == 0) { ++match_count; } } - /* if system and faction already match, station is not so important */ - if (e.Station != null && station != null) { - if (string.Compare(e.Station, station, true) == 0) { - ++match_count; - } - } + /* station does not matter */ return match_count; } @@ -86,51 +74,36 @@ namespace EliteBGS.BGS { public bool IsValid => System != null && Faction != null; - public string System { - get { return system; } - set { system = value; } - } + public string System { get; set; } - public string Station { - get { return station; } - set { station = value; } - } + public string Station { get; set; } - public string Faction { - get { return faction; } - set { faction = value; } - } + public string Faction { get; set; } public override string ToString() { StringBuilder str = new StringBuilder(); - if (system != null && system.Length > 0) { - str.AppendFormat("System: {0}", system); + if (!string.IsNullOrEmpty(System)) { + str.AppendFormat("System: {0}", System); } - if (station != null && station.Length > 0) { + if (!string.IsNullOrEmpty(Faction)) { if (str.Length > 0) { str.Append(", "); } - str.AppendFormat("Station: {0}", station); - } - if (faction != null && faction.Length > 0) { - if (str.Length > 0) { - str.Append(", "); - } - str.AppendFormat("Faction: {0}", faction); + str.AppendFormat("Faction: {0}", Faction); } return str.ToString(); } - public string ToShortString() { + public string ToLocationString() { StringBuilder str = new StringBuilder(); - if (system != null && system.Length > 0) { - str.AppendFormat("{0}", system); + if (!string.IsNullOrEmpty(System)) { + str.AppendFormat("{0}", System); } - if (station != null && station.Length > 0) { + if (!string.IsNullOrEmpty(Station)) { if (str.Length > 0) { str.Append(", "); } - str.AppendFormat("{0}", station); + str.AppendFormat("{0}", Station); } return str.ToString(); }