示例#1
0
 private void connection_OnLogin(object sender, string username, string ipAddress)
 {
     new Thread((ThreadStart)(async() =>
     {
         updateStatus("Connecting...", Accountname);
         loginPacket = await connection.GetLoginDataPacketForUser();
         if (loginPacket.AllSummonerData == null)
         {
             Random rnd = new Random();
             String summonerName = Accountname;
             if (summonerName.Length > 16)
             {
                 summonerName = summonerName.Substring(0, 11) + new Random().Next(1000, 9999).ToString();
             }
             updateStatus("Create Summoner: " + summonerName, Accountname);
             await connection.CreateDefaultSummoner(summonerName);
         }
         await connection.Subscribe("bc", loginPacket.AllSummonerData.Summoner.AcctId);
         await connection.Subscribe("cn", loginPacket.AllSummonerData.Summoner.AcctId);
         await connection.Subscribe("gn", loginPacket.AllSummonerData.Summoner.AcctId);
         sumLevel = loginPacket.AllSummonerData.SummonerLevel.Level;
         sumName = loginPacket.AllSummonerData.Summoner.Name;
         sumId = loginPacket.AllSummonerData.Summoner.SumId;
         rpBalance = loginPacket.RpBalance;
         if (sumLevel > parent.maxLevel || sumLevel == parent.maxLevel)
         {
             connection.Disconnect();
             updateStatus("Summoner: " + sumName + " is already max level.", Accountname);
             updateStatus("Log into new account.", Accountname);
             parent.lognNewAccount();
             return;
         }
         if (sumLevel < 3.0 && queueType == QueueTypes.NORMAL_5x5)
         {
             this.updateStatus("Need to be Level 3 before NORMAL_5x5 queue.", Accountname);
             this.updateStatus("Joins Co-Op vs AI (Beginner) queue until 3", Accountname);
             queueType = QueueTypes.BEGINNER_BOT;
             actualQueueType = QueueTypes.NORMAL_5x5;
         }
         else if (sumLevel < 6.0 && queueType == QueueTypes.ARAM)
         {
             this.updateStatus("Need to be Level 6 before ARAM queue.", Accountname);
             this.updateStatus("Joins Co-Op vs AI (Beginner) queue until 6", Accountname);
             queueType = QueueTypes.BEGINNER_BOT;
             actualQueueType = QueueTypes.ARAM;
         }
         else if (sumLevel < 7.0 && queueType == QueueTypes.NORMAL_3x3)
         {
             this.updateStatus("Need to be Level 7 before NORMAL_3x3 queue.", Accountname);
             this.updateStatus("Joins Co-Op vs AI (Beginner) queue until 7", Accountname);
             queueType = QueueTypes.BEGINNER_BOT;
             actualQueueType = QueueTypes.NORMAL_3x3;
         }
         if ((loginPacket.AllSummonerData.Summoner.ProfileIconId == -1 || loginPacket.AllSummonerData.Summoner.ProfileIconId == 1))
         {
             double[] ids = new double[Convert.ToInt32(sumId)];
             string icons = await connection.GetSummonerIcons(ids);
             List <int> availableIcons = new List <int> {
             };
             var random = new Random();
             for (int i = 0; i < 29; i++)
             {
                 availableIcons.Add(i);
             }
             foreach (var id in icons)
             {
                 availableIcons.Add(Convert.ToInt32(id));
             }
             int index = random.Next(availableIcons.Count);
             int randomIcon = availableIcons[index];
             await connection.UpdateProfileIconId(randomIcon);
         }
         if (rpBalance == 400.0 && parent.buyBoost && sumLevel < 5)
         {
             updateStatus("Buying XP Boost", Accountname);
             try
             {
                 Task t = new Task(buyBoost);
                 t.Start();
             }
             catch (Exception exception)
             {
                 updateStatus("Couldn't buy RP Boost.\n" + exception, Accountname);
             }
         }
         updateStatus("Logged in as " + loginPacket.AllSummonerData.Summoner.Name + " @ level " + loginPacket.AllSummonerData.SummonerLevel.Level, Accountname);
         availableChampsArray = await connection.GetAvailableChampions();
         PlayerDTO player = await connection.CreatePlayer();
         if (loginPacket.ReconnectInfo != null && loginPacket.ReconnectInfo.Game != null)
         {
             connection_OnMessageReceived(sender, (object)loginPacket.ReconnectInfo.PlayerCredentials);
         }
         else
         {
             connection_OnMessageReceived(sender, (object)new EndOfGameStats());
         }
     })).Start();
 }
        void connection_OnLogin(object sender, string username, string ipAddress)
        {
            new Thread(async delegate()
            {
                RegisterNotifications();
                loginPacket = await connection.GetLoginDataPacketForUser();
                //

                /*FileSystemWatcher watcher = new FileSystemWatcher();
                 * watcher.Path = @"..\Common\";
                 * watcher.Filter = "summoner_" + loginPacket.AllSummonerData.Summoner.Name + "_finished.txt";
                 * watcher.NotifyFilter = NotifyFilters.LastAccess |
                 *       NotifyFilters.LastWrite |
                 *       NotifyFilters.FileName |
                 *       NotifyFilters.DirectoryName;
                 * watcher.Created += watcher_Created;
                 * watcher.EnableRaisingEvents = true;*/
                if (loginPacket.AllSummonerData == null)
                {
                    Random rnd          = new Random();
                    String summonerName = username;
                    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("Logged in on " + loginPacket.AllSummonerData.Summoner.Name);
                updateStatus("Starting at lvl " + loginPacket.AllSummonerData.SummonerLevel.Level);
                if (loginPacket.AllSummonerData.SummonerLevel.Level < 6 && queueType == QueueTypes.ARAM)
                {
                    updateStatus("Need to lvl up before ARAM. Defaulting to intro bots");
                    queueType = QueueTypes.INTRO_BOT;
                }
                updateStatus("Starting with " + loginPacket.IpBalance + "ip");
                LoLLauncher.RiotObjects.Platform.Matchmaking.GameQueueConfig[] availableQueues = await connection.GetAvailableQueues();
                //LoLLauncher.RiotObjects.Platform.Summoner.Boost.SummonerActiveBoostsDTO boosts = await connection.GetSumonerActiveBoosts();
                //LoLLauncher.RiotObjects.Platform.Leagues.Client.Dto.SummonerLeagueItemAndProgresssDTO leaguePosProg = await connection.GetMyLeaguePositionsAndProgress();
                availableChampsArray = await connection.GetAvailableChampions();
                LoLLauncher.RiotObjects.Platform.Summoner.Runes.SummonerRuneInventory sumRuneInven   = await connection.GetSummonerRuneInventory(loginPacket.AllSummonerData.Summoner.SumId);
                LoLLauncher.RiotObjects.Platform.Leagues.Client.Dto.SummonerLeagueItemsDTO leaguePos = await connection.GetMyLeaguePositions();
                object preferences = await connection.LoadPreferencesByKey("KEY BINDINGS", 1, false);
                LoLLauncher.RiotObjects.Platform.Summoner.Masterybook.MasteryBookDTO masteryBook = await connection.GetMasteryBook(loginPacket.AllSummonerData.Summoner.SumId);
                LoLLauncher.RiotObjects.Team.Dto.PlayerDTO player = await connection.CreatePlayer();

                if (loginPacket.ReconnectInfo != null && loginPacket.ReconnectInfo.Game != null)
                {
                    updateStatus("Reconnecting to game");
                    connection_OnMessageReceived(sender, loginPacket.ReconnectInfo.PlayerCredentials);
                }
                else
                {
                    if (queueType == QueueTypes.CUSTOM)
                    {
                        CreatePracticeGame();
                    }
                    else
                    {
                        LoLLauncher.RiotObjects.Platform.Statistics.EndOfGameStats eog = new LoLLauncher.RiotObjects.Platform.Statistics.EndOfGameStats();
                        connection_OnMessageReceived(sender, eog);
                    }
                }
            }).Start();
        }
示例#3
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);
                    }
                }
            }
        }
