Пример #1
0
        private void handlePlayerCredentialsDto(object message)
        {
            string str = Enumerable.Last <string>((IEnumerable <string>)Enumerable.OrderBy <string, DateTime>(Directory.EnumerateDirectories((Properties.Settings.Default.lolPath ?? "").Split(new string[] { "lol.launcher.exe" }, StringSplitOptions.None)[0] + "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        = string.Concat(new object[] { "\"8394\" \"LoLLauncher.exe\" \"\" \"", credentials.ServerIp, " ", credentials.ServerPort, " ", credentials.EncryptionKey, " ", credentials.SummonerId, "\"" });
            Logger.Push("Starting game", "info", username);
            lastStarter = startInfo;
            startProcessor(startInfo);
        }
        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();
                        }
                    }
                }
            }
            //=======================
        }
Пример #3
0
        public async void connection_OnMessageReceived(object sender, object message)
        {
            if (message is GameDTO)
            {
                GameDTO game = message as GameDTO;
                switch (game.GameState)
                {
                case "TEAM_SELECT":
                    int totalPlayers = game.TeamOne.Count + game.TeamTwo.Count;
                    this.updateStatus("In custom lobby, playerCount:" + totalPlayers, Accountname);
                    if (totalPlayers == 6 && game.OwnerSummary.AccountId == this.connection.AccountID())
                    {
                        await connection.StartChampionSelection(game.Id, game.OptimisticLock);
                    }
                    break;

                case "CHAMP_SELECT":
                    Program.QueueValid = true;
                    if (this.firstTimeInLobby)
                    {
                        QueueFlag        = true;
                        firstTimeInLobby = false;
                        updateStatus("In Champion Selection", 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));

                                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();
                                int randomAdc = randAvailableChampsArray.First(champ => (champ.Owned || champ.FreeToPlay) && (champ.ChampionId == 22 || champ.ChampionId == 51 || champ.ChampionId == 42 || champ.ChampionId == 119 || champ.ChampionId == 81 || champ.ChampionId == 104 || champ.ChampionId == 222 || champ.ChampionId == 429 || champ.ChampionId == 96 || champ.ChampionId == 236 || champ.ChampionId == 21 || champ.ChampionId == 133 || champ.ChampionId == 15 || champ.ChampionId == 18 || champ.ChampionId == 29 || champ.ChampionId == 110 || champ.ChampionId == 67)).ChampionId;
                                await connection.SelectChampion(randomAdc);


                                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);

                                var randAvailableChampsArray = availableChampsArray.Shuffle();
                                int randomAdc = randAvailableChampsArray.First(champ => (champ.Owned || champ.FreeToPlay) && (champ.ChampionId == 22 || champ.ChampionId == 51 || champ.ChampionId == 42 || champ.ChampionId == 119 || champ.ChampionId == 81 || champ.ChampionId == 104 || champ.ChampionId == 222 || champ.ChampionId == 429 || champ.ChampionId == 96 || champ.ChampionId == 236 || champ.ChampionId == 21 || champ.ChampionId == 133 || champ.ChampionId == 15 || champ.ChampionId == 18 || champ.ChampionId == 29 || champ.ChampionId == 110 || champ.ChampionId == 67)).ChampionId;

                                await connection.SelectChampion(randomAdc);

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

                case "POST_CHAMP_SELECT":
                    firstTimeInLobby = false;
                    this.updateStatus("Last 10 seconds to start game", Accountname);
                    break;

                case "PRE_CHAMP_SELECT":
                    this.updateStatus("Last seconds to set champion", Accountname);
                    break;

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

                case "GameClientConnectedToServer":
                    this.updateStatus("Connected to server", Accountname);
                    break;

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

                case "TERMINATED":
                    this.updateStatus("Re entering to queue", Accountname);
                    this.firstTimeInQueuePop = true;
                    if (queueType == QueueTypes.CUSTOM)
                    {
                        CreatePracticeGame();
                    }
                    break;

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

                        break;
                    }
                    else
                    {
                        break;
                    }

                case "LEAVER_BUSTED":
                    this.updateStatus("You are leaver busted", Accountname);
                    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;
                if (Program.replaceConfig)
                {
                    startInfo.WindowStyle = ProcessWindowStyle.Hidden;
                }
                startInfo.FileName  = "League of Legends.exe";
                startInfo.Arguments = "\"8394\" \"LoLLauncher.exe\" \"\" \"" + credentials.ServerIp + " " +
                                      credentials.ServerPort + " " + credentials.EncryptionKey + " " + credentials.SummonerId + "\"";
                updateStatus("Starting Game", Accountname);
                new Thread((ThreadStart)(() =>
                {
                    exeProcess = Process.Start(startInfo);
                    exeProcess.Exited += exeProcess_Exited;
                    while (exeProcess.MainWindowHandle == IntPtr.Zero)
                    {
                        ;
                    }
                    exeProcess.PriorityClass = ProcessPriorityClass.Idle;
                    exeProcess.EnableRaisingEvents = true;
                    if (!Program.bolRunning)
                    {
                        Thread.Sleep(3000);
                        BasicInject.Inject(exeProcess, Program.dllPath);
                    }
                })).Start();
            }
            else if (!(message is GameNotification) && !(message is SearchingForMatchNotification))
            {
                if (message is EndOfGameStats)
                {
                    EndOfGameStats eog = message as EndOfGameStats;
                    this.joinQueue();
                }
                else
                {
                    if (message.ToString().Contains("EndOfGameStats"))
                    {
                        updateStatus("Game ending, calculating results", Accountname);
                        EndOfGameStats eog = new EndOfGameStats();
                        connection_OnMessageReceived(sender, eog);
                        exeProcess.Exited -= exeProcess_Exited;
                        exeProcess.Kill();
                        Thread.Sleep(500);
                        if (exeProcess.Responding)
                        {
                            Process.Start("taskkill /F /IM \"League of Legends.exe\"");
                        }
                        loginPacket = await this.connection.GetLoginDataPacketForUser();

                        archiveSumLevel = sumLevel;
                        sumLevel        = loginPacket.AllSummonerData.SummonerLevel.Level;
                        if (sumLevel != archiveSumLevel)
                        {
                            levelUp();
                        }
                    }
                }
            }
        }
