From 4cf38379c7774b79cb68446c90dda5b3eddc7fa6 Mon Sep 17 00:00:00 2001 From: Moriarty1982 Date: Wed, 24 Jul 2024 20:29:49 +0200 Subject: [PATCH 1/5] Default values set at properties --- EVEData/System.cs | 46 +++++++++++----------------------------------- 1 file changed, 11 insertions(+), 35 deletions(-) diff --git a/EVEData/System.cs b/EVEData/System.cs index c567cd6e..1c3c4ca8 100644 --- a/EVEData/System.cs +++ b/EVEData/System.cs @@ -12,18 +12,6 @@ namespace SMT.EVEData /// public class System { - /// - /// Initializes a new instance of the class. - /// - public System() - { - Jumps = new List(); - SHStructures = new List(); - - SOVAllianceID = 0; - HasJumpBeacon = false; - } - /// /// Initializes a new instance of the class. /// @@ -31,6 +19,7 @@ public System() /// ID of the system /// Region this system is in /// Does this system contain an NPC station + /// Does this system has an ice belt public System(string name, long id, string region, bool station, bool iceBelt) { Name = name; @@ -38,19 +27,6 @@ public System(string name, long id, string region, bool station, bool iceBelt) Region = region; HasNPCStation = station; HasIceBelt = iceBelt; - - // default the ESI stats - NPCKillsLastHour = 0; - NPCKillsDeltaLastHour = 0; - PodKillsLastHour = 0; - ShipKillsLastHour = 0; - JumpsLastHour = 0; - ActiveIncursion = false; - - SOVAllianceID = 0; - - Jumps = new List(); - SHStructures = new List(); } public enum EdenComTrigStatus @@ -67,7 +43,7 @@ public enum EdenComTrigStatus /// Gets or sets the an incursion is active in this system /// [XmlIgnoreAttribute] - public bool ActiveIncursion { get; set; } + public bool ActiveIncursion { get; set; } = false; /// /// Gets or sets the X coordinate in real space for this system @@ -120,7 +96,7 @@ public enum EdenComTrigStatus public bool FactionWarSystem { get; set; } [XmlIgnoreAttribute] - public bool HasJumpBeacon { get; set; } + public bool HasJumpBeacon { get; set; } = false; /// /// Gets or sets if this system has an NPC Station @@ -144,13 +120,13 @@ public enum EdenComTrigStatus /// /// Gets or sets the list of Jumps from this system /// - public List Jumps { get; set; } + public List Jumps { get; set; } = new(); /// /// Gets or sets the number of pods killed in the last hour /// [XmlIgnoreAttribute] - public int JumpsLastHour { get; set; } + public int JumpsLastHour { get; set; } = 0; /// /// Gets or sets the Name of the system @@ -161,13 +137,13 @@ public enum EdenComTrigStatus /// Gets or sets the delta of NPC Kills in the last hour /// [XmlIgnoreAttribute] - public int NPCKillsDeltaLastHour { get; set; } + public int NPCKillsDeltaLastHour { get; set; } = 0; /// /// Gets or sets the number of NPC Kills in the last hour /// [XmlIgnoreAttribute] - public int NPCKillsLastHour { get; set; } + public int NPCKillsLastHour { get; set; } = 0; /// /// Gets or sets the Faction of the system if owned by an NPC Corp @@ -179,7 +155,7 @@ public enum EdenComTrigStatus /// Gets or sets the number of pod kills in the last hour /// [XmlIgnoreAttribute] - public int PodKillsLastHour { get; set; } + public int PodKillsLastHour { get; set; } = 0; public double RadiusAU { get; set; } @@ -192,19 +168,19 @@ public enum EdenComTrigStatus /// Gets or sets the number of player ships killed in the last hour /// [XmlIgnoreAttribute] - public int ShipKillsLastHour { get; set; } + public int ShipKillsLastHour { get; set; } = 0; /// /// Gets or sets the an incursion is active in this system /// [XmlIgnoreAttribute] - public List SHStructures { get; set; } + public List SHStructures { get; set; } = new(); /// /// Gets or sets the name of the alliance holding sov in this system /// [XmlIgnoreAttribute] - public int SOVAllianceID { get; set; } + public int SOVAllianceID { get; set; } = 0; /// /// Gets or sets the name of the corporation holding sov in this system From 6e18626fcbb345baac38e96ea4207d96d87e20b5 Mon Sep 17 00:00:00 2001 From: Moriarty1982 Date: Wed, 24 Jul 2024 20:30:18 +0200 Subject: [PATCH 2/5] Rewrite ToString() to shorthand function --- EVEData/System.cs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/EVEData/System.cs b/EVEData/System.cs index 1c3c4ca8..a99da67c 100644 --- a/EVEData/System.cs +++ b/EVEData/System.cs @@ -211,18 +211,6 @@ public string SecType return "High Sec"; } - if (TrueSec > 0.0 && TrueSec < 0.45) - { - return "Low Sec"; - } - - return "Null Sec"; - } - } - - public override string ToString() - { - return $"{Name} ({Region})"; - } + public override string ToString() => $"{Name} ({Region})"; } } \ No newline at end of file From 8a7bc3ea6bc2da6d5750094d3fd0eff440aecdff Mon Sep 17 00:00:00 2001 From: Moriarty1982 Date: Wed, 24 Jul 2024 20:31:32 +0200 Subject: [PATCH 3/5] Rewrite: SecType readonly getter Use the new switch syntax --- EVEData/System.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/EVEData/System.cs b/EVEData/System.cs index a99da67c..fa0fb5eb 100644 --- a/EVEData/System.cs +++ b/EVEData/System.cs @@ -202,14 +202,11 @@ public enum EdenComTrigStatus /// public double TrueSec { get; set; } - public string SecType - { - get - { - if (TrueSec >= 0.45) - { - return "High Sec"; - } + public string SecType => String.Join((TrueSec switch { + double s when s >= 0.45 => "High", + double s when s > 0.0 && s < 0.45 => "Low", + _ => "Null" + }), " Sec"); public override string ToString() => $"{Name} ({Region})"; } From 63d77e186df2c3f6354758f1980236fb3cf6b7ce Mon Sep 17 00:00:00 2001 From: Moriarty1982 Date: Wed, 24 Jul 2024 20:41:57 +0200 Subject: [PATCH 4/5] Update System.cs --- EVEData/System.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/EVEData/System.cs b/EVEData/System.cs index fa0fb5eb..542a218d 100644 --- a/EVEData/System.cs +++ b/EVEData/System.cs @@ -203,11 +203,11 @@ public enum EdenComTrigStatus public double TrueSec { get; set; } public string SecType => String.Join((TrueSec switch { - double s when s >= 0.45 => "High", - double s when s > 0.0 && s < 0.45 => "Low", + >= 0.45 => "High", + > 0.05 and < 0.45 => "Low", _ => "Null" }), " Sec"); public override string ToString() => $"{Name} ({Region})"; } -} \ No newline at end of file +} From 3737fcee2eba63e4380233644ca14f68c1ad4230 Mon Sep 17 00:00:00 2001 From: Moriarty1982 Date: Wed, 24 Jul 2024 20:45:01 +0200 Subject: [PATCH 5/5] Update System.cs --- EVEData/System.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EVEData/System.cs b/EVEData/System.cs index 542a218d..9b2cfc83 100644 --- a/EVEData/System.cs +++ b/EVEData/System.cs @@ -204,7 +204,7 @@ public enum EdenComTrigStatus public string SecType => String.Join((TrueSec switch { >= 0.45 => "High", - > 0.05 and < 0.45 => "Low", + > 0.0 and < 0.45 => "Low", _ => "Null" }), " Sec");