drop station from list, it doesn't matter

This commit is contained in:
Florian Stinglmayr 2022-11-06 15:41:12 +01:00
parent 03e7fcbc15
commit 19513d50e9
3 changed files with 26 additions and 53 deletions

View File

@ -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("```");

View File

@ -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("```");

View File

@ -5,37 +5,30 @@ using Newtonsoft.Json;
namespace EliteBGS.BGS {
public class Objective : IComparable<Objective> {
private string system;
private string station;
private string faction;
private List<LogEntry> entries = new List<LogEntry>();
[JsonIgnore]
public bool IsEnabled { get; set; }
[JsonIgnore]
public List<LogEntry> Children {
get => entries;
}
public List<LogEntry> Children { get; } = new List<LogEntry>();
[JsonIgnore]
public string Name => this.ToString();
public string Name {
get { return this.ToString(); }
}
[JsonIgnore]
public bool IsExpanded { get; set; }
[JsonIgnore]
public List<LogEntry> 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();
}