diff --git a/README.md b/README.md index d719b45..e34178a 100644 --- a/README.md +++ b/README.md @@ -76,21 +76,21 @@ To get the app up and running follow these simple steps. Please ensure you are in a match when you try to use it. I swear if you complain about it not working and you're not in a match... If Valorant is already running: -1. Press the big "WAIUA" button and wait about 20-30 seconds +1. Press the big "WAIUA" button and wait about 10 seconds 2. Profit If Valorant is not running: 1. Press the account button in the top left 2. Use your Riot Account details to log in. Remember to select your region from the bottom left. 3. Open Valorant LMAO -3. Press the big "WAIUA" button and wait about 20-30 seconds +3. Press the big "WAIUA" button and wait about 10 seconds 4. Profit slightly less Appologies about the long wait to load the information. I have to individually query each player's information from different APIs and then query another API to display images. ## Roadmap and Known Bugs -See the [project board](https://github.com/Soneliem/WAIUA/projects/1) for a list of proposed features (and known verified bugs). Please check the [issues tab](https://github.com/Soneliem/WAIUA/issues) before making a new issue. +See the [project board](https://github.com/Soneliem/WAIUA/projects/1) for a list of proposed features (and known verified bugs). Please check the [issues tab](https://github.com/Soneliem/WAIUA/issues) before making a new issue. ## Why I Made This diff --git a/WAIUA/Commands/APIConnection.cs b/WAIUA/Commands/APIConnection.cs index d1a344a..87b8901 100644 --- a/WAIUA/Commands/APIConnection.cs +++ b/WAIUA/Commands/APIConnection.cs @@ -6,6 +6,7 @@ using System.Net; using System.Text; using System.Text.RegularExpressions; +using System.Threading.Tasks; namespace WAIUA.Commands { @@ -43,6 +44,7 @@ public static class APIConnection public static string[] PGList { get; set; } = new string[10]; public static string[] PPGList { get; set; } = new string[10]; public static string[] PPPGList { get; set; } = new string[10]; + public static void Login(CookieContainer cookie, string username, string password) { try @@ -116,39 +118,6 @@ public static string Authenticate(CookieContainer cookie, string user, string pa return client.Execute(request).Content; } - //My attempt at re-authentication - //public static void Reauth(CookieContainer jar) - //{ - // RestClient client = new RestClient(new Uri("https://auth.riotgames.com/authorize?redirect_uri=https%3A%2F%2Fplayvalorant.com%2Fopt_in&client_id=play-valorant-web-prod&response_type=token%20id_token")); - // client.CookieContainer = jar; - - // RestRequest request = new RestRequest(); - - // var response = client.Get(request); - // Uri responseUri = response.ResponseUri; - // var errorMessage = response.ErrorMessage; - // System.Diagnostics.Debug.WriteLine($"Response: {responseUri}"); - // System.Diagnostics.Debug.WriteLine($"errorCode: {errorMessage}"); - - // AccessToken = responseUri.ToString(); - // string[] parts = AccessToken.Split(new char[] { '=', '&' }); - // AccessToken = parts[1]; - - // RestClient client2 = new RestClient(new Uri("https://entitlements.auth.riotgames.com/api/token/v1")); - // client2.CookieContainer = jar; - // RestRequest request2 = new RestRequest(); - - // request2.AddHeader("Authorization", $"Bearer {AccessToken}"); - // request2.AddJsonBody("{}"); - - // var response2 = client2.Post(request2); - // string content = client2.Execute(request2).Content; - // var errorMessage2 = content; - // System.Diagnostics.Debug.WriteLine($"errorCode2: {errorMessage2}"); - // var entitlement_token = JsonConvert.DeserializeObject(content); - // JToken entitlement_tokenObj = JObject.FromObject(entitlement_token); - // EntitlementToken = entitlement_tokenObj["entitlements_token"].Value(); - //} public static Boolean CheckLocal() { var lockfileLocation = $@"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\Riot Games\Riot Client\Config\lockfile"; @@ -295,8 +264,9 @@ public static void LiveMatchSetup() } if (LiveMatchID(cookie)) { - GetSeasons(); - GetLatestVersion(); + Parallel.Invoke( + () => GetSeasons(), + () => GetLatestVersion()); string url = $"https://glz-{Region}-1.{Region}.a.pvp.net/core-game/v1/matches/{Matchid}"; RestClient client = new RestClient(url); RestRequest request = new RestRequest(Method.GET); @@ -334,11 +304,12 @@ public static void LiveMatchSetup() public static string[] LiveMatchOutput(int playerno) { CookieContainer cookie = new CookieContainer(); - PlayerList[playerno] = GetIGUsername(cookie, PUUIDList[playerno]); - GetAgentInfo(AgentList[playerno], playerno); - GetCardInfo(CardList[playerno], playerno); - GetCompHistory(PUUIDList[playerno], playerno); - GetPlayerHistory(PUUIDList[playerno], playerno); + Parallel.Invoke( + () => PlayerList[playerno] = GetIGUsername(cookie, PUUIDList[playerno]), + () => GetAgentInfo(AgentList[playerno], playerno), + () => GetCardInfo(CardList[playerno], playerno), + () => GetCompHistory(PUUIDList[playerno], playerno), + () => GetPlayerHistory(PUUIDList[playerno], playerno)); string[] output = new string[]{ PlayerList[playerno], @@ -457,14 +428,14 @@ public static void GetPlayerHistory(string puuid, int playerno) string content = client.Execute(request).Content; dynamic contentobj = JObject.Parse(content); - try - { - rank = contentobj.QueueSkills.competitive.SeasonalInfoBySeasonID[$"{CurrentSeason}"].CompetitiveTier; - } + /*try + {*/ + rank = contentobj.QueueSkills.competitive.SeasonalInfoBySeasonID[$"{CurrentSeason}"].CompetitiveTier; + /*} catch (Exception) { rank = "0"; - } + }*/ RankList[playerno] = GetLRankIcon(rank); try { diff --git a/WAIUA/MainWindow.xaml b/WAIUA/MainWindow.xaml index 97aa502..fcf1679 100644 --- a/WAIUA/MainWindow.xaml +++ b/WAIUA/MainWindow.xaml @@ -203,7 +203,7 @@ FontSize="20" Foreground="White" Opacity="0.7" - Text="Loads live match data if available. This takes 20-30 seconds to load." + Text="Loads live match data if available. This takes around 10 seconds to load." TextAlignment="Center" TextWrapping="Wrap" /> diff --git a/WAIUA/MainWindow.xaml.cs b/WAIUA/MainWindow.xaml.cs index 36c3c38..e6ee3eb 100644 --- a/WAIUA/MainWindow.xaml.cs +++ b/WAIUA/MainWindow.xaml.cs @@ -1,5 +1,4 @@ using System.Windows; -using WAIUA.Commands; using WAIUA.ViewModels; namespace WAIUA diff --git a/WAIUA/Views/Home.xaml.cs b/WAIUA/Views/Home.xaml.cs index 08228e4..de38e1f 100644 --- a/WAIUA/Views/Home.xaml.cs +++ b/WAIUA/Views/Home.xaml.cs @@ -1,4 +1,5 @@ using System.Net; +using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using WAIUA.Commands; @@ -23,22 +24,65 @@ public class HomeInfo public static string[] Player8 { get; set; } public static string[] Player9 { get; set; } + private static void SetPlayer(int number) + { + switch (number) + { + case 0: + Player0 = APIConnection.LiveMatchOutput(0); + break; + + case 1: + Player1 = APIConnection.LiveMatchOutput(1); + break; + + case 2: + Player2 = APIConnection.LiveMatchOutput(2); + break; + + case 3: + Player3 = APIConnection.LiveMatchOutput(3); + break; + + case 4: + Player4 = APIConnection.LiveMatchOutput(4); + break; + + case 5: + Player5 = APIConnection.LiveMatchOutput(5); + break; + + case 6: + Player6 = APIConnection.LiveMatchOutput(6); + break; + + case 7: + Player7 = APIConnection.LiveMatchOutput(7); + break; + + case 8: + Player8 = APIConnection.LiveMatchOutput(8); + break; + + case 9: + Player9 = APIConnection.LiveMatchOutput(9); + break; + + default: + break; + } + } + public static HomeInfo GetHomeInfo() { var output = new HomeInfo() { }; try { APIConnection.LiveMatchSetup(); - Player0 = APIConnection.LiveMatchOutput(0); - Player1 = APIConnection.LiveMatchOutput(1); - Player2 = APIConnection.LiveMatchOutput(2); - Player3 = APIConnection.LiveMatchOutput(3); - Player4 = APIConnection.LiveMatchOutput(4); - Player5 = APIConnection.LiveMatchOutput(5); - Player6 = APIConnection.LiveMatchOutput(6); - Player7 = APIConnection.LiveMatchOutput(7); - Player8 = APIConnection.LiveMatchOutput(8); - Player9 = APIConnection.LiveMatchOutput(9); + Parallel.For(0, 10, i => + { + SetPlayer(i); + }); } catch (System.Exception) { @@ -52,7 +96,6 @@ public Home() InitializeComponent(); CookieContainer cookie = new CookieContainer(); DataContext = HomeInfo.GetHomeInfo(); - } public void Window_Loaded(object sender, RoutedEventArgs e)