コード例 #1
0
ファイル: old_client.cs プロジェクト: chienhao10/VoliBotGUI
 private void connection_OnLogin(object sender, string username, string ipAddress)
 {
     new Thread((ThreadStart)(async() =>
     {
         updateStatus("Connecting...", Accountname);
         loginPacket = await connection.GetLoginDataPacketForUser();
         if (loginPacket.AllSummonerData == null)
         {
             Random rnd = new Random();
             String summonerName = Accountname;
             if (summonerName.Length > 16)
             {
                 summonerName = summonerName.Substring(0, 11) + new Random().Next(1000, 9999).ToString();
             }
             updateStatus("Create Summoner: " + summonerName, Accountname);
             await connection.CreateDefaultSummoner(summonerName);
         }
         await connection.Subscribe("bc", loginPacket.AllSummonerData.Summoner.AcctId);
         await connection.Subscribe("cn", loginPacket.AllSummonerData.Summoner.AcctId);
         await connection.Subscribe("gn", loginPacket.AllSummonerData.Summoner.AcctId);
         sumLevel = loginPacket.AllSummonerData.SummonerLevel.Level;
         sumName = loginPacket.AllSummonerData.Summoner.Name;
         sumId = loginPacket.AllSummonerData.Summoner.SumId;
         rpBalance = loginPacket.RpBalance;
         if (sumLevel > parent.maxLevel || sumLevel == parent.maxLevel)
         {
             connection.Disconnect();
             updateStatus("Summoner: " + sumName + " is already max level.", Accountname);
             updateStatus("Log into new account.", Accountname);
             parent.lognNewAccount();
             return;
         }
         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;
         }
         if ((loginPacket.AllSummonerData.Summoner.ProfileIconId == -1 || loginPacket.AllSummonerData.Summoner.ProfileIconId == 1))
         {
             double[] ids = new double[Convert.ToInt32(sumId)];
             string icons = await connection.GetSummonerIcons(ids);
             List <int> availableIcons = new List <int> {
             };
             var random = new Random();
             for (int i = 0; i < 29; i++)
             {
                 availableIcons.Add(i);
             }
             foreach (var id in icons)
             {
                 availableIcons.Add(Convert.ToInt32(id));
             }
             int index = random.Next(availableIcons.Count);
             int randomIcon = availableIcons[index];
             await connection.UpdateProfileIconId(randomIcon);
         }
         if (rpBalance == 400.0 && parent.buyBoost && sumLevel < 5)
         {
             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);
             }
         }
         updateStatus("Logged in as " + loginPacket.AllSummonerData.Summoner.Name + " @ level " + loginPacket.AllSummonerData.SummonerLevel.Level, Accountname);
         availableChampsArray = await connection.GetAvailableChampions();
         PlayerDTO player = await connection.CreatePlayer();
         if (loginPacket.ReconnectInfo != null && loginPacket.ReconnectInfo.Game != null)
         {
             connection_OnMessageReceived(sender, (object)loginPacket.ReconnectInfo.PlayerCredentials);
         }
         else
         {
             connection_OnMessageReceived(sender, (object)new EndOfGameStats());
         }
     })).Start();
 }