private void connection_OnLogin(object sender, string username, string ipAddress)
        {
            new Thread((ThreadStart)(async() =>
            {
                updateStatus("Connecting...", Accountname);
                this.RegisterNotifications();
                this.loginPacket = await this.connection.GetLoginDataPacketForUser();
                if (loginPacket.AllSummonerData == null)
                {
                    Random rnd = new Random();
                    String summonerName = Accountname;
                    if (summonerName.Length > 16)
                    {
                        summonerName = summonerName.Substring(0, 12) + new Random().Next(1000, 9999).ToString();
                    }
                    LoLLauncher.RiotObjects.Platform.Summoner.AllSummonerData sumData = await connection.CreateDefaultSummoner(summonerName);
                    loginPacket.AllSummonerData = sumData;
                    updateStatus("Created Summonername " + summonerName, Accountname);
                }
                sumLevel = loginPacket.AllSummonerData.SummonerLevel.Level;
                string sumName = loginPacket.AllSummonerData.Summoner.Name;
                double sumId = loginPacket.AllSummonerData.Summoner.SumId;
                rpBalance = loginPacket.RpBalance;
                if (sumLevel > Program.maxLevel || sumLevel == Program.maxLevel)
                {
                    connection.Disconnect();
                    updateStatus("Summoner: " + sumName + " is already max level.", Accountname);
                    updateStatus("Log into new account.", Accountname);
                    Program.lognNewAccount();
                    return;
                }
                if (rpBalance == 400.0 && Program.buyBoost)
                {
                    updateStatus("Buying XP Boost", Accountname);
                    try
                    {
                        Task t = new Task(buyBoost);
                        t.Start();
                    }
                    catch (Exception exception)
                    {
                        updateStatus("Couldn't buy RP Boost.\n" + exception, Accountname);
                    }
                }
                if (sumLevel < 3.0 && queueType == QueueTypes.NORMAL_5x5)
                {
                    this.updateStatus("Need to be Level 3 before NORMAL_5x5 queue.", Accountname);
                    this.updateStatus("Joins Co-Op vs AI (Beginner) queue until 3", Accountname);
                    queueType = QueueTypes.BEGINNER_BOT;
                    actualQueueType = QueueTypes.NORMAL_5x5;
                }
                else if (sumLevel < 6.0 && queueType == QueueTypes.ARAM)
                {
                    this.updateStatus("Need to be Level 6 before ARAM queue.", Accountname);
                    this.updateStatus("Joins Co-Op vs AI (Beginner) queue until 6", Accountname);
                    queueType = QueueTypes.BEGINNER_BOT;
                    actualQueueType = QueueTypes.ARAM;
                }
                else if (sumLevel < 7.0 && queueType == QueueTypes.NORMAL_3x3)
                {
                    this.updateStatus("Need to be Level 7 before NORMAL_3x3 queue.", Accountname);
                    this.updateStatus("Joins Co-Op vs AI (Beginner) queue until 7", Accountname);
                    queueType = QueueTypes.BEGINNER_BOT;
                    actualQueueType = QueueTypes.NORMAL_3x3;
                }

                /* Should be randomize the summonericon on every login,
                 * but only works with extra icons, so it crashes if you only got the standards.
                 * double[] ids = new double[Convert.ToInt32(sumId)];
                 * string icons = await connection.GetSummonerIcons(ids);
                 * List<int> availableIcons = new List<int> { };
                 * var random = new Random();
                 * foreach (var id in icons)
                 * {
                 *  availableIcons.Add(Convert.ToInt32(id));
                 *  Console.WriteLine("[DEBUG]: Added Icon: " + id);
                 * }
                 * int index = random.Next(availableIcons.Count);
                 * Console.WriteLine(" | Random Icon: " + index);
                 * int randomIcon = availableIcons[index];
                 * Console.WriteLine(" | Choose from List: " + randomIcon);
                 * await connection.UpdateProfileIconId(randomIcon);*/
                updateStatus("Đăng nhập : " + loginPacket.AllSummonerData.Summoner.Name + " @ level " + loginPacket.AllSummonerData.SummonerLevel.Level, Accountname);
                availableChampsArray = await connection.GetAvailableChampions();
                LoLLauncher.RiotObjects.Team.Dto.PlayerDTO player = await connection.CreatePlayer();
                if (this.loginPacket.ReconnectInfo != null && this.loginPacket.ReconnectInfo.Game != null)
                {
                    this.connection_OnMessageReceived(sender, (object)this.loginPacket.ReconnectInfo.PlayerCredentials);
                }
                else
                {
                    this.connection_OnMessageReceived(sender, (object)new EndOfGameStats());
                }
            })).Start();
        }
Ejemplo n.º 2
0
 /// 14.)
 public void GetAllSummonerDataByAccount(Double accountId, AllSummonerData.Callback callback)
 {
     AllSummonerData cb = new AllSummonerData(callback);
     InvokeWithCallback("summonerService", "getAllSummonerDataByAccount", new object[] { accountId }, cb);
 }
Ejemplo n.º 3
0
 public async Task<AllSummonerData> GetAllSummonerDataByAccount(Double accountId)
 {
     int Id = Invoke("summonerService", "getAllSummonerDataByAccount", new object[] { accountId });
     while (!results.ContainsKey(Id))
         await Task.Delay(10);
     TypedObject messageBody = results[Id].GetTO("data").GetTO("body");
     AllSummonerData result = new AllSummonerData(messageBody);
     results.Remove(Id);
     return result;
 }
Ejemplo n.º 4
0
 public async Task<AllSummonerData> CreateDefaultSummoner(String summonerName)
 {
     int Id = Invoke("summonerService", "createDefaultSummoner", new object[] { summonerName });
     while (!results.ContainsKey(Id))
         await Task.Delay(10);
     TypedObject messageBody = results[Id].GetTO("data").GetTO("body");
     AllSummonerData result = new AllSummonerData(messageBody);
     results.Remove(Id);
     return result;
 }