private void connection_OnError(object sender, Error error)
 {
     Invoke((Action)(() =>
     {
         label1.Text = "Test Result:";
         label2.Text = "ERROR - Account don't works.";
         button1.Enabled = true;
         _connection.Disconnect();
     }));
 }
 public void Disconnect()
 {
     if (connection.IsConnected())
     {
         updateStatus("Disconnecting");
         connection.Disconnect();
         while (connection.IsConnected())
         {
             connection.Disconnect();
             System.Threading.Thread.Sleep(100);
         }
     }
 }
Esempio n. 3
0
        public async void AntiBuster(MatchMakerParams matchParams)
        {
            //Thx to mah niggah Everance
            //who made this possible

            if (QueueFlag)
            {
                Console.Out.WriteLine("Something wrong with smurf list");
                connection.Disconnect();
            }
            else
            {
                this.updateStatus("You are leaver busted.", Accountname);
                connection.Disconnect();
            }
        }
Esempio n. 4
0
        public async void AntiBuster(MatchMakerParams matchParams)
        {
            //Thx to mah niggah Everance
            //who made this possible

            if (QueueFlag)
            {
                Console.WriteLine(
                    "Something went wrong, couldn't enter queue. Check accounts.txt for correct queue type.");
                connection.Disconnect();
                Environment.Exit(0);
            }
            else
            {
                this.updateStatus("Sorry, you're leavebusted :/ use LuxBot instead.", Accountname);
                connection.Disconnect();
            }
        }
