private async void GetData() { var loginPacket = await Connection.GetLoginDataPacketForUser(); if (loginPacket.AllSummonerData == null) { return; } var champions = await Connection.GetAvailableChampions(); var skins = new List <ChampionSkinDTO>(); foreach (var champion in champions) { skins.AddRange(champion.ChampionSkins.Where(s => s.Owned)); } Data.Level = (int)loginPacket.AllSummonerData.SummonerLevel.Level; Data.RpBalance = (int)loginPacket.RpBalance; Data.Ipbalance = (int)loginPacket.IpBalance; Data.Champions = champions.Count(c => c.Owned); Data.Skins = skins.Count; Data.RunePages = loginPacket.AllSummonerData.SpellBook.BookPages.Count; Data.SummonerName = loginPacket.AllSummonerData.Summoner.Name; Console.WriteLine("[{0:HH:mm}] <{1}> Data received!", DateTime.Now, Data.Username); _completed = true; Report(Result.Success); }
private static async void Load() { PVPNetConnection connection = new PVPNetConnection(); ChampionDTO[] champs = await connection.GetAvailableChampions(); throw new Exception(champs[0].SkinName); }
private void OnLogin(object sender, string username, string ipAddress) { new Thread(async() => { try { Packets = await Connections.GetLoginDataPacketForUser(); } catch (NotSupportedException) { // Restarting BotClient; Controller.Restart(); } if (Packets.AllSummonerData == null) { NewPlayerAccout(); OnLogin(sender, username, ipAddress); return; } await Connections.Subscribe("bc", Packets.AllSummonerData.Summoner.AcctId); await Connections.Subscribe("cn", Packets.AllSummonerData.Summoner.AcctId); await Connections.Subscribe("gn", Packets.AllSummonerData.Summoner.AcctId); if (Packets.AllSummonerData.Summoner.ProfileIconId == -1) { SetSummonerIcon(); } SummonerLevel = Packets.AllSummonerData.SummonerLevel.Level; SummonerName = Packets.AllSummonerData.Summoner.Name; SummonerId = Packets.AllSummonerData.Summoner.SumId; HeroesArray = await Connections.GetAvailableChampions(); Debug.WriteLine(JsonConvert.SerializeObject(HeroesArray.Where(ho => ho.Owned || ho.FreeToPlay))); WebService.SetLevel(Account.Id, (int)SummonerLevel); WebService.SetMoney(Account.Id, (int)Packets.IpBalance); if (SummonerLevel > Account.Maxlevel || Convert.ToInt32(SummonerLevel) == Account.Maxlevel) { Client.Status("Maximum level reached!", AccountName); return; } Hero = await Connections.CreatePlayer(); OnMessageReceived(sender, new ClientBeforeStart()); Thread.Sleep(2000); }).Start(); }
private async Task GetChampions() { var champions = await Connection.GetAvailableChampions(); Data.ChampionList = new List <ChampionData>(); Data.SkinList = new List <SkinData>(); foreach (var champion in champions) { var championData = LeagueData.Champions.FirstOrDefault(c => c.Id == champion.ChampionId); if (championData == null) { continue; } if (champion.Owned) { Data.ChampionList.Add( new ChampionData { Name = championData.Name, PurchaseDate = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds( Math.Round(champion.PurchaseDate / 1000d)), Champion = championData }); } foreach (var skin in champion.ChampionSkins.Where(skin => skin.Owned)) { var skinData = championData.Skins.FirstOrDefault(s => s.Id == skin.SkinId); if (skinData == null) { continue; } Data.SkinList.Add( new SkinData { Name = skinData.Name, StillObtainable = skin.StillObtainable, Champion = championData, Skin = skinData }); } } }
//internal static Inviter CurrentInviter; #pragma warning disable 4014 internal static void OnMessageReceived(object sender, object message) { MainWin.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async() => { if (message is StoreAccountBalanceNotification) { StoreAccountBalanceNotification newBalance = (StoreAccountBalanceNotification)message; InfoLabel.Content = "IP: " + newBalance.Ip + " ∙ RP: " + newBalance.Rp; Client.LoginPacket.IpBalance = newBalance.Ip; Client.LoginPacket.RpBalance = newBalance.Rp; } else if (message is GameNotification) { GameNotification notification = (GameNotification)message; MessageOverlay messageOver = new MessageOverlay(); messageOver.MessageTitle.Content = notification.Type; switch (notification.Type) { case "PLAYER_BANNED_FROM_GAME": messageOver.MessageTitle.Content = "Banned from custom game"; messageOver.MessageTextBox.Text = "You have been banned from this custom game!"; break; default: messageOver.MessageTextBox.Text = notification.MessageCode + Environment.NewLine; messageOver.MessageTextBox.Text = Convert.ToString(notification.MessageArgument); break; } Client.OverlayContainer.Content = messageOver.Content; Client.OverlayContainer.Visibility = Visibility.Visible; Client.ClearPage(typeof(CustomGameLobbyPage)); if (messageOver.MessageTitle.Content.ToString() != "PLAYER_QUIT") { Client.SwitchPage(new MainPage()); } } else if (message is PVPNetConnect.RiotObjects.Platform.Statistics.EndOfGameStats) { PVPNetConnect.RiotObjects.Platform.Statistics.EndOfGameStats stats = message as PVPNetConnect.RiotObjects.Platform.Statistics.EndOfGameStats; EndOfGamePage EndOfGame = new EndOfGamePage(stats); Client.ClearPage(typeof(TeamQueuePage)); Client.OverlayContainer.Visibility = Visibility.Visible; Client.OverlayContainer.Content = EndOfGame.Content; } else if (message is StoreFulfillmentNotification) { PlayerChampions = await PVPNet.GetAvailableChampions(); } else if (message is Inviter) { Inviter stats = message as Inviter; //CurrentInviter = stats; } else if (message is InvitationRequest) { InvitationRequest stats = message as InvitationRequest; //TypedObject body = (TypedObject)to["body"]; if (stats.Inviter != null) { try { //Already existant popup. Do not create a new one var x = Client.InviteData[stats.InvitationId]; if (x.Inviter != null) { return; } } catch { } MainWin.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { GameInvitePopup pop = new GameInvitePopup(stats); pop.HorizontalAlignment = HorizontalAlignment.Right; pop.VerticalAlignment = VerticalAlignment.Bottom; pop.Height = 230; Client.NotificationGrid.Children.Add(pop); })); } } })); }
public async void GetData() { var loginPacket = await Connection.GetLoginDataPacketForUser(); if (loginPacket.AllSummonerData == null) { Data.ErrorMessage = "Summoner not created."; Data.Result = Result.Error; IsCompleted.TrySetResult(true); return; } var champions = await Connection.GetAvailableChampions(); Data.ChampionList = new List <ChampionData>(); Data.SkinList = new List <SkinData>(); foreach (var champion in champions) { var cdata = LeagueData.Data.data.FirstOrDefault(c => Int32.Parse(c.key) == champion.ChampionId); if (cdata == null) { continue; // champion not implemented in json file ? } if (champion.Owned) { Data.ChampionList.Add( new ChampionData { Name = cdata.name, PurchaseDate = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds( Math.Round(champion.PurchaseDate / 1000d)) }); } foreach (var skin in champion.ChampionSkins.Where(skin => skin.Owned)) { var sdata = cdata.skins.FirstOrDefault(s => Int32.Parse(s.id) == skin.SkinId); if (sdata == null) { continue; // skin not implemented in json file ? } Data.SkinList.Add(new SkinData { Name = sdata.name, StillObtainable = skin.StillObtainable }); } } Data.Level = (int)loginPacket.AllSummonerData.SummonerLevel.Level; Data.RpBalance = (int)loginPacket.RpBalance; Data.IpBalance = (int)loginPacket.IpBalance; Data.Champions = Data.ChampionList.Count; Data.Skins = Data.SkinList.Count; Data.RunePages = loginPacket.AllSummonerData.SpellBook.BookPages.Count; Data.Summoner = loginPacket.AllSummonerData.Summoner.Name; var emailStatus = loginPacket.EmailStatus.Replace('_', ' '); Data.EmailStatus = Char.ToUpper(emailStatus[0]) + emailStatus.Substring(1); // Leagues if (Data.Level == 30) { var myLeagues = await Connection.GetMyLeaguePositions(); var soloqLeague = myLeagues.SummonerLeagues.FirstOrDefault(l => l.QueueType == "RANKED_SOLO_5x5"); Data.SoloQRank = soloqLeague != null ? string.Format( "{0}{1} {2}", char.ToUpper(soloqLeague.Tier[0]), soloqLeague.Tier.Substring(1).ToLower(), soloqLeague.Rank) : "Unranked"; } else { Data.SoloQRank = "Unranked"; } // Last Play var recentGames = await Connection.GetRecentGames(loginPacket.AllSummonerData.Summoner.AcctId); var lastGame = recentGames.GameStatistics.FirstOrDefault(); if (lastGame != null) { Data.LastPlay = lastGame.CreateDate; } Data.Result = Result.Success; IsCompleted.TrySetResult(true); }
//internal static Inviter CurrentInviter; internal static void OnMessageReceived(object sender, object message) { MainWin.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async() => { if (message is StoreAccountBalanceNotification) { StoreAccountBalanceNotification newBalance = (StoreAccountBalanceNotification)message; InfoLabel.Content = "IP: " + newBalance.Ip + " ∙ RP: " + newBalance.Rp; Client.LoginPacket.IpBalance = newBalance.Ip; Client.LoginPacket.RpBalance = newBalance.Rp; } else if (message is GameNotification) { GameNotification notification = (GameNotification)message; MessageOverlay messageOver = new MessageOverlay(); messageOver.MessageTitle.Content = notification.Type; switch (notification.Type) { case "PLAYER_BANNED_FROM_GAME": messageOver.MessageTitle.Content = "Banned from custom game"; messageOver.MessageTextBox.Text = "You have been banned from this custom game!"; break; default: messageOver.MessageTextBox.Text = notification.MessageCode + Environment.NewLine; messageOver.MessageTextBox.Text = Convert.ToString(notification.MessageArgument); break; } Client.OverlayContainer.Content = messageOver.Content; Client.OverlayContainer.Visibility = Visibility.Visible; Client.ClearPage(new CustomGameLobbyPage()); Client.SwitchPage(new MainPage()); } else if (message is EndOfGameStats) { EndOfGameStats stats = message as EndOfGameStats; EndOfGamePage EndOfGame = new EndOfGamePage(stats); Client.OverlayContainer.Visibility = Visibility.Visible; Client.OverlayContainer.Content = EndOfGame.Content; } else if (message is StoreFulfillmentNotification) { PlayerChampions = await PVPNet.GetAvailableChampions(); } else if (message is Inviter) { Inviter stats = message as Inviter; //CurrentInviter = stats; } else if (message is InvitationRequest) { InvitationRequest stats = message as InvitationRequest; Inviter Inviterstats = message as Inviter; //TypedObject body = (TypedObject)to["body"]; MainWin.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { //Gameinvite stuff GameInvitePopup pop = new GameInvitePopup(stats); //await Invite.Callback; //Invite.InvitationRequest(body); pop.HorizontalAlignment = HorizontalAlignment.Right; pop.VerticalAlignment = VerticalAlignment.Bottom; pop.Height = 230; Client.NotificationGrid.Children.Add(pop); //Client.InviteJsonRequest = LegendaryClient.Logic.JSON.InvitationRequest.PopulateGameInviteJson(); //message.GetType() == typeof(GameInvitePopup) })); } })); }