From 85ab854fe266ec5643e74da22d842c8e26490f66 Mon Sep 17 00:00:00 2001 From: KiD Fearless Date: Fri, 1 Jan 2021 14:42:00 -0700 Subject: [PATCH] tweak formula --- Models/User.cs | 1 + Views/MainWindow.xaml.cs | 40 +++++++++++++++++++++++++++------------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/Models/User.cs b/Models/User.cs index d44a28e..3fb62e6 100644 --- a/Models/User.cs +++ b/Models/User.cs @@ -77,6 +77,7 @@ public async void GetProfileData() this.Profile = await Steam.GetProfileDataAsync(url); this.ProfileRetreived?.Invoke(this, this.Profile); } + // sometimes it just fails for no reason. so we just try again. catch { try diff --git a/Views/MainWindow.xaml.cs b/Views/MainWindow.xaml.cs index e614645..3446689 100644 --- a/Views/MainWindow.xaml.cs +++ b/Views/MainWindow.xaml.cs @@ -615,12 +615,22 @@ Color GetBackgroundColor(User user) } var difference = DateTime.Now - memberSince; - var memberThreat = 5 - (difference.TotalDays / 365); - threatLevel += (int)Math.Clamp(memberThreat, 0, 10); + var months = difference.TotalDays / 30; + var years = difference.TotalDays / 365; + double threat = 0; + if(years < 2) + { + threat = (24 - months) / 2.4; + } + + user.UI.ThreatLevel.Text += $"age: {(int)threat} "; + threatLevel += (int)Math.Clamp(threat, 0, 10); } else { threatLevel += 2; + user.UI.ThreatLevel.Text += $"age: N/A "; + } if (user.Profile.mostPlayedGames is not null && user.Profile.mostPlayedGames.mostPlayedGame is not null) @@ -628,7 +638,9 @@ Color GetBackgroundColor(User user) var game = user.Profile.mostPlayedGames.MostPlayedGames.FirstOrDefault(t => t.gameName == "Counter-Strike: Global Offensive"); if (game is not null) { - var timeThreat = 10 - (Convert.ToDouble(game.hoursOnRecord) / 100); + var timeThreat = Math.Round(10 - (Convert.ToDouble(game.hoursOnRecord) / 100)); + user.UI.ThreatLevel.Text += $"time: {(int)timeThreat} "; + threatLevel += (int)Math.Clamp(timeThreat, 0, 10); } } @@ -641,6 +653,8 @@ Color GetBackgroundColor(User user) // only shows 1, 0, or null if (user.Profile.vacBanned == "1") { + user.UI.ThreatLevel.Text += $"vac: 5 "; + threatLevel += 5; } } @@ -654,24 +668,24 @@ Color GetBackgroundColor(User user) return threatLevel switch { 1 => - Color.FromArgb(25, 100, 100, 225), + Color.FromArgb(20, 100, 100, 225), 2 => - Color.FromArgb(25, 100, 100, 200), + Color.FromArgb(30, 100, 100, 200), 3 => - Color.FromArgb(25, 100, 100, 175), + Color.FromArgb(40, 100, 100, 175), 4 => - Color.FromArgb(25, 100, 100, 150), + Color.FromArgb(50, 100, 100, 150), 5 => - Color.FromArgb(25, 100, 100, 125), + Color.FromArgb(60, 100, 100, 125), 6 => - Color.FromArgb(25, 100, 100, 100), + Color.FromArgb(70, 100, 100, 100), 7 => - Color.FromArgb(25, 100, 100, 75), + Color.FromArgb(80, 100, 100, 75), 8 => - Color.FromArgb(25, 100, 100, 50), + Color.FromArgb(90, 100, 100, 50), 9 => - Color.FromArgb(25, 100, 100, 25), - 10 => Color.FromArgb(25, 0, 100, 255), + Color.FromArgb(100, 100, 100, 25), + 10 => Color.FromArgb(100, 255, 255, 0), _ => Color.FromArgb(0, 0, 0, 0), }; }