Esempio n. 5
0
 private void connection_OnError(object sender, LoLLauncher.Error error)
 {
     if (!m_disposed)
     {
         if (error.Message.Contains("Wrong client version for server"))
         {
             connection.Disconnect();
         }
         else if (error.Message.Contains("Game was not found!"))
         {
             Logger.Push("Somebody broke the game queue.", "info", username);
         }
         else if (error.Message.Contains("Riots servers are currently unavailable"))
         {
             smurf.restart();
         }
         else
         {
             Logger.Push("Unhandled error message recieved from server:" + error.Message, "warning", username);
             Logger.Push("Restarting smurf in hard mode:" + error.Message, "warning", username);
             smurf.restartHard();
         }
     }
 }
        public async void connection_OnMessageReceived(object sender, object message)
        {
            //=======================
            if (message is GameDTO)
            {
                GameDTO game = message as GameDTO;
                switch (game.GameState)
                {
                case "CHAMP_SELECT":
                    if (this.firstTimeInLobby)
                    {
                        updateStatus("Bắt đầu trận thứ : " + solandachoi, "");
                        firstTimeInLobby = false;
                        updateStatus("Đang chọn tướng !", Accountname);
                        object obj = await connection.SetClientReceivedGameMessage(game.Id, "CHAMP_SELECT_CLIENT");

                        if (queueType != QueueTypes.ARAM)
                        {
                            if (Program.championId != "" && Program.championId != "RANDOM")
                            {
                                int Spell1;
                                int Spell2;
                                if (!Program.rndSpell)
                                {
                                    Spell1 = Enums.spellToId(Program.spell1);
                                    Spell2 = Enums.spellToId(Program.spell2);
                                }
                                else
                                {
                                    var random    = new Random();
                                    var spellList = new List <int> {
                                        13, 6, 7, 10, 1, 11, 21, 12, 3, 14, 2, 4
                                    };

                                    int index  = random.Next(spellList.Count);
                                    int index2 = random.Next(spellList.Count);

                                    int randomSpell1 = spellList[index];
                                    int randomSpell2 = spellList[index2];

                                    if (randomSpell1 == randomSpell2)
                                    {
                                        int index3 = random.Next(spellList.Count);
                                        randomSpell2 = spellList[index3];
                                    }

                                    Spell1 = Convert.ToInt32(randomSpell1);
                                    Spell2 = Convert.ToInt32(randomSpell2);
                                }

                                await connection.SelectSpells(Spell1, Spell2);

                                await connection.SelectChampion(Enums.championToId(Program.championId));

                                updateStatus("Bạn chọn tướng : " + Program.championId, Accountname);
                                updateStatus("Phép bổ trợ 1 : " + Program.spell1, Accountname);
                                updateStatus("Phép bổ trợ 2 : " + Program.spell2, Accountname);
                                await connection.ChampionSelectCompleted();
                            }
                            else if (Program.championId == "RANDOM")
                            {
                                int Spell1;
                                int Spell2;
                                if (!Program.rndSpell)
                                {
                                    Spell1 = Enums.spellToId(Program.spell1);
                                    Spell2 = Enums.spellToId(Program.spell2);
                                }
                                else
                                {
                                    var random    = new Random();
                                    var spellList = new List <int> {
                                        13, 6, 7, 10, 1, 11, 21, 12, 3, 14, 2, 4
                                    };

                                    int index  = random.Next(spellList.Count);
                                    int index2 = random.Next(spellList.Count);

                                    int randomSpell1 = spellList[index];
                                    int randomSpell2 = spellList[index2];

                                    if (randomSpell1 == randomSpell2)
                                    {
                                        int index3 = random.Next(spellList.Count);
                                        randomSpell2 = spellList[index3];
                                    }

                                    Spell1 = Convert.ToInt32(randomSpell1);
                                    Spell2 = Convert.ToInt32(randomSpell2);
                                }

                                await connection.SelectSpells(Spell1, Spell2);

                                var randAvailableChampsArray = availableChampsArray.Shuffle();
                                await connection.SelectChampion(randAvailableChampsArray.First(champ => champ.Owned || champ.FreeToPlay).ChampionId);

                                updateStatus("Chọn tướng ngẫu nhiên ", Accountname);
                                updateStatus("Bạn chọn tướng : " + randAvailableChampsArray.First(champ => champ.Owned || champ.FreeToPlay).ChampionId, Accountname);
                                updateStatus("Phép bổ trợ 1 : " + Spell1, Accountname);
                                updateStatus("Phép bổ trợ 2 : " + Spell2, Accountname);
                                await connection.ChampionSelectCompleted();
                            }
                            else
                            {
                                int Spell1;
                                int Spell2;
                                if (!Program.rndSpell)
                                {
                                    Spell1 = Enums.spellToId(Program.spell1);
                                    Spell2 = Enums.spellToId(Program.spell2);
                                }
                                else
                                {
                                    var random    = new Random();
                                    var spellList = new List <int> {
                                        13, 6, 7, 10, 1, 11, 21, 12, 3, 14, 2, 4
                                    };

                                    int index  = random.Next(spellList.Count);
                                    int index2 = random.Next(spellList.Count);

                                    int randomSpell1 = spellList[index];
                                    int randomSpell2 = spellList[index2];

                                    if (randomSpell1 == randomSpell2)
                                    {
                                        int index3 = random.Next(spellList.Count);
                                        randomSpell2 = spellList[index3];
                                    }

                                    Spell1 = Convert.ToInt32(randomSpell1);
                                    Spell2 = Convert.ToInt32(randomSpell2);
                                }

                                await connection.SelectSpells(Spell1, Spell2);

                                await connection.SelectChampion(availableChampsArray.First(champ => champ.Owned || champ.FreeToPlay).ChampionId);

                                updateStatus("Chọn tướng đầu tiên", Accountname);
                                updateStatus("Bạn chọn tướng : " + availableChampsArray.First(champ => champ.Owned || champ.FreeToPlay).ChampionId, Accountname);
                                updateStatus("Phép bổ trợ 1 : " + Spell1, Accountname);
                                updateStatus("Phép bổ trợ 2 : " + Spell2, Accountname);
                                await connection.ChampionSelectCompleted();
                            }
                        }
                        break;
                    }
                    else
                    {
                        break;
                    }

                case "POST_CHAMP_SELECT":
                    firstTimeInLobby = false;
                    this.updateStatus("(Post Champ Select)", Accountname);
                    break;

                case "PRE_CHAMP_SELECT":
                    this.updateStatus("(Pre Champ Select)", Accountname);
                    break;

                case "GAME_START_CLIENT":
                    this.updateStatus("Trò chơi bắt đầu .", Accountname);
                    break;

                case "GameClientConnectedToServer":
                    this.updateStatus("Client kết nối tới sever .", Accountname);
                    break;

                case "IN_QUEUE":
                    this.updateStatus("Đang tìm trận ...", Accountname);
                    QueueFlag = true;
                    break;

                case "TERMINATED":

                    if (solandachoi <= solanchoi)
                    {
                        updateStatus("Xong trận thứ : " + solandachoi, "");
                        this.updateStatus("Vào lại hàng chờ !", Accountname);
                        solandachoi++;
                    }
                    else
                    {
                        connection.Disconnect();
                        updateStatus("Hết số lần chơi ! . Thoát LOL ...", "");
                        Process[] processes = Process.GetProcessesByName("RitoBot");
                        foreach (Process process in processes)
                        {
                            process.Kill();
                            process.WaitForExit();
                        }
                    }
                    Thread.Sleep(2000);
                    this.firstTimeInQueuePop = true;
                    break;

                case "JOINING_CHAMP_SELECT":
                    if (this.firstTimeInQueuePop && game.StatusOfParticipants.Contains("1"))
                    {
                        this.updateStatus("Đang chờ người chơi !", Accountname);
                        this.firstTimeInQueuePop = false;
                        this.firstTimeInLobby    = true;
                        object obj = await this.connection.AcceptPoppedGame(true);

                        break;
                    }
                    else
                    {
                        break;
                    }

                case "LEAVER_BUSTED":
                    this.updateStatus("Leave busted", Accountname);
                    break;
                }
            }
            else if (message is PlayerCredentialsDto)
            {
                string str = ipath + "GAME\\";

                /* string str = Enumerable.Last<string>((IEnumerable<string>)Enumerable.OrderBy<string, DateTime>(Directory.EnumerateDirectories((this.ipath ?? "")
                 + "RADS\\solutions\\lol_game_client_sln\\releases\\"), (Func<string, DateTime>)(f => new DirectoryInfo(f).CreationTime))) + "\\deploy\\";*/
                LoLLauncher.RiotObjects.Platform.Game.PlayerCredentialsDto credentials = message as PlayerCredentialsDto;
                System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
                startInfo.CreateNoWindow   = false;
                startInfo.WorkingDirectory = str;
                startInfo.FileName         = "League of Legends.exe";
                startInfo.Arguments        = "\"8394\" \"LoLLauncher.exe\" \"\" \"" + credentials.ServerIp + " " +
                                             credentials.ServerPort + " " + credentials.EncryptionKey + " " + credentials.SummonerId + "\"";
                updateStatus("League of Legends đang chạy !", Accountname);
                new Thread((ThreadStart)(() =>
                {
                    exeProcess = Process.Start(startInfo);
                    exeProcess.Exited += exeProcess_Exited;
                    while (exeProcess.MainWindowHandle == IntPtr.Zero)
                    {
                        ;
                    }
                    exeProcess.PriorityClass = ProcessPriorityClass.Idle;
                    exeProcess.EnableRaisingEvents = true;
                })).Start();
            }
            else if (!(message is GameNotification) && !(message is SearchingForMatchNotification))
            {
                if (message is EndOfGameStats)
                {
                    LoLLauncher.RiotObjects.Platform.Matchmaking.MatchMakerParams matchParams = new LoLLauncher.RiotObjects.Platform.Matchmaking.MatchMakerParams();
                    if (queueType == QueueTypes.INTRO_BOT)
                    {
                        matchParams.BotDifficulty = "INTRO";
                    }
                    else if (queueType == QueueTypes.BEGINNER_BOT)
                    {
                        matchParams.BotDifficulty = "EASY";
                    }
                    else if (queueType == QueueTypes.MEDIUM_BOT)
                    {
                        matchParams.BotDifficulty = "MEDIUM";
                    }

                    if (sumLevel == 3 && actualQueueType == QueueTypes.NORMAL_5x5)
                    {
                        queueType = actualQueueType;
                    }
                    else if (sumLevel == 6 && actualQueueType == QueueTypes.ARAM)
                    {
                        queueType = actualQueueType;
                    }
                    else if (sumLevel == 7 && actualQueueType == QueueTypes.NORMAL_3x3)
                    {
                        queueType = actualQueueType;
                    }

                    matchParams.QueueIds = new Int32[1] {
                        (int)queueType
                    };
                    LoLLauncher.RiotObjects.Platform.Matchmaking.SearchingForMatchNotification m = await connection.AttachToQueue(matchParams);

                    if (m.PlayerJoinFailures == null)
                    {
                        this.updateStatus("Chế độ chơi : " + queueType.ToString(), Accountname);
                    }
                    else
                    {
                        try
                        {
                            updateStatus("Couldn't enter Q - " + m.PlayerJoinFailures.Summoner.Name + " : " + m.PlayerJoinFailures.ReasonFailed, Accountname);
                        }
                        catch (Exception)
                        {
                            if (QueueFlag)
                            {
                                Console.WriteLine(
                                    "Something went wrong, couldn't enter queue. Check accounts.txt for correct queue type.");
                                connection.Disconnect();
                            }
                            else
                            {
                                this.updateStatus("Bạn đang bị vào hàng chờ thấp ... VCC", Accountname);
                                this.updateStatus("Tool đang check . đợi xíu . 1 phút 1 lần !", Accountname);
                                Thread.Sleep(1000 * 60);
                                EndOfGameStats eog = new EndOfGameStats();
                                connection_OnMessageReceived(sender, eog);
                            }
                        }
                    }
                }
                else
                {
                    if (message.ToString().Contains("EndOfGameStats"))
                    {
                        EndOfGameStats eog = new EndOfGameStats();
                        connection_OnMessageReceived(sender, eog);
                        exeProcess.Exited -= exeProcess_Exited;
                        exeProcess.Kill();
                        loginPacket = await this.connection.GetLoginDataPacketForUser();

                        archiveSumLevel = sumLevel;
                        sumLevel        = loginPacket.AllSummonerData.SummonerLevel.Level;
                        if (sumLevel != archiveSumLevel)
                        {
                            levelUp();
                        }
                    }
                }
            }
            //=======================
        }
