Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1 from Soneliem/Testing
Browse files Browse the repository at this point in the history
Merge Testing build to Main build
  • Loading branch information
Soneliem authored Aug 23, 2021
2 parents 3940f84 + 082e509 commit f8ec9b3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 16 deletions.
2 changes: 1 addition & 1 deletion WAIUA/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public partial class App : Application
{
private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
MessageBox.Show("An unhandled exception just occurred: " + e.Exception.Message, "Exception Sample", MessageBoxButton.OK, MessageBoxImage.Warning);
MessageBox.Show("An unhandled exception just occurred: " + e.Exception.Message, e.Exception.Source, MessageBoxButton.OK, MessageBoxImage.Warning);
e.Handled = true;
}
}
Expand Down
52 changes: 37 additions & 15 deletions WAIUA/Commands/APIConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public static class APIConnection
public static string PUUID { get; set; }
public static string Matchid { get; set; }
public static string IGN { get; set; }
public static string INusername { get; set; }
public static string INpassword { get; set; }
public static string Port { get; set; }
public static string LPassword { get; set; }
public static string Protocol { get; set; }
Expand All @@ -46,6 +44,7 @@ public static class APIConnection
public static string[] PPGList { get; set; } = new string[10];
public static string[] PPPGList { get; set; } = new string[10];
public static string[] TitleList { get; set; } = new string[10];
public static bool[] IsIncognito { get; set; } = new bool[10];
private static ConcurrentDictionary<string, string> url_to_body = new();

public static string DoCachedRequest(Method method, String url, bool add_riot_auth, CookieContainer cookie_container = null, bool bypass_cache = false) // Thank you MitchC for this, I am always touched when random people go out of the way to help others even though they know that we would be clueless and need to ask alot of followup questions
Expand Down Expand Up @@ -90,8 +89,8 @@ public static void Login(CookieContainer cookie, string username, string passwor
JToken authObj = JObject.FromObject(authJson);

string authURL = authObj["response"]["parameters"]["uri"].Value<string>();
var access_tokenVar = Regex.Match(authURL, @"access_token=(.+?)&scope=").Groups[1].Value;
AccessToken = $"{access_tokenVar}";
var accessTokenVar = Regex.Match(authURL, @"access_token=(.+?)&scope=").Groups[1].Value;
AccessToken = $"{accessTokenVar}";

RestClient client = new RestClient(new Uri("https://entitlements.auth.riotgames.com/api/token/v1"));
RestRequest request = new RestRequest(Method.POST);
Expand Down Expand Up @@ -154,7 +153,7 @@ public static string Authenticate(CookieContainer cookie, string user, string pa
return client.Execute(request).Content;
}

public static Boolean CheckLocal()
public static bool CheckLocal()
{
var lockfileLocation = $@"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\Riot Games\Riot Client\Config\lockfile";

Expand Down Expand Up @@ -318,35 +317,45 @@ public static void LiveMatchSetup()
string[] card = new string[10];
string[] level = new string[10];
string[] title = new string[10];
bool[] incognito = new bool[10];
int index = 0;
foreach (var entry in matchinfo.Players)
{
playerno[index] = index;
puuid[index] = entry.Subject;
agent[index] = entry.CharacterID;
card[index] = entry.PlayerIdentity.PlayerCardID;
level[index] = entry.PlayerIdentity.AccountLevel;
title[index] = entry.PlayerIdentity.PlayerTitleID;
index++;
if (entry.IsCoach == false)
{
playerno[index] = index;
puuid[index] = entry.Subject;
agent[index] = entry.CharacterID;
card[index] = entry.PlayerIdentity.PlayerCardID;
level[index] = entry.PlayerIdentity.AccountLevel;
title[index] = entry.PlayerIdentity.PlayerTitleID;
if (entry.PlayerIdentity.Incognito == true)
{
incognito[index] = true;
}
index++;
if (index == 10) { break; }
}
}
PlayerNo = playerno;
PUUIDList = puuid;
AgentList = agent;
CardList = card;
LevelList = level;
TitleList = title;
IsIncognito = incognito;
}
}
catch (Exception)
catch (Exception e)
{
System.Diagnostics.Debug.WriteLine(e);
}
}

public static string[] LiveMatchOutput(int playerno)
{
CookieContainer cookie = new CookieContainer();
Parallel.Invoke(
() => PlayerList[playerno] = GetIGUsername(cookie, PUUIDList[playerno]),
() => GetIGCUsername(playerno),
() => GetAgentInfo(AgentList[playerno], playerno),
() => GetCardInfo(CardList[playerno], playerno),
() => GetTitleInfo(TitleList[playerno], playerno),
Expand All @@ -372,6 +381,19 @@ public static string[] LiveMatchOutput(int playerno)
return output;
}

public static void GetIGCUsername(int playerno)
{
CookieContainer cookie = new CookieContainer();
if (IsIncognito[playerno])
{
PlayerList[playerno] = "----";
}
else
{
PlayerList[playerno] = GetIGUsername(cookie, PUUIDList[playerno]);
}
}

public static void GetAgentInfo(string agent, int playerno)
{
try
Expand Down

0 comments on commit f8ec9b3

Please sign in to comment.