示例#4
0
        private void connection_OnLogin(object sender, string username, string ipAddress)
        {
            Logger.Push("Smurf logged in, ready to queue", "info", this.username);
            smurf.updateTimer(15);

            new Thread((ThreadStart)(async() =>
            {
                loginPacket = await connection.GetLoginDataPacketForUser();
                this.RegisterNotifications();
                if (loginPacket.AllSummonerData == null)
                {
                    Random rnd = new Random();
                    String summonerName = username;
                    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;

                    Logger.Push("Smurf summoner name updated as" + summonerName, "success", this.username);
                }
                currentLevel = loginPacket.AllSummonerData.SummonerLevel.Level;
                currentExp = loginPacket.AllSummonerData.SummonerLevelAndPoints.ExpPoints;
                toNextLevel = loginPacket.AllSummonerData.SummonerLevel.ExpToNextLevel;
                dynamicSummonerName = loginPacket.AllSummonerData.Summoner.Name;
                summonerId = loginPacket.AllSummonerData.Summoner.SumId;
                rpBalance = loginPacket.RpBalance;
                updateSmurfInfo();

                if (currentLevel >= desiredLevel)
                {
                    Logger.Push("Smurfing is done, smurf is level: " + (int)currentLevel, "success", this.username);
                    if (!smurf.groupMember)
                    {
                        connection.Disconnect();
                    }
                }

                if (rpBalance == 400.0 && App.Client.UserData.Settings.BuyBoost)
                {
                    Logger.Push("Buying xp boost", "info", this.username);
                    try
                    {
                        Task t = new Task(buyBoost);
                        t.Start();
                    }
                    catch (Exception exception)
                    {
                        Logger.Push("Failed to buy xp boost", "warning", this.username);
                    }
                }

                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); //Oyun varsa reconnect paketini yonlendir
                }
                else
                {
                    if (!smurf.groupMember)
                    {
                        this.joinQueue();
                    }
                    else
                    {
                        if (smurf.isHost)
                        {
                            this.createLobby();
                        }
                        else
                        {
                            Logger.Push("Requesting host to invite me.", "info", this.username);
                            smurf.hostCallback.inviteMe(summonerId);
                            smurf.updateTimer(15);
                        }
                    }
                }
            })).Start();
        }