Esempio n. 7
0
        private async void AttachToQueue()
        {
            MatchMakerParams matchParams = new MatchMakerParams();

            //Set BotParams
            if (queueType == QueueTypes.INTRO_BOT)
            {
                matchParams.BotDifficulty = "INTRO";
            }
            else if (queueType == QueueTypes.BEGINNER_BOT)
            {
                matchParams.BotDifficulty = "EASY";
            }
            else if (queueType == QueueTypes.MEDIUM_BOT)
            {
                matchParams.BotDifficulty = "MEDIUM";
            }
            //Check if is available to join queue.
            if (sumLevel == 3 && actualQueueType == QueueTypes.NORMAL_5x5)
            {
                queueType = actualQueueType;
            }
            else if (sumLevel == 6 && actualQueueType == QueueTypes.ARAM)
            {
                queueType = actualQueueType;
            }
            else if (sumLevel == 7 && actualQueueType == QueueTypes.NORMAL_3x3)
            {
                queueType = actualQueueType;
            }
            matchParams.QueueIds = new Int32[1] {
                (int)queueType
            };
            SearchingForMatchNotification m = await connection.AttachToQueue(matchParams);

            if (m.PlayerJoinFailures == null)
            {
                this.updateStatus("In Queue: " + queueType.ToString(), Accountname);
            }
            else
            {
                foreach (var failure in m.PlayerJoinFailures)
                {
                    if (failure.ReasonFailed == "LEAVER_BUSTED")
                    {
                        m_accessToken = failure.AccessToken;
                        if (failure.LeaverPenaltyMillisRemaining > m_leaverBustedPenalty)
                        {
                            m_leaverBustedPenalty = failure.LeaverPenaltyMillisRemaining;
                        }
                    }
                    else if (failure.ReasonFailed == "LEAVER_BUSTER_TAINTED_WARNING")
                    {
                        //updateStatus("Please login on your LoL Client and type I Agree to the message that comes up.", Accountname);
                        await connection.ackLeaverBusterWarning();

                        await connection.callPersistenceMessaging(new SimpleDialogMessageResponse()
                        {
                            AccountID = loginPacket.AllSummonerData.Summoner.SumId,
                            MsgID     = loginPacket.AllSummonerData.Summoner.SumId,
                            Command   = "ack"
                        });

                        connection_OnMessageReceived(null, (object)new EndOfGameStats());
                    }
                }

                if (String.IsNullOrEmpty(m_accessToken))
                {
                    // Queue dodger or something else
                }
                else
                {
                    updateStatus("Waiting out leaver buster: " + m_leaverBustedPenalty / 1000 / (float)60 + " minutes!", Accountname);
                    System.Threading.Thread.Sleep(TimeSpan.FromMilliseconds(m_leaverBustedPenalty));
                    m = await connection.AttachToLowPriorityQueue(matchParams, m_accessToken);

                    if (m.PlayerJoinFailures == null)
                    {
                        this.updateStatus("Succesfully joined lower priority queue!", Accountname);
                    }
                    else
                    {
                        this.updateStatus("There was an error in joining lower priority queue.\nDisconnecting.", Accountname);
                        connection.Disconnect();
                        parent.lognNewAccount();
                    }
                }
            }
        }
