private async void Download_Click(object sender, RoutedEventArgs e) { if (User) { PublicSummoner summoner = await RiotCalls.GetSummonerByName(Command.Text); if (string.IsNullOrWhiteSpace(summoner.Name)) { var overlay = new MessageOverlay { MessageTitle = { Content = "No Summoner Found" }, MessageTextBox = { Text = "The summoner \"" + Command.Text + "\" does not exist." } }; Client.OverlayContainer.Content = overlay.Content; Client.OverlayContainer.Visibility = Visibility.Visible; return; } HintLabel.Content = "retrieving replay"; HintLabel.Visibility = Visibility.Visible; var fadeLabelInAnimationx = new DoubleAnimation(1, TimeSpan.FromSeconds(0.1)); HintLabel.BeginAnimation(OpacityProperty, fadeLabelInAnimationx); PlatformGameLifecycleDTO n = await RiotCalls.RetrieveInProgressSpectatorGameInfo(Command.Text); if (n == null) { var overlay = new MessageOverlay { MessageTitle = { Content = "No Game Found" }, MessageTextBox = { Text = "The summoner \"" + Command.Text + "\" is not currently in game." } }; Client.OverlayContainer.Content = overlay.Content; Client.OverlayContainer.Visibility = Visibility.Visible; return; } if (n.GameName != null) { string ip = n.PlayerCredentials.ObserverServerIp + ":" + n.PlayerCredentials.ObserverServerPort; string key = n.PlayerCredentials.ObserverEncryptionKey; var gameId = (int)n.PlayerCredentials.GameId; recorder = new ReplayRecorder(ip, gameId, Client.Region.InternalName, key); recorder.OnReplayRecorded += recorder_OnReplayRecorded; recorder.OnGotChunk += recorder_OnGotChunk; var fadeGridOutAnimation = new DoubleAnimation(0, TimeSpan.FromSeconds(0.1)); Command.Visibility = Visibility.Hidden; Download.Visibility = Visibility.Hidden; HintLabel.Visibility = Visibility.Visible; HintLabel.Content = "Starting replay download"; } HintLabel.Content = "That player is not in a game"; HintLabel.Visibility = Visibility.Visible; } }
private async void Download_Click(object sender, RoutedEventArgs e) { if (User == true) { PublicSummoner Summoner = await Client.PVPNet.GetSummonerByName(Command.Text); if (String.IsNullOrWhiteSpace(Summoner.Name)) { MessageOverlay overlay = new MessageOverlay(); overlay.MessageTitle.Content = "No Summoner Found"; overlay.MessageTextBox.Text = "The summoner \"" + Command.Text + "\" does not exist."; Client.OverlayContainer.Content = overlay.Content; Client.OverlayContainer.Visibility = Visibility.Visible; return; } HintLabel.Content = "retrieving replay"; HintLabel.Visibility = Visibility.Visible; var fadeLabelInAnimationx = new DoubleAnimation(1, TimeSpan.FromSeconds(0.1)); HintLabel.BeginAnimation(Label.OpacityProperty, fadeLabelInAnimationx); PlatformGameLifecycleDTO n = await Client.PVPNet.RetrieveInProgressSpectatorGameInfo(Command.Text); if (n.GameName != null) { int port = n.PlayerCredentials.ServerPort; string IP; if (port == 0) { IP = n.PlayerCredentials.ObserverServerIp + ":8088"; } else { IP = n.PlayerCredentials.ObserverServerIp + ":" + port; } string Key = n.PlayerCredentials.ObserverEncryptionKey; int GameID = (Int32)n.PlayerCredentials.GameId; recorder = new ReplayRecorder(IP, GameID, Client.Region.InternalName, Key); recorder.OnReplayRecorded += recorder_OnReplayRecorded; recorder.OnGotChunk += recorder_OnGotChunk; var fadeGridOutAnimation = new DoubleAnimation(0, TimeSpan.FromSeconds(0.1)); Command.Visibility = Visibility.Hidden; Download.Visibility = Visibility.Hidden; HintLabel.Visibility = Visibility.Visible; HintLabel.Content = "Starting replay download"; return; } else { HintLabel.Content = "That player is not in a game"; HintLabel.Visibility = Visibility.Visible; return; } } }
public async Task <PlatformGameLifecycleDTO> RetrieveInProgressSpectatorGameInfo(String summonerName) { int Id = Invoke("gameService", "retrieveInProgressSpectatorGameInfo", new object[] { summonerName }); while (!results.ContainsKey(Id)) { await Task.Delay(10); } TypedObject messageBody = results[Id].GetTO("data").GetTO("body"); PlatformGameLifecycleDTO result = new PlatformGameLifecycleDTO(messageBody); results.Remove(Id); return(result); }
private async void LoadStats(string user) { PlatformGameLifecycleDTO n = await RiotCalls.RetrieveInProgressSpectatorGameInfo(user); if (n.GameName != null) { LoadPar(new List <Participant>(n.Game.TeamOne.ToArray()), n, BlueTeam); LoadPar(new List <Participant>(n.Game.TeamTwo.ToArray()), n, PurpleTeam); } else { Client.win.Visibility = Visibility.Hidden; Client.win.Close(); } }
private async void SpectateGame_Click(object sender, RoutedEventArgs e) { if (LastPlayerItem.GameStatus == "inGame") { PlatformGameLifecycleDTO n = await Client.PVPNet.RetrieveInProgressSpectatorGameInfo(LastPlayerItem.Username); if (n.GameName != null) { Client.LaunchSpectatorGame(Client.Region.SpectatorIpAddress, n.PlayerCredentials.ObserverEncryptionKey, (int)n.PlayerCredentials.GameId, Client.Region.InternalName); } } else if (LastPlayerItem.GameStatus == "spectating") { } }
private async void SpectateGame_Click(object sender, RoutedEventArgs e) { switch (LastPlayerItem.GameStatus) { case "inGame": { PlatformGameLifecycleDTO n = await RiotCalls.RetrieveInProgressSpectatorGameInfo(LastPlayerItem.Username); if (n.GameName != null) { Client.LaunchSpectatorGame(Client.Region.SpectatorIpAddress, n.PlayerCredentials.ObserverEncryptionKey, (int)n.PlayerCredentials.GameId, Client.Region.InternalName); } } break; case "spectating": break; } }
/// <summary> /// Loads the particiapants for the game /// </summary> /// <param name="allParticipants"></param> /// <param name="n"></param> /// <param name="list"></param> private async void LoadPar(List <Participant> allParticipants, PlatformGameLifecycleDTO n, ListView list) { bool isYourTeam = false; list.Items.Clear(); list.Items.Refresh(); try { string mmrJson; string url = Client.Region.SpectatorLink + "consumer/getGameMetaData/" + Client.Region.InternalName + "/" + n.Game.Id + "/token"; using (var client = new WebClient()) mmrJson = client.DownloadString(url); var serializer = new JavaScriptSerializer(); var deserializedJson = serializer.Deserialize <Dictionary <string, object> >(mmrJson); MMRLabel.Content = "Game MMR ≈ " + deserializedJson["interestScore"]; } catch { MMRLabel.Content = "Unable to calculate Game MMR"; } foreach (Participant par in allParticipants) { if (par is PlayerParticipant) { PublicSummoner scoutersum = await RiotCalls.GetSummonerByName(GSUsername); if ((par as PlayerParticipant).AccountId == scoutersum.AcctId) { isYourTeam = true; } } } foreach (Participant par in allParticipants) { if (par is PlayerParticipant) { var participant = par as PlayerParticipant; foreach (PlayerChampionSelectionDTO championSelect in n.Game.PlayerChampionSelections.Where(championSelect => championSelect.SummonerInternalName == participant.SummonerInternalName)) { GameScouterPlayer control = new GameScouterPlayer(); control.Tag = championSelect; GameStats = new List <MatchStats>(); control.Username.Content = championSelect.SummonerInternalName; //Make it so you can see yourself if (championSelect.SummonerInternalName == GSUsername) { control.Username.Foreground = (Brush)(new BrushConverter().ConvertFrom("#FF007A53")); } control.ChampIcon.Source = champions.GetChampion(championSelect.ChampionId).icon; if (File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell1Id))))) { var UriSource = new System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell1Id))), UriKind.Absolute); control.SumIcon1.Source = new BitmapImage(UriSource); } if (File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell2Id))))) { var UriSource = new System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell2Id))), UriKind.Absolute); control.SumIcon2.Source = new BitmapImage(UriSource); } GameStats.Clear(); try { PublicSummoner summoner = await RiotCalls.GetSummonerByName(championSelect.SummonerInternalName.Replace("summoner", string.Empty)); if (File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", summoner.ProfileIconId.ToString() + ".png"))) { control.ProfileIcon.Source = Client.GetImage(Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", summoner.ProfileIconId.ToString() + ".png")); } RecentGames result = await RiotCalls.GetRecentGames(summoner.AcctId); result.GameStatistics.Sort((s1, s2) => s2.CreateDate.CompareTo(s1.CreateDate)); foreach (PlayerGameStats game in result.GameStatistics) { game.GameType = Client.TitleCaseString(game.GameType.Replace("_GAME", "").Replace("MATCHED", "NORMAL")); var match = new MatchStats(); foreach (RawStat stat in game.Statistics) { Type type = typeof(MatchStats); string fieldName = Client.TitleCaseString(stat.StatType.Replace('_', ' ')).Replace(" ", ""); FieldInfo f = type.GetField(fieldName); f.SetValue(match, stat.Value); } match.Game = game; GameStats.Add(match); } int Kills, ChampKills; int Deaths, ChampDeaths; int Assists, ChampAssists; int GamesPlayed, ChampGamesPlayed; Kills = 0; Deaths = 0; Assists = 0; GamesPlayed = 0; ChampKills = 0; ChampDeaths = 0; ChampAssists = 0; ChampGamesPlayed = 0; //Load average KDA for past 20 games if possible foreach (MatchStats stats in GameStats) { champions gameChamp = champions.GetChampion((int)Math.Round(stats.Game.ChampionId)); Kills = Kills + (int)stats.ChampionsKilled; Deaths = Deaths + (int)stats.NumDeaths; Assists = Assists + (int)stats.Assists; GamesPlayed++; if (championSelect.ChampionId == (int)Math.Round(stats.Game.ChampionId)) { ChampKills = ChampKills + (int)stats.ChampionsKilled; ChampDeaths = ChampDeaths + (int)stats.NumDeaths; ChampAssists = ChampAssists + (int)stats.Assists; ChampGamesPlayed++; } } //GetKDA string string KDAString = string.Format("{0}/{1}/{2}", (Kills / GamesPlayed), (Deaths / GamesPlayed), (Assists / GamesPlayed)); string ChampKDAString = ""; try { ChampKDAString = string.Format("{0}/{1}/{2}", (ChampKills / ChampGamesPlayed), (ChampDeaths / ChampGamesPlayed), (ChampAssists / ChampGamesPlayed)); } catch { } if (ChampGamesPlayed == 0) { ChampKDAString = "No Games lately"; } control.AverageKDA.Content = KDAString; control.ChampAverageKDA.Content = ChampKDAString; BrushConverter bc = new BrushConverter(); if (isYourTeam) { bc = new BrushConverter(); if (ChampKills < ChampDeaths) { control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FFC51C1C"); } else if (ChampKills == ChampDeaths) { control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FF8D8D8D"); } else { control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FF1EBF1E"); } bc = new BrushConverter(); if (Kills < Deaths) { control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FFC51C1C"); } else if (Kills == Deaths) { control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FF8D8D8D"); } else { control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FF1EBF1E"); } } else { bc = new BrushConverter(); if (ChampKills > ChampDeaths) { control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FFC51C1C"); } else if (ChampKills == ChampDeaths) { control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FF8D8D8D"); } else { control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FF1EBF1E"); } bc = new BrushConverter(); if (Kills > Deaths) { control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FFC51C1C"); } else if (Kills == Deaths) { control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FF8D8D8D"); } else { control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FF1EBF1E"); } } } catch { Client.Log("Failed to get stats about player", "GAME_SCOUTER_ERROR"); } if (participant.TeamParticipantId != null) { try { Brush myColor = color[(double)participant.TeamParticipantId]; control.QueueTeamColor.Fill = myColor; control.QueueTeamColor.Visibility = Visibility.Visible; } catch { BrushConverter bc = new BrushConverter(); Brush brush = Brushes.White; //I know that there is a better way in the InGamePage //I find that sometimes the colors (colours) are very hard to distinguish from eachother //This makes sure that each color is easy to see //because of hexa hill I put 12 in just in case switch (ColorId) { case 0: //blue brush = (Brush)bc.ConvertFrom("#FF00E8FF"); break; case 2: //Lime Green brush = (Brush)bc.ConvertFrom("#FF00FF00"); break; case 3: //Yellow brush = (Brush)bc.ConvertFrom("#FFFFFF00"); break; case 4: //Blue Green brush = (Brush)bc.ConvertFrom("#FF007A53"); break; case 5: //Purple brush = (Brush)bc.ConvertFrom("#FF5100FF"); break; case 6: //Pink brush = (Brush)bc.ConvertFrom("#FFCB46C5"); break; case 7: //Dark Green brush = (Brush)bc.ConvertFrom("#FF006409"); break; case 8: //Brown brush = (Brush)bc.ConvertFrom("#FF643200"); break; case 9: //White brush = (Brush)bc.ConvertFrom("#FFFFFFFF"); break; case 10: //Grey brush = (Brush)bc.ConvertFrom("#FF363636"); break; case 11: //Red Pink brush = (Brush)bc.ConvertFrom("#FF8F4242"); break; case 12: //Grey Blue brush = (Brush)bc.ConvertFrom("#FFFF0000"); break; } color.Add((double)participant.TeamParticipantId, brush); ColorId++; control.QueueTeamColor.Fill = brush; control.QueueTeamColor.Visibility = Visibility.Visible; } } //control.MouseMove += controlMouseEnter; control.MouseEnter += controlMouseEnter; control.MouseLeave += control_MouseLeave; control.MouseDown += control_MouseDown; TinyRuneMasteryData smallData = new TinyRuneMasteryData(); //Now store data in the tags so that all of the event handlers work Dictionary <string, object> data = new Dictionary <string, object>(); data.Add("MasteryDataControl", smallData); data.Add("RuneData", await GetUserRunesPage(GSUsername)); data.Add("MasteryData", await GetUserRunesPage(GSUsername)); control.Tag = data; list.Items.Add(control); } } } }
public void Update(PlatformGameLifecycleDTO currentGame, string username) { _user = username; _game = currentGame; BlueBansLabel.Visibility = Visibility.Hidden; PurpleBansLabel.Visibility = Visibility.Hidden; PurpleBanListView.Items.Clear(); BlueBanListView.Items.Clear(); BlueListView.Items.Clear(); PurpleListView.Items.Clear(); ImageGrid.Children.Clear(); var allParticipants = new List <Participant>(currentGame.Game.TeamOne.ToArray()); allParticipants.AddRange(currentGame.Game.TeamTwo); var i = 0; var y = 0; foreach (var part in allParticipants) { var control = new ChampSelectPlayer(); if (part is PlayerParticipant) { var participant = part as PlayerParticipant; foreach ( var championSelect in currentGame.Game.PlayerChampionSelections.Where( championSelect => championSelect.SummonerInternalName == participant.SummonerInternalName)) { control.KnownPar = true; control._sumName = participant.SummonerInternalName; control._champID = championSelect.ChampionId; control.ChampionImage.Source = champions.GetChampion(championSelect.ChampionId).icon; var uriSource = new Uri( Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell1Id))), UriKind.Absolute); control.SummonerSpell1.Source = new BitmapImage(uriSource); uriSource = new Uri( Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell2Id))), UriKind.Absolute); control.SummonerSpell2.Source = new BitmapImage(uriSource); #region Generate Background var m = new Image(); Panel.SetZIndex(m, -2); m.Stretch = Stretch.None; m.Width = 100; m.Opacity = 0.50; m.HorizontalAlignment = HorizontalAlignment.Left; m.VerticalAlignment = VerticalAlignment.Stretch; m.Margin = new Thickness(y++ *100, 0, 0, 0); var cropRect = new Rectangle(new Point(100, 0), new Size(100, 560)); var src = System.Drawing.Image.FromFile(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", champions.GetChampion(championSelect.ChampionId).portraitPath)) as Bitmap; var target = new Bitmap(cropRect.Width, cropRect.Height); using (var g = Graphics.FromImage(target)) { if (src != null) { g.DrawImage(src, new Rectangle(0, 0, target.Width, target.Height), cropRect, GraphicsUnit.Pixel); } } m.Source = Client.ToWpfBitmap(target); ImageGrid.Children.Add(m); #endregion Generate Background } control.PlayerName.Content = participant.SummonerName; if (participant.TeamParticipantId != null) { var values = BitConverter.GetBytes((double)participant.TeamParticipantId); if (!BitConverter.IsLittleEndian) { Array.Reverse(values); } var r = values[2]; var b = values[3]; var g = values[4]; var myColor = Color.FromArgb(r, b, g); var converter = new BrushConverter(); var brush = (Brush)converter.ConvertFromString("#" + myColor.Name); control.TeamRectangle.Fill = brush; control.TeamRectangle.Visibility = Visibility.Visible; } } i++; if (i <= 5) { BlueListView.Items.Add(control); } else { PurpleListView.Items.Add(control); } } if (currentGame.Game.BannedChampions.Count > 0) { BlueBansLabel.Visibility = Visibility.Visible; PurpleBansLabel.Visibility = Visibility.Visible; } foreach (var x in currentGame.Game.BannedChampions) { var champImage = new Image { Height = 58, Width = 58, Source = champions.GetChampion(x.ChampionId).icon }; if (x.TeamId == 100) { BlueBanListView.Items.Add(champImage); } else { PurpleBanListView.Items.Add(champImage); } } try { string mmrJson; var url = Client.Region.SpectatorLink + "consumer/getGameMetaData/" + Client.Region.InternalName + "/" + currentGame.Game.Id + "/token"; using (var client = new WebClient()) { mmrJson = client.DownloadString(url); } var serializer = new JavaScriptSerializer(); var deserializedJson = serializer.Deserialize <Dictionary <string, object> >(mmrJson); MMRLabel.Content = "≈" + deserializedJson["interestScore"]; } catch { MMRLabel.Content = "N/A"; } }
/// 58.) public void RetrieveInProgressSpectatorGameInfo(String summonerName, PlatformGameLifecycleDTO.Callback callback) { PlatformGameLifecycleDTO cb = new PlatformGameLifecycleDTO(callback); InvokeWithCallback("gameService", "retrieveInProgressSpectatorGameInfo", new object[] { summonerName }, cb); }
public void Update(PlatformGameLifecycleDTO CurrentGame) { Game = CurrentGame; BlueBansLabel.Visibility = System.Windows.Visibility.Hidden; PurpleBansLabel.Visibility = System.Windows.Visibility.Hidden; PurpleBanListView.Items.Clear(); BlueBanListView.Items.Clear(); BlueListView.Items.Clear(); PurpleListView.Items.Clear(); ImageGrid.Children.Clear(); List <Participant> AllParticipants = new List <Participant>(CurrentGame.Game.TeamOne.ToArray()); AllParticipants.AddRange(CurrentGame.Game.TeamTwo); int i = 0; int y = 0; foreach (Participant part in AllParticipants) { ChampSelectPlayer control = new ChampSelectPlayer(); if (part is PlayerParticipant) { PlayerParticipant participant = part as PlayerParticipant; foreach (PlayerChampionSelectionDTO championSelect in CurrentGame.Game.PlayerChampionSelections) { if (championSelect.SummonerInternalName == participant.SummonerInternalName) { control.ChampionImage.Source = champions.GetChampion(championSelect.ChampionId).icon; var uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell1Id))), UriKind.Absolute); control.SummonerSpell1.Source = new BitmapImage(uriSource); uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell2Id))), UriKind.Absolute); control.SummonerSpell2.Source = new BitmapImage(uriSource); #region Generate Background Image m = new Image(); Canvas.SetZIndex(m, -2); m.Stretch = Stretch.None; m.Width = 100; m.Opacity = 0.50; m.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; m.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; m.Margin = new System.Windows.Thickness(y++ *100, 0, 0, 0); System.Drawing.Rectangle cropRect = new System.Drawing.Rectangle(new System.Drawing.Point(100, 0), new System.Drawing.Size(100, 560)); System.Drawing.Bitmap src = System.Drawing.Image.FromFile(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", champions.GetChampion(championSelect.ChampionId).portraitPath)) as System.Drawing.Bitmap; System.Drawing.Bitmap target = new System.Drawing.Bitmap(cropRect.Width, cropRect.Height); using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(target)) { g.DrawImage(src, new System.Drawing.Rectangle(0, 0, target.Width, target.Height), cropRect, System.Drawing.GraphicsUnit.Pixel); } m.Source = Client.ToWpfBitmap(target); ImageGrid.Children.Add(m); #endregion Generate Background } } control.PlayerName.Content = participant.SummonerName; if (participant.TeamParticipantId != null) { byte[] values = BitConverter.GetBytes((double)participant.TeamParticipantId); if (!BitConverter.IsLittleEndian) { Array.Reverse(values); } byte r = values[2]; byte b = values[3]; byte g = values[4]; System.Drawing.Color myColor = System.Drawing.Color.FromArgb(r, b, g); var converter = new System.Windows.Media.BrushConverter(); var brush = (Brush)converter.ConvertFromString("#" + myColor.Name); control.TeamRectangle.Fill = brush; control.TeamRectangle.Visibility = System.Windows.Visibility.Visible; } } i++; if (i <= 5) { BlueListView.Items.Add(control); } else { PurpleListView.Items.Add(control); } } if (CurrentGame.Game.BannedChampions.Count > 0) { BlueBansLabel.Visibility = System.Windows.Visibility.Visible; PurpleBansLabel.Visibility = System.Windows.Visibility.Visible; } foreach (var x in CurrentGame.Game.BannedChampions) { Image champImage = new Image(); champImage.Height = 58; champImage.Width = 58; champImage.Source = champions.GetChampion(x.ChampionId).icon; if (x.TeamId == 100) { BlueBanListView.Items.Add(champImage); } else { PurpleBanListView.Items.Add(champImage); } } try { string mmrJSON = ""; string url = Client.Region.SpectatorLink + "consumer/getGameMetaData/" + Client.Region.InternalName + "/" + CurrentGame.Game.Id + "/token"; using (WebClient client = new WebClient()) { mmrJSON = client.DownloadString(url); } JavaScriptSerializer serializer = new JavaScriptSerializer(); Dictionary <string, object> deserializedJSON = serializer.Deserialize <Dictionary <string, object> >(mmrJSON); MMRLabel.Content = "≈" + deserializedJSON["interestScore"]; } catch { MMRLabel.Content = "N/A"; } }
public async void GetSummonerProfile(string s) { PublicSummoner Summoner = await Client.PVPNet.GetSummonerByName(String.IsNullOrWhiteSpace(s)?Client.LoginPacket.AllSummonerData.Summoner.Name : s); if (String.IsNullOrWhiteSpace(Summoner.Name)) { MessageOverlay overlay = new MessageOverlay(); overlay.MessageTitle.Content = "No Summoner Found"; overlay.MessageTextBox.Text = "The summoner \"" + s + "\" does not exist."; Client.OverlayContainer.Content = overlay.Content; Client.OverlayContainer.Visibility = Visibility.Visible; return; } SummonerNameLabel.Content = Summoner.Name; SummonerLevelLabel.Content = "Level " + Summoner.SummonerLevel; if (Summoner.SummonerLevel < 30) { LeagueHeader.Visibility = System.Windows.Visibility.Collapsed; } else { Client.PVPNet.GetAllLeaguesForPlayer(Summoner.SummonerId, new SummonerLeaguesDTO.Callback(GotLeaguesForPlayer)); } int ProfileIconID = Summoner.ProfileIconId; var uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", ProfileIconID + ".png"); ProfileImage.Source = Client.GetImage(uriSource); PlatformGameLifecycleDTO n = await Client.PVPNet.RetrieveInProgressSpectatorGameInfo(s); if (n.GameName != null) { InGameHeader.Visibility = Visibility.Visible; InGameHeader.IsSelected = true; Ingame ingame = InGameContainer.Content as Ingame; ingame.Update(n); } else { InGameHeader.Visibility = Visibility.Collapsed; OverviewHeader.IsSelected = true; } if (Summoner.InternalName == Client.LoginPacket.AllSummonerData.Summoner.InternalName) { ChampionsTab.Visibility = System.Windows.Visibility.Visible; SkinsTab.Visibility = System.Windows.Visibility.Visible; } else { ChampionsTab.Visibility = System.Windows.Visibility.Hidden; SkinsTab.Visibility = System.Windows.Visibility.Hidden; } MatchHistory history = MatchHistoryContainer.Content as MatchHistory; history.Update(Summoner.AcctId); Overview overview = OverviewContainer.Content as Overview; overview.Update(Summoner.SummonerId, Summoner.AcctId); }
#pragma warning disable 4014 //Code does not need to be awaited private async void GotLoginPacket(LoginDataPacket packet) { if (packet.AllSummonerData == null) { //Just Created Account, need to put logic here. Client.done = false; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { var createSummoner = new CreateSummonerNameOverlay(); Client.OverlayContainer.Content = createSummoner.Content; Client.OverlayContainer.Visibility = Visibility.Visible; })); while (!Client.done) { } Client.PVPNet.Connect(LoginUsernameBox.Text, LoginPasswordBox.Password, Client.Region.PVPRegion, Client.Version); return; } Client.LoginPacket = packet; if (packet.AllSummonerData.Summoner.ProfileIconId == -1) { Client.done = false; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { Client.OverlayContainer.Content = new ChooseProfilePicturePage().Content; Client.OverlayContainer.Visibility = Visibility.Visible; })); while (!Client.done) { } Client.PVPNet.Connect(LoginUsernameBox.Text, LoginPasswordBox.Password, Client.Region.PVPRegion, Client.Version); return; } Client.PlayerChampions = await Client.PVPNet.GetAvailableChampions(); Client.PVPNet.OnError -= PVPNet_OnError; Client.GameConfigs = packet.GameTypeConfigs; Client.PVPNet.Subscribe("bc", packet.AllSummonerData.Summoner.AcctId); Client.PVPNet.Subscribe("cn", packet.AllSummonerData.Summoner.AcctId); Client.PVPNet.Subscribe("gn", packet.AllSummonerData.Summoner.AcctId); Client.IsLoggedIn = true; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async() => { Client.StatusContainer.Visibility = Visibility.Visible; Client.Container.Margin = new Thickness(0, 0, 0, 40); var newCredentials = new AuthenticationCredentials { Username = LoginUsernameBox.Text, Password = LoginPasswordBox.Password, ClientVersion = Client.Version, IpAddress = GetNewIpAddress(), Locale = Client.Region.Locale, Domain = "lolclient.lol.riotgames.com" }; //Almost like the lol client now string os = Environment.OSVersion.ToString(); string[] ossplit = os.Split('.'); if (ossplit[0] == "Windows 8") { if (ossplit[1] == "1") { os = "Windows 8.1"; } } else { os = ossplit[0]; } newCredentials.OperatingSystem = os; Session login = await Client.PVPNet.Login(newCredentials); Client.PlayerSession = login; //Setup chat if (!Client.Garena) { Client.ChatClient.AutoReconnect = 30; Client.ChatClient.KeepAlive = 10; Client.ChatClient.NetworkHost = "chat." + Client.Region.ChatName + ".lol.riotgames.com"; Client.ChatClient.Port = 5223; Client.ChatClient.Server = "pvp.net"; Client.ChatClient.SSL = true; Client.ChatClient.User = LoginUsernameBox.Text; Client.ChatClient.Password = "******" + LoginPasswordBox.Password; Client.userpass = new KeyValuePair <String, String>(LoginUsernameBox.Text, "AIR_" + LoginPasswordBox.Password); Client.ChatClient.OnInvalidCertificate += Client.ChatClient_OnInvalidCertificate; Client.ChatClient.OnMessage += Client.ChatClient_OnMessage; Client.ChatClient.OnPresence += Client.ChatClient_OnPresence; Client.ChatClient.OnDisconnect += Client.ChatClient_OnDisconnect; Client.ChatClient.Connect(); } else { Client.ChatClient.AutoReconnect = 30; Client.ChatClient.KeepAlive = 10; Client.ChatClient.NetworkHost = Client.Region.ChatName; Client.ChatClient.Port = 5223; Client.ChatClient.Server = "pvp.net"; Client.ChatClient.SSL = true; Client.ChatClient.User = packet.AllSummonerData.Summoner.AcctId.ToString(); Client.ChatClient.Password = "******" + GetLast(packet.AllSummonerData.Summoner.AcctId.ToString(), 5); Client.userpass = new KeyValuePair <String, String>(packet.AllSummonerData.Summoner.AcctId.ToString(), "AIR_pass" + GetLast(packet.AllSummonerData.Summoner.AcctId.ToString(), 5)); Client.ChatClient.OnInvalidCertificate += Client.ChatClient_OnInvalidCertificate; Client.ChatClient.OnMessage += Client.ChatClient_OnMessage; Client.ChatClient.OnPresence += Client.ChatClient_OnPresence; Client.ChatClient.OnDisconnect += Client.ChatClient_OnDisconnect; Client.ChatClient.Connect(); } Client.RostManager = new RosterManager { Stream = Client.ChatClient, AutoAllow = AutoSubscriptionHanding.AllowAll }; Client.RostManager.OnRosterItem += Client.RostManager_OnRosterItem; Client.RostManager.OnRosterEnd += Client.ChatClientConnect; Client.PresManager = new PresenceManager { Stream = Client.ChatClient }; Client.PresManager.OnPrimarySessionChange += Client.PresManager_OnPrimarySessionChange; Client.ConfManager = new ConferenceManager { Stream = Client.ChatClient }; //switch Client.Log("Connected to " + Client.Region.RegionName + " and logged in as " + Client.LoginPacket.AllSummonerData.Summoner.Name); //Gather data and convert it that way that it does not cause errors PlatformGameLifecycleDTO data = Client.LoginPacket.ReconnectInfo; if (data != null && data.Game != null) { Client.Log(data.PlayerCredentials.ChampionId.ToString(CultureInfo.InvariantCulture)); Client.CurrentGame = data.PlayerCredentials; Client.GameType = data.Game.GameType; Client.SwitchPage(new InGame()); } else { uiLogic.UpdateMainPage(); } Client.ClearPage(typeof(LoginPage)); })); }
#pragma warning disable 4014 //Code does not need to be awaited private async void GotLoginPacket(LoginDataPacket packet) { if (packet.AllSummonerData == null) { //Just Created Account, need to put logic here. Client.done = false; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { CreateSummonerNameOverlay createSummoner = new CreateSummonerNameOverlay(); Client.OverlayContainer.Content = createSummoner.Content; Client.OverlayContainer.Visibility = Visibility.Visible; })); while (!Client.done) { ; } Client.PVPNet.Connect(usernameBox.Text, passwordBox.Password, Client.Region.PVPRegion, Client.Version); return; } Client.LoginPacket = packet; if (packet.AllSummonerData.Summoner.ProfileIconId == -1) { Client.done = false; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { Client.OverlayContainer.Content = new ChooseProfilePicturePage().Content; Client.OverlayContainer.Visibility = Visibility.Visible; })); while (!Client.done) { ; } Client.PVPNet.Connect(usernameBox.Text, passwordBox.Password, Client.Region.PVPRegion, Client.Version); return; } Client.PlayerChampions = await Client.PVPNet.GetAvailableChampions(); Client.PVPNet.OnError -= PVPNet_OnError; Client.GameConfigs = packet.GameTypeConfigs; Client.PVPNet.Subscribe("bc", packet.AllSummonerData.Summoner.AcctId); Client.PVPNet.Subscribe("cn", packet.AllSummonerData.Summoner.AcctId); Client.PVPNet.Subscribe("gn", packet.AllSummonerData.Summoner.AcctId); Client.IsLoggedIn = true; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async() => { AuthenticationCredentials newCredentials = new AuthenticationCredentials(); newCredentials.Username = usernameBox.Text; newCredentials.Password = passwordBox.Password; newCredentials.ClientVersion = Client.Version; newCredentials.IpAddress = GetNewIpAddress(); newCredentials.Locale = Client.Region.Locale; newCredentials.Domain = "lolclient.lol.riotgames.com"; Session login = await Client.PVPNet.Login(newCredentials); Client.PlayerSession = login; //Setup chat Client.ChatClient.AutoReconnect = 30; Client.ChatClient.KeepAlive = 10; Client.ChatClient.NetworkHost = "chat." + Client.Region.ChatName + ".lol.riotgames.com"; Client.ChatClient.Port = 5223; Client.ChatClient.Server = "pvp.net"; Client.ChatClient.SSL = true; Client.ChatClient.User = usernameBox.Text; Client.ChatClient.Password = "******" + passwordBox.Password; Client.ChatClient.OnInvalidCertificate += Client.ChatClient_OnInvalidCertificate; Client.ChatClient.OnMessage += Client.ChatClient_OnMessage; Client.ChatClient.OnPresence += Client.ChatClient_OnPresence; Client.ChatClient.Connect(); Client.RostManager = new RosterManager(); Client.RostManager.Stream = Client.ChatClient; Client.RostManager.AutoSubscribe = true; Client.RostManager.AutoAllow = jabber.client.AutoSubscriptionHanding.AllowAll; Client.RostManager.OnRosterItem += Client.RostManager_OnRosterItem; Client.RostManager.OnRosterEnd += new bedrock.ObjectHandler(Client.ChatClientConnect); Client.PresManager = new PresenceManager(); Client.PresManager.Stream = Client.ChatClient; //Client.PresManager.OnPrimarySessionChange += Client.PresManager_OnPrimarySessionChange; Client.ConfManager = new ConferenceManager(); Client.ConfManager.Stream = Client.ChatClient; Client.Log("Connected and logged in as " + Client.ChatClient.User); //Gather data and convert it that way that it does not cause errors PlatformGameLifecycleDTO data = Client.LoginPacket.ReconnectInfo; if (data != null && data.Game != null) { Client.CurrentGame = data.PlayerCredentials; Client.SwitchPage(new InGame()); } else { Client.SwitchPage(new MainPage()); } })); }
private void GotLoginPacket(LoginDataPacket packet) { if (packet.AllSummonerData == null) { Client.RiotConnection.CallbackException -= client_CallbackException; Client.RiotConnection.MessageReceived -= client_MessageReceived; //Just Created Account, need to put logic here. Client.done = false; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { var createSummoner = new CreateSummonerNameOverlay(); Client.OverlayContainer.Content = createSummoner.Content; Client.OverlayContainer.Visibility = Visibility.Visible; })); while (!Client.done) { } Login(); return; } Client.LoginPacket = packet; if (packet.AllSummonerData.Summoner.ProfileIconId == -1) { Client.RiotConnection.CallbackException -= client_CallbackException; Client.RiotConnection.MessageReceived -= client_MessageReceived; Client.done = false; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { Client.OverlayContainer.Content = new ChooseProfilePicturePage().Content; Client.OverlayContainer.Visibility = Visibility.Visible; })); while (!Client.done) { } Login(); return; } Client.RiotConnection.MessageReceived += Client.OnMessageReceived; Client.RiotConnection.Disconnected += Client.RiotConnection_Disconnected; Client.GameConfigs = packet.GameTypeConfigs; Client.IsLoggedIn = true; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { MessageBox.Show("Do not play ANY games. I am not sure if they will work ~eddy", "XMPP", MessageBoxButton.OK, MessageBoxImage.Warning); Client.StatusContainer.Visibility = Visibility.Visible; Client.Container.Margin = new Thickness(0, 0, 0, 40); //You have to hand implement this //Client.XmppConnection.AutoReconnect = 30; Client.XmppConnection = new agsXMPP.XmppClientConnection("pvp.net", 5223) { AutoResolveConnectServer = false, ConnectServer = "chat." + Client.Region.ChatName + ".lol.riotgames.com", Resource = "xiff", UseSSL = true, KeepAliveInterval = 10, KeepAlive = true }; Client.XmppConnection.UseCompression = true; Client.XmppConnection.OnMessage += Client.XmppConnection_OnMessage; Client.XmppConnection.OnError += Client.XmppConnection_OnError; Client.XmppConnection.OnLogin += (o) => { Client.Log("Connected to XMPP Server"); //Set up chat Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { if (invisibleLoginCheckBox.IsChecked != true) { Client.XmppConnection.Send(new Presence(ShowType.chat, Client.GetPresence(), 0) { Type = PresenceType.available }); } else { Client.XmppConnection.Send(new Presence(ShowType.NONE, Client.GetPresence(), 0) { Type = PresenceType.invisible }); } })); }; Client.RostManager = new RosterManager(Client.XmppConnection); Client.XmppConnection.OnRosterItem += Client.RostManager_OnRosterItem; Client.XmppConnection.OnRosterEnd += Client.ChatClientConnect; Client.PresManager = new PresenceManager(Client.XmppConnection); Client.XmppConnection.OnPresence += Client.XmppConnection_OnPresence; if (!Client.Garena) { Client.userpass = new KeyValuePair <string, string>(LoginUsernameBox.Text, "AIR_" + LoginPasswordBox.Password); Client.XmppConnection.Open(LoginUsernameBox.Text, "AIR_" + LoginPasswordBox.Password); //Client.XmppConnection.OnInvalidCertificate += Client.XmppConnection_OnInvalidCertificate; } else { Client.XmppConnection.ConnectServer = "chat" + Client.Region.ChatName + ".lol.garenanow.com"; var gas = getGas(); Client.XmppConnection.Open(Client.UID, "AIR_" + gas); Client.userpass = new KeyValuePair <string, string>(Client.UID, "AIR_" + gas); } //Client.PresManager.OnPrimarySessionChange += Client.PresManager_OnPrimarySessionChange; /* * Client.ConfManager = new ConferenceManager * { * Stream = Client.XmppConnection * }; * //*/ //switch Client.Log("Connected to " + Client.Region.RegionName + " and logged in as " + Client.LoginPacket.AllSummonerData.Summoner.Name); //Gather data and convert it that way that it does not cause errors PlatformGameLifecycleDTO data = (PlatformGameLifecycleDTO)Client.LoginPacket.ReconnectInfo; Client.MainPage = new MainPage(); if (data != null && data.Game != null) { Client.Log(data.PlayerCredentials.ChampionId.ToString(CultureInfo.InvariantCulture)); Client.CurrentGame = data.PlayerCredentials; Client.GameType = data.Game.GameType; Client.SwitchPage(new InGame()); } else { Client.SwitchPage(Client.MainPage); } Client.ClearPage(typeof(LoginPage)); })); }
public async void GetSummonerProfile(string s) { PublicSummoner summoner = await Client.PVPNet.GetSummonerByName(String.IsNullOrWhiteSpace(s) ?Client.LoginPacket.AllSummonerData.Summoner.Name : s); if (String.IsNullOrWhiteSpace(summoner.Name)) { var overlay = new MessageOverlay { MessageTitle = { Content = "No Summoner Found" }, MessageTextBox = { Text = "The summoner \"" + s + "\" does not exist." } }; Client.OverlayContainer.Content = overlay.Content; Client.OverlayContainer.Visibility = Visibility.Visible; return; } SummonerNameLabel.Content = summoner.Name; SummonerLevelLabel.Content = "Level " + summoner.SummonerLevel; if (summoner.SummonerLevel < 30) { LeagueHeader.Visibility = Visibility.Collapsed; TeamsHeader.Visibility = Visibility.Collapsed; } else { Client.PVPNet.GetAllLeaguesForPlayer(summoner.SummonerId, GotLeaguesForPlayer); PlayerDTO playerTeams = await Client.PVPNet.FindPlayer(summoner.SummonerId); GotPlayerTeams(playerTeams); } int profileIconId = summoner.ProfileIconId; string uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", profileIconId + ".png"); ProfileImage.Source = Client.GetImage(uriSource); PlatformGameLifecycleDTO n = await Client.PVPNet.RetrieveInProgressSpectatorGameInfo(s); if (n.GameName != null) { InGameHeader.Visibility = Visibility.Visible; InGameHeader.IsSelected = true; var ingame = InGameContainer.Content as Ingame; if (ingame != null) { ingame.Update(n, summoner.Name); } } else { InGameHeader.Visibility = Visibility.Collapsed; OverviewHeader.IsSelected = true; } if (summoner.InternalName == Client.LoginPacket.AllSummonerData.Summoner.InternalName) { ChampionsTab.Visibility = Visibility.Visible; SkinsTab.Visibility = Visibility.Visible; MatchHistoryBetaTab.Margin = new Thickness(0, 0, 0, 0); } else { ChampionsTab.Visibility = Visibility.Hidden; SkinsTab.Visibility = Visibility.Hidden; MatchHistoryBetaTab.Margin = new Thickness(-211, 0, 211, 0); } var historyBeta = LeagueMatchHistoryBetaContainer.Content as MatchHistoryOnline; if (historyBeta != null) { historyBeta.Update(summoner.AcctId); } var history = MatchHistoryContainer.Content as MatchHistory; if (history != null) { history.Update(summoner.AcctId); } var overview = OverviewContainer.Content as Overview; if (overview != null) { overview.Update(summoner.SummonerId, summoner.AcctId); } }