From de978bb317d2bce90d13e2f5860613c3f8416d9e Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Sun, 23 Dec 2018 20:18:28 +0300 Subject: [PATCH 01/15] use of last match variable/field. --- OWTrack/Tracker.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index 8a7c44b..2b72175 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -205,6 +205,7 @@ namespace OWTrack public void AddMatch(Match match) { + match.LastMatchSR = this.Matches.Last().newSR; this.Matches.Add(match); this.TotalMatches = Matches.Count(); } -- 2.39.5 From 2e78d7ccfe7f36593c5e4fcf2dd704cbda5c1160 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Sun, 23 Dec 2018 20:19:13 +0300 Subject: [PATCH 02/15] Ex handling and API changes --- OWTrack/MainForm.cs | 2 +- OWTrack/saveManeger.cs | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/OWTrack/MainForm.cs b/OWTrack/MainForm.cs index 05a33e6..37078c7 100644 --- a/OWTrack/MainForm.cs +++ b/OWTrack/MainForm.cs @@ -92,7 +92,7 @@ namespace OWTrack } catch (Exception) { - MessageBox.Show("Could not load Save.\n" + + MessageBox.Show("Could not load Save!\n" + "Starting new save."); tr = new Tracker(); } diff --git a/OWTrack/saveManeger.cs b/OWTrack/saveManeger.cs index 74d29a0..1e88428 100644 --- a/OWTrack/saveManeger.cs +++ b/OWTrack/saveManeger.cs @@ -33,6 +33,10 @@ namespace OWTrack public static string GetSaves() { return SAVES; } public static string GetCurrentDir() { return curDir; } + /// + /// Paths of 'Program Files' folders. + /// + /// public struct ProgramFiles { public const string C = "C:\\Program Files"; @@ -47,17 +51,16 @@ namespace OWTrack /// /// Deserialize saved tracker instance. /// - /// + /// Tracker public static Tracker GetSavedTracker() { try { return JsonConvert.DeserializeObject(File.ReadAllText(Paths.GetSaves())); } - catch (Exception) + catch (Exception e) { - Exception ex = new Exception("json"); - throw ex; + throw e; } } @@ -81,8 +84,8 @@ namespace OWTrack /// ///Saves the Tracker Object. /// - /// - /// + /// + /// Boolean Value public static bool SaveJSON(Tracker tracker) { try @@ -90,9 +93,9 @@ namespace OWTrack File.WriteAllText(Paths.GetSaves(), JsonConvert.SerializeObject(tracker, Formatting.Indented)); return true; } - catch (Exception) + catch (Exception e) { - return false; + throw e; } } -- 2.39.5 From dbcdef9bf0e6eedf7c421bcde44da226914def3d Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Sun, 23 Dec 2018 20:39:46 +0300 Subject: [PATCH 03/15] Exception handling --- OWTrack/MainForm.cs | 22 +++++++++++++++------- OWTrack/Tracker.cs | 3 +-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/OWTrack/MainForm.cs b/OWTrack/MainForm.cs index 37078c7..67f0db5 100644 --- a/OWTrack/MainForm.cs +++ b/OWTrack/MainForm.cs @@ -144,16 +144,24 @@ namespace OWTrack private void update() { - Wins.Text = tr.GetWins().ToString(); - Losses.Text = tr.GetLosses().ToString(); - if (tr.newSR == 0) + try { - if (tr.srDiff() < 1) { srLabel.Text = tr.startSR.ToString() + " - 0"; } + Wins.Text = tr.GetWins().ToString(); + Losses.Text = tr.GetLosses().ToString(); + if (tr.newSR == 0) + { + if (tr.srDiff() < 1) { srLabel.Text = tr.startSR.ToString() + " - 0"; } + else srLabel.Text = tr.startSR.ToString() + " - " + tr.srDiff(); + } else srLabel.Text = tr.startSR.ToString() + " - " + tr.srDiff(); + srTextBox.Text = null; + saveManeger.SaveJSON(tr); } - else srLabel.Text = tr.startSR.ToString() + " - " + tr.srDiff(); - srTextBox.Text = null; - saveManeger.SaveJSON(tr); + catch (Exception e) + { + MessageBox.Show(e.Message); + } + } private void AddMatch() diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index 2b72175..ff65364 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -128,8 +128,7 @@ namespace OWTrack } catch (Exception e) { - MessageBox.Show(e.Message); - return false; + throw e; } } -- 2.39.5 From c54c61c4d906cfdafcd2712be3a05aa24d383a39 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Sun, 23 Dec 2018 20:40:17 +0300 Subject: [PATCH 04/15] Unessesery imports --- OWTrack/Tracker.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index ff65364..c1f7238 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -22,7 +22,6 @@ using System; using System.Diagnostics; using System.Linq; using System.IO; -using System.Windows.Forms; using System.Collections.Generic; namespace OWTrack -- 2.39.5 From 8f3d7641148a089edbc009b5f9cd5f0db4c3d4e3 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Sun, 23 Dec 2018 20:40:58 +0300 Subject: [PATCH 05/15] new variable in Match. DateTime String. --- OWTrack/MainForm.cs | 3 ++- OWTrack/Tracker.cs | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/OWTrack/MainForm.cs b/OWTrack/MainForm.cs index 67f0db5..67cd05d 100644 --- a/OWTrack/MainForm.cs +++ b/OWTrack/MainForm.cs @@ -171,7 +171,8 @@ namespace OWTrack StartSR = tr.startSR, newSR = tr.newSR, ChangeInSR = tr.srDiff(), - dateTime = DateTime.Now.Date + dateTime = DateTime.Now.Date, + DateTimeSting = DateTime.Now.ToString("hh:mm tt") }; tr.GetCurrentSession().AddMatch(match); } diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index c1f7238..5faf0b0 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -213,6 +213,7 @@ namespace OWTrack { public Match() { } public DateTime dateTime { get; set; } + public string DateTimeSting; public int StartSR; public int LastMatchSR; public int newSR; -- 2.39.5 From 74cd192c8aae019426e709d753778c17755f0781 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Sun, 23 Dec 2018 20:41:28 +0300 Subject: [PATCH 06/15] Formatting --- OWTrack/MainForm.cs | 6 +++--- OWTrack/Tracker.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/OWTrack/MainForm.cs b/OWTrack/MainForm.cs index 67cd05d..bb0df2a 100644 --- a/OWTrack/MainForm.cs +++ b/OWTrack/MainForm.cs @@ -34,14 +34,14 @@ namespace OWTrack private string Version = Program.Version.ToString(); public MainForm() - { + { InitializeComponent(); - tr = new Tracker(); + tr = new Tracker(); loadSave(); checkStatus(); update(); label4.Text = Version; - Text = "OWTrack " + Version; + Text = "OWTrack " + Version; } private void checkStatus() diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index 5faf0b0..a8a2e54 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -29,7 +29,7 @@ namespace OWTrack class Tracker { public int wins, losses, startSR, newSR, totalMatches = 0; - + public void addWin() => wins++; public void addLoss() => losses++; public void reduceWin() => wins--; @@ -65,7 +65,7 @@ namespace OWTrack sessions.Clear(); StartNewSeission(); } - + public void StartNewSeission() { Session ses = new Session(startSR); @@ -178,7 +178,7 @@ namespace OWTrack public int SkillChange; public int StartSR; public DateTime date; - public List Matches = new List(); + public List Matches = new List(); /// /// Start a new session with a starting Skill Rating -- 2.39.5 From a2d7f8f888762273395feccc711819b9ec6cc7c6 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Sun, 23 Dec 2018 20:52:07 +0300 Subject: [PATCH 07/15] stats class. Incomplete. Add In VS --- OWTrack/Statistics.cs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 OWTrack/Statistics.cs diff --git a/OWTrack/Statistics.cs b/OWTrack/Statistics.cs new file mode 100644 index 0000000..f202751 --- /dev/null +++ b/OWTrack/Statistics.cs @@ -0,0 +1,32 @@ +using System; +using System.IO; +using Newtonsoft.Json; +using System.Collections.Generic; + + +namespace OWTrack +{ + public class Statistics + { + private Tracker tr; + public Statistics(Tracker tr) + { + this.tr = tr; + } + + public int GetTotalSkillChange() + { + int change = 0; + foreach (var Session in tr.sessions) + { + if (Session.Matches.Count != 0) + { + foreach (var match in Session.Matches) + { + + } + } + } + } + } +} \ No newline at end of file -- 2.39.5 From 74fc40f0d521cffbb274fd34473ce05c92a1e7bf Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Tue, 25 Dec 2018 14:22:57 +0300 Subject: [PATCH 08/15] session win/loss --- OWTrack/Tracker.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index a8a2e54..5bc5e5d 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -174,6 +174,7 @@ namespace OWTrack class Session { + public int wins, losses; public int TotalMatches; public int SkillChange; public int StartSR; @@ -206,6 +207,10 @@ namespace OWTrack match.LastMatchSR = this.Matches.Last().newSR; this.Matches.Add(match); this.TotalMatches = Matches.Count(); + if (match.IsWin) + wins++; + else + losses++; } } @@ -213,6 +218,7 @@ namespace OWTrack { public Match() { } public DateTime dateTime { get; set; } + public bool IsWin;//to be used. public string DateTimeSting; public int StartSR; public int LastMatchSR; -- 2.39.5 From b8298a2c4ca9dff310d815954268ca7d5f53f500 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Tue, 25 Dec 2018 14:52:29 +0300 Subject: [PATCH 09/15] cleanup --- OWTrack/MainForm.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/OWTrack/MainForm.cs b/OWTrack/MainForm.cs index bb0df2a..0af0615 100644 --- a/OWTrack/MainForm.cs +++ b/OWTrack/MainForm.cs @@ -71,7 +71,6 @@ namespace OWTrack } } - //Move to saveManeger.cs ? private void loadSave() { try @@ -235,12 +234,6 @@ namespace OWTrack } finally { - //if (!SRonce) - //{ - // tr.startSR = sr; - // SRonce = true; - //} - //else tr.newSR = sr; if (tr.GetCurrentSession().IsNewSession()) tr.startSR = sr; else -- 2.39.5 From 1360a570bcefc1d4143d63b1de12762c01a31699 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Mon, 31 Dec 2018 05:45:37 +0300 Subject: [PATCH 10/15] Moved Settings class --- OWTrack/Settings.cs | 43 +++++++++++++++++++++++++++++++++++++++++++ OWTrack/Tracker.cs | 16 ---------------- 2 files changed, 43 insertions(+), 16 deletions(-) create mode 100644 OWTrack/Settings.cs diff --git a/OWTrack/Settings.cs b/OWTrack/Settings.cs new file mode 100644 index 0000000..83e4384 --- /dev/null +++ b/OWTrack/Settings.cs @@ -0,0 +1,43 @@ +/*Copyright(c) 2018 Hesham Systems LLC. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.*/ + + +namespace OWTrack +{ + class Settings + { + public bool TrackSR, TrackOW = true; + public string GamePath = ""; + + public Settings() + { + } + + /// + /// Reset All values to defult + /// + public void Reset() + { + TrackOW = true; + TrackSR = true; + GamePath = ""; + } + } +} diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index a8a2e54..7d68ca4 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -156,22 +156,6 @@ namespace OWTrack } } - class Settings - { - public bool TrackSR, TrackOW = true; - public string GamePath = ""; - - /// - /// Reset All values to defult - /// - public void Reset() - { - TrackOW = true; - TrackSR = true; - GamePath = ""; - } - } - class Session { public int TotalMatches; -- 2.39.5 From fdcdbdaa7c9493f74282ec902fea69209b746ebb Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Mon, 31 Dec 2018 05:49:10 +0300 Subject: [PATCH 11/15] csProj for settings.cs --- OWTrack/OWTrack.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/OWTrack/OWTrack.csproj b/OWTrack/OWTrack.csproj index a6997e9..a581a43 100644 --- a/OWTrack/OWTrack.csproj +++ b/OWTrack/OWTrack.csproj @@ -113,6 +113,7 @@ MainForm.cs + -- 2.39.5 From 04371ef64524a75fc099c131bbd2e6911e2d2afc Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Mon, 31 Dec 2018 05:49:51 +0300 Subject: [PATCH 12/15] removed funstion --- OWTrack/saveManeger.cs | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/OWTrack/saveManeger.cs b/OWTrack/saveManeger.cs index 1e88428..b9aa9b2 100644 --- a/OWTrack/saveManeger.cs +++ b/OWTrack/saveManeger.cs @@ -64,23 +64,6 @@ namespace OWTrack } } - /// - /// Deserialize saved tracker instance from a Custom path - /// - /// - /// - public static Tracker GetSavedTracker(string customPath) - { - try - { - return JsonConvert.DeserializeObject(File.ReadAllText(customPath)); - } - catch (Exception e) - { - throw e; - } - } - /// ///Saves the Tracker Object. /// -- 2.39.5 From 0634e5c21bbc28c24360f83d8cdf46e6892efbe7 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Mon, 31 Dec 2018 06:29:19 +0300 Subject: [PATCH 13/15] API --- OWTrack/Tracker.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index 5bc5e5d..e653e77 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -174,7 +174,7 @@ namespace OWTrack class Session { - public int wins, losses; + public int wins, losses = 0; public int TotalMatches; public int SkillChange; public int StartSR; @@ -182,7 +182,7 @@ namespace OWTrack public List Matches = new List(); /// - /// Start a new session with a starting Skill Rating + /// Start a new session /// public Session(int StartSR) { @@ -191,17 +191,29 @@ namespace OWTrack TotalMatches = 0; } + /// + /// Check if session does not have any matches + /// + /// Booelan public bool IsNewSession() { if (Matches.Count == 0) return true; else return false; } + /// + /// Get last match in Matchs list + /// + /// Match public Match GetLastMatch() { return Matches.Last(); } + /// + /// Add Match to list + /// + /// public void AddMatch(Match match) { match.LastMatchSR = this.Matches.Last().newSR; -- 2.39.5 From 16afdb74ac76d4aa83294862612b91f14515b4e6 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Mon, 31 Dec 2018 06:29:44 +0300 Subject: [PATCH 14/15] Implement LastMatchSR --- OWTrack/MainForm.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OWTrack/MainForm.cs b/OWTrack/MainForm.cs index 0af0615..267b139 100644 --- a/OWTrack/MainForm.cs +++ b/OWTrack/MainForm.cs @@ -171,7 +171,8 @@ namespace OWTrack newSR = tr.newSR, ChangeInSR = tr.srDiff(), dateTime = DateTime.Now.Date, - DateTimeSting = DateTime.Now.ToString("hh:mm tt") + DateTimeSting = DateTime.Now.ToString("hh:mm tt"), + LastMatchSR = tr.GetCurrentSession().GetLastMatch().newSR, }; tr.GetCurrentSession().AddMatch(match); } -- 2.39.5 From 6b9413ec93bd578d42a84ebbd7cd1a8da5e76c9d Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Mon, 31 Dec 2018 06:30:07 +0300 Subject: [PATCH 15/15] IsWIn bool in Match --- OWTrack/Tracker.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OWTrack/Tracker.cs b/OWTrack/Tracker.cs index e653e77..d88b98d 100644 --- a/OWTrack/Tracker.cs +++ b/OWTrack/Tracker.cs @@ -230,7 +230,7 @@ namespace OWTrack { public Match() { } public DateTime dateTime { get; set; } - public bool IsWin;//to be used. + public bool IsWin; public string DateTimeSting; public int StartSR; public int LastMatchSR; -- 2.39.5