Esempio n. 8
0
        public async void connection_OnMessageReceived(object sender, object message)
        {
            if (message is GameDTO)
            {
                GameDTO game = message as GameDTO;
                switch (game.GameState)
                {
                case "CHAMP_SELECT":
                    if (this.firstTimeInLobby)
                    {
                        firstTimeInLobby = false;
                        updateStatus("In Champion Select", Accountname);
                        object obj = await connection.SetClientReceivedGameMessage(game.Id, "CHAMP_SELECT_CLIENT");

                        if (queueType != QueueTypes.ARAM)
                        {
                            if (Program.championId != "")
                            {
                                await connection.SelectChampion(Enums.championToId(Program.championId));

                                await connection.ChampionSelectCompleted();
                            }
                            else
                            {
                                await connection.SelectChampion(availableChampsArray.First(champ => champ.Owned || champ.FreeToPlay).ChampionId);

                                await connection.ChampionSelectCompleted();

                                int Spell1;
                                int Spell2;
                                if (!Program.rndSpell)
                                {
                                    Spell1 = Enums.spellToId(Program.spell1);
                                    Spell2 = Enums.spellToId(Program.spell2);
                                }
                                else
                                {
                                    var random    = new Random();
                                    var spellList = new List <int> {
                                        13, 6, 7, 10, 1, 11, 21, 12, 3, 14, 2, 4
                                    };

                                    int index  = random.Next(spellList.Count);
                                    int index2 = random.Next(spellList.Count);

                                    int randomSpell1 = spellList[index];
                                    int randomSpell2 = spellList[index2];

                                    if (randomSpell1 == randomSpell2)
                                    {
                                        int index3 = random.Next(spellList.Count);
                                        randomSpell2 = spellList[index3];
                                    }

                                    Spell1 = Convert.ToInt32(randomSpell1);
                                    Spell2 = Convert.ToInt32(randomSpell2);
                                }

                                await connection.SelectSpells(Spell1, Spell2);
                            }
                        }
                        break;
                    }
                    else
                    {
                        break;
                    }

                case "POST_CHAMP_SELECT":
                    firstTimeInLobby = false;
                    this.updateStatus("(Post Champ Select)", Accountname);
                    break;

                case "PRE_CHAMP_SELECT":
                    this.updateStatus("(Pre Champ Select)", Accountname);
                    break;

                case "GAME_START_CLIENT":
                    this.updateStatus("Game client ran", Accountname);
                    break;

                case "GameClientConnectedToServer":
                    this.updateStatus("Client connected to the server", Accountname);
                    break;

                case "IN_QUEUE":
                    this.updateStatus("In Queue", Accountname);
                    break;

                case "TERMINATED":
                    this.updateStatus("Re-entering queue", Accountname);
                    this.firstTimeInQueuePop = true;
                    break;

                case "JOINING_CHAMP_SELECT":
                    if (this.firstTimeInQueuePop && game.StatusOfParticipants.Contains("1"))
                    {
                        this.updateStatus("Accepted Queue", Accountname);
                        this.firstTimeInQueuePop = false;
                        this.firstTimeInLobby    = true;
                        object obj = await this.connection.AcceptPoppedGame(true);

                        break;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            else if (message is PlayerCredentialsDto)
            {
                string str = Enumerable.Last <string>((IEnumerable <string>)Enumerable.OrderBy <string, DateTime>(Directory.EnumerateDirectories((this.ipath ?? "") + "RADS\\solutions\\lol_game_client_sln\\releases\\"), (Func <string, DateTime>)(f => new DirectoryInfo(f).CreationTime))) + "\\deploy\\";
                LoLLauncher.RiotObjects.Platform.Game.PlayerCredentialsDto credentials = message as PlayerCredentialsDto;
                System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
                startInfo.CreateNoWindow   = false;
                startInfo.WorkingDirectory = str;
                startInfo.FileName         = "League of Legends.exe";
                startInfo.Arguments        = "\"8394\" \"LoLLauncher.exe\" \"\" \"" + credentials.ServerIp + " " +
                                             credentials.ServerPort + " " + credentials.EncryptionKey + " " + credentials.SummonerId + "\"";
                updateStatus("Launching League of Legends", Accountname);
                new Thread((ThreadStart)(() =>
                {
                    exeProcess = Process.Start(startInfo);
                    exeProcess.Exited += exeProcess_Exited;
                    while (exeProcess.MainWindowHandle == IntPtr.Zero)
                    {
                        ;
                    }
                    exeProcess.PriorityClass = ProcessPriorityClass.Idle;
                    exeProcess.EnableRaisingEvents = true;
                })).Start();
            }
            else if (!(message is GameNotification) && !(message is SearchingForMatchNotification))
            {
                if (message is EndOfGameStats)
                {
                    LoLLauncher.RiotObjects.Platform.Matchmaking.MatchMakerParams matchParams = new LoLLauncher.RiotObjects.Platform.Matchmaking.MatchMakerParams();
                    if (queueType == QueueTypes.INTRO_BOT)
                    {
                        matchParams.BotDifficulty = "INTRO";
                    }
                    else if (queueType == QueueTypes.BEGINNER_BOT)
                    {
                        matchParams.BotDifficulty = "EASY";
                    }
                    else if (queueType == QueueTypes.MEDIUM_BOT)
                    {
                        matchParams.BotDifficulty = "MEDIUM";
                    }

                    if (sumLevel == 3 && actualQueueType == QueueTypes.NORMAL_5x5)
                    {
                        queueType = actualQueueType;
                    }
                    else if (sumLevel == 6 && actualQueueType == QueueTypes.ARAM)
                    {
                        queueType = actualQueueType;
                    }
                    else if (sumLevel == 7 && actualQueueType == QueueTypes.NORMAL_3x3)
                    {
                        queueType = actualQueueType;
                    }

                    matchParams.QueueIds = new Int32[1] {
                        (int)queueType
                    };
                    LoLLauncher.RiotObjects.Platform.Matchmaking.SearchingForMatchNotification m = await connection.AttachToQueue(matchParams);

                    if (m.PlayerJoinFailures == null)
                    {
                        this.updateStatus("In Queue: " + queueType.ToString(), Accountname);
                    }
                    else
                    {
                        try
                        {
                            updateStatus("Couldn't enter Q - " + m.PlayerJoinFailures.Summoner.Name + " : " + m.PlayerJoinFailures.ReasonFailed, Accountname);
                        }
                        catch (Exception) { Console.WriteLine("Something went wrong, couldn't enter queue. Check accounts.txt for correct queue type."); connection.Disconnect(); }
                    }
                }
                else
                {
                    if (message.ToString().Contains("EndOfGameStats"))
                    {
                        EndOfGameStats eog = new EndOfGameStats();
                        connection_OnMessageReceived(sender, eog);
                        exeProcess.Exited -= exeProcess_Exited;
                        exeProcess.Kill();
                        loginPacket = await this.connection.GetLoginDataPacketForUser();

                        archiveSumLevel = sumLevel;
                        sumLevel        = loginPacket.AllSummonerData.SummonerLevel.Level;
                        if (sumLevel != archiveSumLevel)
                        {
                            levelUp();
                        }
                    }
                }
            }
        }
Esempio n. 9
0
 private void connection_OnLogin(object sender, string username, string ipAddress)
 {
     new Thread((ThreadStart)(async() =>
     {
         updateStatus("Connecting...", Accountname);
         loginPacket = await connection.GetLoginDataPacketForUser();
         await connection.Subscribe("bc", loginPacket.AllSummonerData.Summoner.AcctId);
         await connection.Subscribe("cn", loginPacket.AllSummonerData.Summoner.AcctId);
         await connection.Subscribe("gn", loginPacket.AllSummonerData.Summoner.AcctId);
         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();
             }
             await connection.CreateDefaultSummoner(summonerName);
             updateStatus("Created Summoner: " + summonerName, Accountname);
         }
         sumLevel = loginPacket.AllSummonerData.SummonerLevel.Level;
         string sumName = loginPacket.AllSummonerData.Summoner.Name;
         double sumId = loginPacket.AllSummonerData.Summoner.SumId;
         rpBalance = loginPacket.RpBalance;
         if (sumLevel > Core.maxLevel || sumLevel == Core.maxLevel)
         {
             connection.Disconnect();
             updateStatus("Summoner: " + sumName + " is already max level.", Accountname);
             updateStatus("Log into new account.", Accountname);
             Core.lognNewAccount();
             return;
         }
         if (rpBalance == 400.0 && Core.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;
         }
         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);
         }
         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();
 }
Esempio n. 10
0
        private async void connection_OnMessageReceived(object sender, object message)
        {
            if (message is GameDTO)
            {
                GameDTO game = message as GameDTO;
                Console.WriteLine("Message Type:" + game.GameState);
                switch (game.GameState)
                {
                case "START_REQUESTED":
                    break;

                case "FAILED_TO_START":
                    Console.WriteLine("Failed to Start!");
                    break;

                case "CHAMP_SELECT":
                    firstTimeInCustom   = true;
                    firstTimeInQueuePop = true;
                    if (firstTimeInLobby)
                    {
                        firstTimeInLobby = false;
                        object obj = await connection.SetClientReceivedGameMessage(game.Id, "CHAMP_SELECT_CLIENT");

                        if (QueueType != QueueTypes.ARAM)
                        {
                            int Spell1;
                            int Spell2;
                            var random    = new Random();
                            var spellList = new List <int> {
                                13, 6, 7, 1, 11, 21, 12, 3, 14, 2, 4
                            };

                            int index  = random.Next(spellList.Count);
                            int index2 = random.Next(spellList.Count);

                            int randomSpell1 = spellList[index];
                            int randomSpell2 = spellList[index2];

                            if (randomSpell1 == randomSpell2)
                            {
                                int index3 = random.Next(spellList.Count);
                                randomSpell2 = spellList[index3];
                            }

                            Spell1 = Convert.ToInt32(randomSpell1);
                            Spell2 = Convert.ToInt32(randomSpell2);

                            await connection.SelectSpells(Spell1, Spell2);

                            var randAvailableChampsArray = myChampions.Shuffle();
                            await connection.SelectChampion(randAvailableChampsArray.First(champ => champ.Owned || champ.FreeToPlay).ChampionId);

                            await connection.ChampionSelectCompleted();
                        }
                        break;
                    }
                    else
                    {
                        break;
                    }

                case "PRE_CHAMP_SELECT":
                    updateStatus(msgStatus.INFO, "Champion selection in progress");
                    break;

                case "POST_CHAMP_SELECT":
                    firstTimeInLobby = false;
                    if (firstTimeInPostChampSelect)
                    {
                        firstTimeInPostChampSelect = false;
                        updateStatus(msgStatus.INFO, "Champion selection is done, waiting for game to start");
                        break;
                    }
                    else
                    {
                        break;
                    }

                case "IN_QUEUE":
                    updateStatus(msgStatus.INFO, "In Queue");
                    break;

                case "TERMINATED":
                    updateStatus(msgStatus.INFO, "Re-entering queue");
                    firstTimeInPostChampSelect = true;
                    firstTimeInQueuePop        = true;
                    break;

                case "JOINING_CHAMP_SELECT":
                    if (firstTimeInQueuePop && game.StatusOfParticipants.Contains("1"))
                    {
                        updateStatus(msgStatus.INFO, "Accepted Queue");
                        firstTimeInQueuePop = false;
                        firstTimeInLobby    = true;
                        object obj = await connection.AcceptPoppedGame(true);

                        break;
                    }
                    else
                    {
                        break;
                    }

                default:
                    updateStatus(msgStatus.INFO, "[DEFAULT]" + game.GameStateString);
                    break;
                }
            }
            else if (message.GetType() == typeof(TradeContractDTO))
            {
                TradeContractDTO tradeDto = message as TradeContractDTO;
                if (tradeDto != null)
                {
                    switch (tradeDto.State)
                    {
                    case "PENDING":
                        if (tradeDto != null)
                        {
                            object obj = await connection.AcceptTrade(tradeDto.RequesterInternalSummonerName, (int)tradeDto.RequesterChampionId);

                            break;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            else if (message is PlayerCredentialsDto)
            {
                firstTimeInPostChampSelect = true;
                PlayerCredentialsDto dto       = message as PlayerCredentialsDto;
                ProcessStartInfo     startInfo = new ProcessStartInfo();
                startInfo.WorkingDirectory = FindLoLExe();
                startInfo.FileName         = "League of Legends.exe";
                startInfo.Arguments        = "\"8394\" \"LoLLauncher.exe\" \"\" \"" + dto.ServerIp + " " +
                                             dto.ServerPort + " " + dto.EncryptionKey + " " + dto.SummonerId + "\"";
                updateStatus(msgStatus.INFO, "Launching League of Legends");

                new Thread(() =>
                {
                    exeProcess = Process.Start(startInfo);
                    exeProcess.EnableRaisingEvents = true;
                    exeProcess.Exited += new EventHandler(exeProcess_Exited);
                    while (exeProcess.MainWindowHandle == IntPtr.Zero)
                    {
                    }
                    Console.WriteLine(exeProcess.MainWindowTitle);
                    Thread.Sleep(1000);
                    App.gameMask.addGame(info.username, info.region.ToString(), exeProcess);
                }).Start();
            }
            else if (!(message is GameNotification) && !(message is SearchingForMatchNotification))
            {
                if (message is EndOfGameStats)
                {
                    object obj4 = await connection.ackLeaverBusterWarning();

                    object obj5 = await connection.callPersistenceMessaging(new SimpleDialogMessageResponse()
                    {
                        AccountID = loginDataPacket.AllSummonerData.Summoner.SumId,
                        MsgID     = loginDataPacket.AllSummonerData.Summoner.SumId,
                        Command   = "ack"
                    });

                    MatchMakerParams matchParams = new MatchMakerParams();
                    checkAndUpdateQueueType();
                    if (QueueType == QueueTypes.INTRO_BOT)
                    {
                        matchParams.BotDifficulty = "INTRO";
                    }
                    else if (QueueType == QueueTypes.BEGINNER_BOT)
                    {
                        matchParams.BotDifficulty = "EASY";
                    }
                    else if (QueueType == QueueTypes.MEDIUM_BOT)
                    {
                        matchParams.BotDifficulty = "MEDIUM";
                    }
                    if (QueueType != 0)
                    {
                        matchParams.QueueIds = new Int32[1] {
                            (int)QueueType
                        };
                        SearchingForMatchNotification m = await connection.AttachToQueue(matchParams);

                        if (m.PlayerJoinFailures == null)
                        {
                            updateStatus(msgStatus.INFO, "In Queue: " + QueueType.ToString());
                        }
                        else
                        {
                            foreach (var failure in m.PlayerJoinFailures)
                            {
                                if (failure.ReasonFailed == "LEAVER_BUSTED")
                                {
                                    m_accessToken = failure.AccessToken;
                                    if (failure.LeaverPenaltyMillisRemaining > m_leaverBustedPenalty)
                                    {
                                        m_leaverBustedPenalty = failure.LeaverPenaltyMillisRemaining;
                                    }
                                }
                                Console.WriteLine("Start Failed:" + failure.ReasonFailed);
                            }

                            if (string.IsNullOrEmpty(m_accessToken))
                            {
                                foreach (var failure in m.PlayerJoinFailures)
                                {
                                    updateStatus(msgStatus.INFO, "Dodge Remaining Time: " + Convert.ToString((failure.DodgePenaltyRemainingTime / 1000 / (float)60)).Replace(",", ":") + "...");
                                }
                            }
                            else
                            {
                                double minutes = m_leaverBustedPenalty / 1000 / (float)60;
                                updateStatus(msgStatus.INFO, "Waiting out leaver buster: " + minutes + " minutes!");
                                t = TimeSpan.FromMinutes((int)minutes);
                                //Tick(); -> Enable to get visual time remaining
                                Thread.Sleep(TimeSpan.FromMilliseconds(m_leaverBustedPenalty));
                                m = await connection.AttachToLowPriorityQueue(matchParams, m_accessToken);

                                if (m.PlayerJoinFailures == null)
                                {
                                    updateStatus(msgStatus.INFO, "Succesfully joined lower priority queue!");
                                }
                                else
                                {
                                    updateStatus(msgStatus.ERROR, "There was an error in joining lower priority queue.\nDisconnecting.");
                                    connection.Disconnect();
                                }
                            }
                        }
                    }
                }
                else if (message.ToString().Contains("EndOfGameStats"))
                {
                    EndOfGameStats eog = new EndOfGameStats();
                    exeProcess.Exited -= new EventHandler(exeProcess_Exited);
                    exeProcess.Kill();
                    Thread.Sleep(500);
                    if (exeProcess.Responding)
                    {
                        Process.Start("taskkill /F /IM \"League of Legends.exe\"");
                    }
                    loginDataPacket = await connection.GetLoginDataPacketForUser();

                    if (type == RotationType.SmurfDone)
                    {
                        if (info.desiredLevel > loginDataPacket.AllSummonerData.SummonerLevel.Level)
                        {
                            connection_OnMessageReceived(sender, eog);
                        }
                        else
                        {
                            connection.Disconnect();
                        }
                    }
                    else
                    {
                        connection_OnMessageReceived(sender, eog);
                    }
                }
            }
        }
Esempio n. 11
0
        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("Logged in as " + 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();
        }