Пример #4
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();
                        }
                    }
                }
            }
        }
Пример #5
0
 public void LaunchGame(PlayerCredentialsDto CurrentGame)
 {
     ProcessStartInfo startInfo = new ProcessStartInfo();
     startInfo.CreateNoWindow = false;
     startInfo.WorkingDirectory = FindLoLExe();
     startInfo.FileName = "League of Legends.exe";
     startInfo.Arguments = "\"8394\" \"LoLLauncher.exe\" \"\" \"" + CurrentGame.ServerIp + " " +
         CurrentGame.ServerPort + " " + CurrentGame.EncryptionKey + " " + CurrentGame.SummonerId + "\"";
     updateStatus("Playing League of Legends", Accountname);
     new Thread(() =>
     {
         exeProcess = Process.Start(startInfo);
         while (exeProcess.MainWindowHandle == IntPtr.Zero) { }
         Thread.Sleep(1000);
     }).Start();
 }
Пример #6
0
        public async void connection_OnMessageReceived(object sender, object message)
        {
            if (message is GameDTO)
            {
                GameDTO game = message as GameDTO;
                switch (game.GameState)
                {
                case "TEAM_SELECT":
                    if (Program.IsGameCreated == true && Program.LobbyPlayers == Program.maxBots && Program.LobbyOwner.Equals(Accountname) && leader)
                    {
                        Thread.Sleep(2000);
                        this.updateStatus("Start Custom Game", Accountname);
                        await connection.StartChampionSelection(Program.GameID, game.OptimisticLock);
                    }
                    break;

                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 != "" && 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));

                                this.updateStatus("Champion Pick : " + Program.championId, this.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);

                                this.updateStatus("Random Champion", this.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);

                                this.updateStatus("Random Champion", this.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("Game client ran", Accountname);
                    break;

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

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

                case "TERMINATED":
                    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;
                    }

                case "LEAVER_BUSTED":
                    this.updateStatus("Leave busted", Accountname);
                    break;
                }
            }
            else if (message is PlayerCredentialsDto)
            {
                string str = ipath + "GAME\\";
                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();
                p = true;
                Program.IsGameCreated = false;
                totalgame++;
            }
            else if (message is EndOfGameStats)
            {
                EndOfGameStats eog = message as EndOfGameStats;
                if (p)
                {
                    Console.ForegroundColor = ConsoleColor.Magenta;
                    this.updateStatus("========Result========", this.Accountname);
                    var tempxp = eog.ExperienceEarned + eog.BoostXpEarned;
                    var tempip = eog.IpEarned + eog.BoostIpEarned;
                    ip = ip + tempip;
                    xp = xp + tempxp;

                    bool tempvic         = false;
                    var  allParticipants =
                        new List <PlayerParticipantStatsSummary>(eog.TeamPlayerParticipantStats.ToArray());
                    foreach (PlayerParticipantStatsSummary summary in allParticipants)
                    {
                        foreach (RawStatDTO stat in summary.Statistics.Where(stat => stat.StatTypeName.ToLower() == "win"))
                        {
                            if (summary.SummonerName == loginPacket.AllSummonerData.Summoner.Name)
                            {
                                win++;
                                tempvic = true;
                            }
                        }
                    }

                    if (tempvic)
                    {
                        this.updateStatus("Victory!", this.Accountname);
                    }
                    else
                    {
                        this.updateStatus("Defeat!", this.Accountname);
                    }
                    this.updateStatus("IP Earned: " + tempip, this.Accountname);
                    this.updateStatus("XP Earned: " + tempxp, this.Accountname);
                    var winrate = (win / totalgame) * 100;
                    this.updateStatus("Win Rate: " + winrate + "%" + "(Win: " + win + " TotalGame: " + totalgame + ")", this.Accountname);
                    if (loginPacket.AllSummonerData.SummonerLevel.Level < 30)
                    {
                        var xpnextlevel = loginPacket.AllSummonerData.SummonerLevel.ExpToNextLevel;
                        this.updateStatus("Exp to Next Level : " + xpnextlevel, this.Accountname);
                    }

                    this.updateStatus("====================", this.Accountname);
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.Title           = " Current Connected: " + Program.connectedAccs + " Total IP: " + ip + " Total XP:" + xp + " Total Game: " + totalgame + " WinRate: " + winrate + "%";
                    exeProcess.Exited      -= exeProcess_Exited;
                    exeProcess.Kill();
                    p           = false;
                    loginPacket = await this.connection.GetLoginDataPacketForUser();

                    archiveSumLevel = sumLevel;
                    sumLevel        = loginPacket.AllSummonerData.SummonerLevel.Level;
                    if (sumLevel != archiveSumLevel)
                    {
                        levelUp();
                    }
                    this.updateStatus("Re-entering queue", Accountname);
                }

                if (queueType == QueueTypes.CUSTOM_DOM_3x3 || queueType == QueueTypes.CUSTOM_HA_3x3)
                {
                    if (Program.IsGameCreated == false && leader)
                    {
                        PracticeGameConfig cfg = new PracticeGameConfig();
                        BotParticipant     bcg = new BotParticipant();

                        GameMap map = new GameMap();
                        if (queueType == QueueTypes.CUSTOM_DOM_3x3)
                        {
                            map.Description      = "desc";
                            map.DisplayName      = "Crystal Scar";
                            map.TotalPlayers     = 6;
                            map.Name             = "Crystal Scar";
                            map.MapId            = (int)GameMode.Dominion;
                            map.MinCustomPlayers = 1;
                            cfg.GameMode         = StringEnum.GetStringValue(GameMode.Dominion);
                        }
                        else
                        {
                            map.Description      = "desc";
                            map.DisplayName      = "Howling Abyss";
                            map.TotalPlayers     = 6;
                            map.Name             = "Howling Abyss";
                            map.MapId            = (int)GameMode.HowlingAbyss;
                            map.MinCustomPlayers = 1;
                            cfg.GameMode         = StringEnum.GetStringValue(GameMode.HowlingAbyss);
                        }

                        cfg.GameName        = RandomString(10);
                        cfg.GamePassword    = "******";
                        cfg.GameMap         = map;
                        cfg.MaxNumPlayers   = 6;
                        cfg.GameTypeConfig  = 1;
                        cfg.AllowSpectators = "NONE";

                        GameDTO result = await connection.CreatePracticeGame(cfg);



                        // Custom game has been created;
                        Program.IsGameCreated = true;
                        Program.GameID        = result.Id;
                        Program.LobbyOwner    = Accountname;
                        Program.LobbyPlayers  = 1;

                        // Notify
                        updateStatus(" Game [" + Program.GameID + "] has been created. Lobby password: "******"Waiting Leader Create Room", Accountname);
                        } while (!Program.IsGameCreated);

                        if (Program.IsGameCreated == true && Program.LobbyOwner != Accountname && Program.LobbyPlayers < Program.maxBots && !leader)
                        {
                            Program.LobbyPlayers++;
                            await connection.JoinGame(Program.GameID, "Paruru");

                            updateStatus(" Player has joined the lobby! Players: [" + Program.LobbyPlayers + "/" + Program.maxBots + "]", Accountname);
                            System.Threading.Thread.Sleep(5000);
                        }
                    }
                }
                else
                {
                    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
                    {
                        foreach (QueueDodger current in m.PlayerJoinFailures)
                        {
                            if (current.ReasonFailed == "LEAVER_BUSTED")
                            {
                                m_accessToken = current.AccessToken;
                                if (current.LeaverPenaltyMillisRemaining > this.m_leaverBustedPenalty)
                                {
                                    this.m_leaverBustedPenalty = current.LeaverPenaltyMillisRemaining;
                                }
                            }
                        }
                        if (!string.IsNullOrEmpty(this.m_accessToken))
                        {
                            this.updateStatus("Waiting For Leaver Busted: " + (float)(this.m_leaverBustedPenalty / 1000) / 60f + " Minute", this.Accountname);
                            Thread.Sleep(TimeSpan.FromMilliseconds((double)this.m_leaverBustedPenalty));
                            m = await connection.AttachToLowPriorityQueue(matchParams, this.m_accessToken);

                            if (m.PlayerJoinFailures == null)
                            {
                                this.updateStatus("In Queue: " + queueType.ToString(), this.Accountname);
                            }
                            else
                            {
                                this.updateStatus("There was an error in joining lower priority queue.\nDisconnecting.", this.Accountname);
                                this.connection.Disconnect();
                            }
                        }
                    }
                }
            }
            else
            {
            }
        }