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 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); }
public async void GetData() { try { var loginPacket = await Connection.GetLoginDataPacketForUser(); if (loginPacket.AllSummonerData == null) { Data.ErrorMessage = "Summoner not created."; Data.State = Account.Result.Error; IsCompleted.TrySetResult(true); return; } await GetChampions(); GetRunes(loginPacket.AllSummonerData.Summoner.SumId); Data.Summoner = loginPacket.AllSummonerData.Summoner.Name; 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; if (loginPacket.EmailStatus != null) { var emailStatus = loginPacket.EmailStatus.Replace('_', ' '); Data.EmailStatus = Char.ToUpper(emailStatus[0]) + emailStatus.Substring(1); } else { Data.EmailStatus = "Unknown"; } // 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.State = Account.Result.Success; } catch (Exception e) { Utils.ExportException(e); Data.ErrorMessage = string.Format("Exception found: {0}", e.Message); Data.State = Account.Result.Error; } IsCompleted.TrySetResult(true); }
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); }