Example #1
0
 private bool OnSearchingForMatch(SearchingForMatchNotification search)
 {
     if (search.JoinedQueues.Count > 0)
     {
         OnAdvancedToMatchmaking();
     }
     else
     {
         if (!search.PlayerJoinFailures.Any())
         {
             Debugger.Break();
         }
         var fail = search.PlayerJoinFailures.First();
         //TODO OnFailedQueue(fail);
         var dodger = fail as QueueDodger;
         if (dodger != null)
         {
             Debug.WriteLine(dodger.ReasonFailed + ": " + dodger.DodgePenaltyRemainingTime);
         }
         else
         {
             Debug.WriteLine(fail.ReasonFailed);
         }
     }
     return(true);
 }
Example #2
0
        public static Queue Create(SearchingForMatchNotification searching)
        {
            if (searching.PlayerJoinFailures != null)
            {
                var  leaver = searching.PlayerJoinFailures[0];
                bool me     = leaver.Summoner.SummonerId == Session.Current.Account.SummonerID;
                switch (leaver.ReasonFailed)
                {
                case "LEAVER_BUSTER":
                    throw new Exception("Leaver Buster");

                //TODO Leaverbuster
                case "QUEUE_DODGER":
                    throw new Exception("Queue Dodger");

                //TODO Queue delay event
                default:
                    throw new Exception(leaver.ReasonFailed);
                }
            }
            else if (searching.JoinedQueues != null && searching.JoinedQueues.Count > 0)
            {
                if (searching.JoinedQueues.Count != 1)
                {
                    Session.Log("Received incorrect number of joined queues");
                }
                return(new Queue(searching.JoinedQueues.FirstOrDefault()));
            }
            else
            {
                throw new Exception("Unknown exception");
            }
        }
Example #3
0
 protected virtual void OnQueueEntered(SearchingForMatchNotification searching)
 {
     try {
         queue = Queue.Create(searching);
         queue.QueueCancelled += (s, e) => OnQueueLeft();
         QueueEntered?.Invoke(this, new QueueEventArgs(queue));
     } catch (Exception x) {
         //TODO Queue Dodge and the like
         Session.ThrowException(x, "Trying to enter queue");
         Dispose();
     }
 }
        private void EnteredQueue(SearchingForMatchNotification result)
        {
            if (result.PlayerJoinFailures != null)
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    Button item = LastSender;
                    var config  = (GameQueueConfig)item.Tag;
                    Queues.Remove(config.Id);
                    var message = new MessageOverlay();
                    message.MessageTitle.Content = "Failed to join queue";
                    message.MessageTextBox.Text  = result.PlayerJoinFailures[0].ReasonFailed;
                    if (result.PlayerJoinFailures[0].ReasonFailed == "QUEUE_DODGER")
                    {
                        message.MessageTextBox.Text = "Unable to join the queue due to you recently dodging a game." +
                                                      Environment.NewLine;
                        TimeSpan time = TimeSpan.FromMilliseconds(result.PlayerJoinFailures[0].PenaltyRemainingTime);
                        message.MessageTextBox.Text = "You have " +
                                                      string.Format("{0:D2}m:{1:D2}s", time.Minutes, time.Seconds) +
                                                      " remaining until you may queue again";
                    }
                    else if (result.PlayerJoinFailures[0].ReasonFailed == "RANKED_MIN_LEVEL")
                    {
                        message.MessageTextBox.Text = "You do not meet the requirements for this queue." +
                                                      Environment.NewLine;
                    }
                    else if (result.PlayerJoinFailures[0].ReasonFailed == "QUEUE_PARTICIPANTS")
                    {
                        message.MessageTextBox.Text =
                            "This queue is in dev. Please use this queue on the real league of legends client." +
                            Environment.NewLine;
                    }
                    Client.OverlayContainer.Content    = message.Content;
                    Client.OverlayContainer.Visibility = Visibility.Visible;
                }));
                return;
            }

            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                Button item    = LastSender;
                var fakeButton = new Button(); //We require a unique button to add to the dictionary
                fakeButton.Tag = item;
                item.Content   = "00:00";
                ButtonTimers.Add(fakeButton, 0);
            }));
            InQueue               = true;
            Client.GameStatus     = "inQueue";
            Client.timeStampSince =
                (DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime()).TotalMilliseconds;
            Client.SetChatHover();
            Client.PVPNet.OnMessageReceived += GotQueuePop;
        }
        private void EnteredQueue(SearchingForMatchNotification result)
        {
            if (result.PlayerJoinFailures != null)
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    Client.HasPopped = false;
                    var messageOver  = new MessageOverlay();
                    messageOver.MessageTitle.Content = "Could not join the queue";
                    foreach (QueueDodger x in result.PlayerJoinFailures)
                    {
                        TimeSpan time = TimeSpan.FromMilliseconds(x.PenaltyRemainingTime);
                        switch (x.ReasonFailed)
                        {
                        case "LEAVER_BUSTER_TAINTED_WARNING":
                            messageOver.MessageTextBox.Text += " - You have left a game in progress. Please use the official client to remove the warning for now.";
                            //Need to implement their new warning for leaving.
                            break;

                        case "QUEUE_DODGER":
                            messageOver.MessageTextBox.Text += " - " + x.Summoner.Name + " is unable to join the queue as they recently dodged a game." + Environment.NewLine;
                            messageOver.MessageTextBox.Text += " - You have " + string.Format("{0:D2}m:{1:D2}s", time.Minutes, time.Seconds) + " remaining until you may queue again";
                            break;

                        case "QUEUE_RESTRICTED":
                            messageOver.MessageTextBox.Text += " - You are too far apart in ranked to queue together.";
                            messageOver.MessageTextBox.Text += " - For instance, Silvers can only queue with Bronze, Silver, or Gold players.";
                            break;

                        case "RANKED_RESTRICTED":
                            messageOver.MessageTextBox.Text += " - You are not currently able to queue for ranked for: " + x.PenaltyRemainingTime + " games. If this is inaccurate please report it as an issue on the github page. Thanks!";
                            break;

                        default:
                            messageOver.MessageTextBox.Text += "Please submit: - " + x.ReasonFailed + " - as an Issue on github explaining what it meant. Thanks!";
                            break;
                        }
                    }
                    Client.OverlayContainer.Content    = messageOver.Content;
                    Client.OverlayContainer.Visibility = Visibility.Visible;
                }));
                return;
            }
            Client.PVPNet.OnMessageReceived += GotQueuePop;
            setStartButtonText("Joining Queue");
            startTime             = 1;
            inQueue               = true;
            Client.GameStatus     = "inQueue";
            Client.timeStampSince = (DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime()).TotalMilliseconds;
            Client.SetChatHover();
        }
Example #6
0
        private bool OnSearchingForMatch(SearchingForMatchNotification search)
        {
            if (search.JoinedQueues.Count > 0)
            {
                queueStart = DateTime.Now;
                state      = new Model.MatchmakingState {
                    Estimate = search.JoinedQueues.First().WaitTime,
                    Actual   = state?.Actual ?? 0,
                };
                OnStateChanged();
            }

            return(true);
        }
Example #7
0
        public async Task <SearchingForMatchNotification> AttachToQueue(MatchMakerParams matchMakerParams)
        {
            int Id = Invoke("matchmakerService", "attachToQueue", new object[] { matchMakerParams.GetBaseTypedObject() });

            while (!results.ContainsKey(Id))
            {
                await Task.Delay(10);
            }
            TypedObject messageBody = results[Id].GetTO("data").GetTO("body");
            SearchingForMatchNotification result = new SearchingForMatchNotification(messageBody);

            results.Remove(Id);
            return(result);
        }
Example #8
0
        public async Task <SearchingForMatchNotification> AttachToLowPriorityQueue(MatchMakerParams matchMakerParams, string accessToken)
        {
            TypedObject to = new TypedObject(null);

            to.Add("LEAVER_BUSTER_ACCESS_TOKEN", accessToken);
            int Id = Invoke("matchmakerService", "attachToQueue",
                            new object[] { matchMakerParams.GetBaseTypedObject(), to });

            while (!results.ContainsKey(Id))
            {
                await Task.Delay(10);
            }
            TypedObject messageBody = results[Id].GetTO("data").GetTO("body");
            SearchingForMatchNotification result = new SearchingForMatchNotification(messageBody);

            results.Remove(Id);
            return(result);
        }
Example #9
0
 private void EnteredQueue(SearchingForMatchNotification result)
 {
     if (result.PlayerJoinFailures != null)
     {
         Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
         {
             MessageOverlay messageOver       = new MessageOverlay();
             messageOver.MessageTitle.Content = "Could not join the queue";
             foreach (QueueDodger x in result.PlayerJoinFailures)
             {
                 messageOver.MessageTextBox.Text += x.Summoner.Name + " is unable to join the queue as they recently dodged a game." + Environment.NewLine;
                 TimeSpan time = TimeSpan.FromMilliseconds(x.PenaltyRemainingTime);
                 messageOver.MessageTextBox.Text += "You have " + string.Format("{0:D2}m:{1:D2}s", time.Minutes, time.Seconds) + " remaining until you may queue again";
             }
             messageOver.Content    = messageOver.Content;
             messageOver.Visibility = Visibility.Visible;
         }));
         return;
     }
 }
Example #10
0
        public RemotingMessageReceivedEventArgs HandleMessage(object sender, RemotingMessageReceivedEventArgs e)
        {
            SearchingForMatchNotification notification = new SearchingForMatchNotification
            {
                PlayerJoinFailures = new ArrayCollection
                {
                    new QueueDisabled
                    {
                        Message = "QUEUE_DISABLED",
                        QueueId = 1
                    }
                },
                GhostGameSummoners = new ArrayCollection(),
                JoinedQueues       = new ArrayCollection()
            };

            e.ReturnRequired = true;
            e.Data           = notification;

            return(e);
        }
Example #11
0
        public async Task <SearchingForMatchNotification> AttachToLowPriorityQueue(MatchMakerParams matchMakerParams, string accessToken)
        {
            TypedObject typedObject = new TypedObject(null);

            typedObject.Add("LEAVER_BUSTER_ACCESS_TOKEN", accessToken);
            int key = this.Invoke("matchmakerService", "attachToQueue", new object[]
            {
                matchMakerParams.GetBaseTypedObject(),
                typedObject
            });

            while (!this.results.ContainsKey(key))
            {
                await Task.Delay(10);
            }
            TypedObject tO = this.results[key].GetTO("data").GetTO("body");
            SearchingForMatchNotification result = new SearchingForMatchNotification(tO);

            this.results.Remove(key);
            return(result);
        }
Example #12
0
        internal static void OnMessageReceived(object sender, MessageReceivedEventArgs message)
        {
            MainWin.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async() =>
            {
                if (message.Body is StoreAccountBalanceNotification)
                {
                    StoreAccountBalanceNotification newBalance = (StoreAccountBalanceNotification)message.Body;
                    InfoLabel.Content     = "IP: " + newBalance.Ip + " ∙ RP: " + newBalance.Rp;
                    LoginPacket.IpBalance = newBalance.Ip;
                    LoginPacket.RpBalance = newBalance.Rp;
                }
                else if (message.Body is GameNotification)
                {
                    GameNotification notification    = (GameNotification)message.Body;
                    MessageOverlay messageOver       = new MessageOverlay();
                    messageOver.MessageTitle.Content = notification.Type;
                    switch (notification.Type)
                    {
                    case "PLAYER_BANNED_FROM_GAME":
                        messageOver.MessageTitle.Content = "Banned from custom game";
                        messageOver.MessageTextBox.Text  = "You have been banned from this custom game!";
                        break;

                    case "PLAYER_QUIT":
                        string[] Name = await RiotCalls.GetSummonerNames(new double[1] {
                            Convert.ToDouble((string)notification.MessageArgument)
                        });
                        messageOver.MessageTitle.Content = "Player has left the queue";
                        messageOver.MessageTextBox.Text  = Name[0] + " has left the queue";
                        break;

                    default:
                        messageOver.MessageTextBox.Text  = notification.MessageCode + Environment.NewLine;
                        messageOver.MessageTextBox.Text += Convert.ToString(notification.MessageArgument);
                        break;
                    }
                    OverlayContainer.Content    = messageOver.Content;
                    OverlayContainer.Visibility = Visibility.Visible;
                    QuitCurrentGame();
                }
                else if (message.Body is EndOfGameStats)
                {
                    EndOfGameStats stats        = message.Body as EndOfGameStats;
                    EndOfGamePage EndOfGame     = new EndOfGamePage(stats);
                    OverlayContainer.Visibility = Visibility.Visible;
                    OverlayContainer.Content    = EndOfGame.Content;
                }
                else if (message.Body is StoreFulfillmentNotification)
                {
                    PlayerChampions = await RiotCalls.GetAvailableChampions();
                }
                else if (message.Body is GameDTO)
                {
                    GameDTO Queue = message.Body as GameDTO;
                    if (!IsInGame && Queue.GameState != "TERMINATED" && Queue.GameState != "TERMINATED_IN_ERROR")
                    {
                        MainWin.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                        {
                            Client.OverlayContainer.Content    = new QueuePopOverlay(Queue).Content;
                            Client.OverlayContainer.Visibility = Visibility.Visible;
                        }));
                    }
                }
                else if (message.Body is SearchingForMatchNotification)
                {
                    SearchingForMatchNotification Notification = message.Body as SearchingForMatchNotification;
                    if (Notification.PlayerJoinFailures != null && Notification.PlayerJoinFailures.Count > 0)
                    {
                        MessageOverlay messageOver       = new MessageOverlay();
                        messageOver.MessageTitle.Content = "Could not join the queue";
                        foreach (QueueDodger x in Notification.PlayerJoinFailures)
                        {
                            messageOver.MessageTextBox.Text += x.Summoner.Name + " is unable to join the queue as they recently dodged a game." + Environment.NewLine;
                            TimeSpan time = TimeSpan.FromMilliseconds(x.PenaltyRemainingTime);
                            messageOver.MessageTextBox.Text += "You have " + string.Format("{0:D2}m:{1:D2}s", time.Minutes, time.Seconds) + " remaining until you may queue again";
                        }
                        OverlayContainer.Content    = messageOver.Content;
                        OverlayContainer.Visibility = Visibility.Visible;
                    }
                }
            }));
        }
Example #13
0
        /// 37.)
        public void AttachToQueue(MatchMakerParams matchMakerParams, SearchingForMatchNotification.Callback callback)
        {
            SearchingForMatchNotification cb = new SearchingForMatchNotification(callback);

            InvokeWithCallback("matchmakerService", "attachToQueue", new object[] { matchMakerParams.GetBaseTypedObject() }, cb);
        }
Example #14
0
        private async void joinQueue()
        {
            MatchMakerParams matchParams = new MatchMakerParams();

            if (queue == QueueTypes.INTRO_BOT)
            {
                matchParams.BotDifficulty = "INTRO";
            }
            else if (queue == QueueTypes.BEGINNER_BOT)
            {
                matchParams.BotDifficulty = "EASY";
            }
            else if (queue == QueueTypes.MEDIUM_BOT)
            {
                matchParams.BotDifficulty = "MEDIUM";
            }
            mustQueue = queue;
            if (currentLevel < 3 && queue == QueueTypes.NORMAL_5x5)
            {
                Logger.Push("Need to be Level 3 before NORMAL_5x5 queue, joining Co-Op vs AI (Beginner) queue until 3.", "info", username);
                mustQueue = QueueTypes.BEGINNER_BOT;
            }
            if (currentLevel < 6 && queue == QueueTypes.ARAM)
            {
                Logger.Push("Need to be Level 6 before ARAM queue, joining Co-Op vs AI (Beginner) queue until 6.", "info", username);
                mustQueue = QueueTypes.BEGINNER_BOT;
            }
            if (currentLevel < 7 && queue == QueueTypes.NORMAL_3x3)
            {
                Logger.Push("Need to be Level 7 before NORMAL_3x3 queue, joining Co-Op vs AI (Beginner) queue until 6.", "info", username);
                mustQueue = QueueTypes.BEGINNER_BOT;
            }

            matchParams.QueueIds = new Int32[1] {
                (int)mustQueue
            };
            lastMatchParams = matchParams;
            SearchingForMatchNotification message = await connection.AttachToQueue(matchParams);

            if (message.PlayerJoinFailures == null)
            {
                Logger.Push("In Queue: " + mustQueue.ToString(), "info", username);
                smurf.updateTimer(60 * 5);
            }
            else
            {
                dynamic failure        = message.PlayerJoinFailures[0];
                bool    taintedWarning = false;
                foreach (QueueDodger current in message.PlayerJoinFailures)
                {
                    if (current.ReasonFailed == "LEAVER_BUSTED")
                    {
                        m_accessToken = current.AccessToken;
                        if (current.LeaverPenaltyMillisRemaining > this.m_leaverBustedPenalty)
                        {
                            this.m_leaverBustedPenalty = current.LeaverPenaltyMillisRemaining;
                        }
                    }

                    if (current.ReasonFailed == "QUEUE_DODGER")
                    {
                        m_accessToken = current.AccessToken;
                        if (current.DodgePenaltyRemainingTime > this.m_leaverBustedPenalty)
                        {
                            this.m_leaverBustedPenalty = current.DodgePenaltyRemainingTime;
                        }
                    }

                    if (current.ReasonFailed == "LEAVER_BUSTER_TAINTED_WARNING")
                    {
                        Logger.Push("Login to your account using your real client and accept the popup you will see", "danger", username);
                        taintedWarning = true;
                        connection.Disconnect();
                        break;
                    }
                }
                if (!string.IsNullOrEmpty(this.m_accessToken))
                {
                    double minutes = ((float)(this.m_leaverBustedPenalty / 0x3e8)) / 60f;
                    smurf.updateTimer(Convert.ToInt32(Math.Round(minutes) + 10) * 60);
                    Logger.Push("Waiting out leaver buster: " + minutes + " minutes!", "warning", username);
                    Thread.Sleep(TimeSpan.FromMilliseconds((double)this.m_leaverBustedPenalty));
                    if (!m_disposed)
                    {
                        try
                        {
                            message = await connection.AttachToLowPriorityQueue(matchParams, this.m_accessToken);

                            if (message.PlayerJoinFailures == null)
                            {
                                Logger.Push("Succesfully joined lower priority queue!", "info", username);
                            }
                            else
                            {
                                Logger.Push("There was an error in joining lower priority queue.Disconnecting...", "danger", username);
                                smurf.restart();
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                }
                else
                {
                    if (!taintedWarning)
                    {
                        double minutes = ((float)(this.m_leaverBustedPenalty / 0x3e8)) / 60f;
                        if (minutes <= 0)
                        {
                            try
                            {
                                exeProcess.Exited -= exeProcess_Exited;
                                exeProcess.Kill();
                            }
                            catch (Exception ex)
                            {
                            }
                            if (lastStarter != null)
                            {
                                startProcessor(lastStarter);
                            }
                        }
                        else
                        {
                            Logger.Push("Waiting out queue buster: " + minutes + " minutes!", "warning", username);
                            smurf.updateTimer(Convert.ToInt32(Math.Round((double)m_leaverBustedPenalty) + 2) * 60);
                            Thread.Sleep(TimeSpan.FromMilliseconds((double)this.m_leaverBustedPenalty));
                            if (!m_disposed)
                            {
                                try
                                {
                                    this.joinQueue();
                                }
                                catch (Exception ex)
                                {
                                }
                            }
                        }
                    }
                }
            }
        }
Example #15
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":
                    firstTimeInCustom   = true;
                    firstTimeInQueuePop = true;
                    if (firstTimeInLobby)
                    {
                        firstTimeInLobby = false;
                        updateStatus("In Champion Select", Accountname);
                        await connection.SetClientReceivedGameMessage(game.Id, "CHAMP_SELECT_CLIENT");

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

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

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

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

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

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

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

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

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

                case "JOINING_CHAMP_SELECT":
                    if (firstTimeInQueuePop)
                    {
                        updateStatus("Queue popped", Accountname);
                        if (game.StatusOfParticipants.Contains("1"))
                        {
                            updateStatus("Accepted Queue", Accountname);
                            firstTimeInQueuePop = false;
                            firstTimeInLobby    = true;
                            await connection.AcceptPoppedGame(true);
                        }
                    }
                    break;
                }
            }
            else if (message is PlayerCredentialsDto)
            {
                PlayerCredentialsDto dto = message as PlayerCredentialsDto;
                if (!HasLaunchedGame)
                {
                    HasLaunchedGame = true;
                    new Thread((ThreadStart)(() =>
                    {
                        LaunchGame(dto);
                        Thread.Sleep(3000);
                    })).Start();
                }
            }
            else if (!(message is GameNotification) && !(message is SearchingForMatchNotification))
            {
                if (message is EndOfGameStats)
                {
                    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)
                    {
                        updateStatus("In Queue: " + queueType.ToString(), Accountname);
                    }
                    else
                    {
                        updateStatus("Couldn't enter Queue! Please contact us @ volibot.com", Accountname);
                    }
                }
                else
                {
                    if (message.ToString().Contains("EndOfGameStats"))
                    {
                        EndOfGameStats eog = new EndOfGameStats();
                        connection_OnMessageReceived(sender, eog);
                        exeProcess.Kill();
                        loginPacket = await this.connection.GetLoginDataPacketForUser();

                        archiveSumLevel = sumLevel;
                        sumLevel        = loginPacket.AllSummonerData.SummonerLevel.Level;
                        if (sumLevel != archiveSumLevel)
                        {
                            levelUp();
                        }
                    }
                }
            }
        }
Example #16
0
        private async void AttachToQueue()
        {
            MatchMakerParams matchMakerParams = new MatchMakerParams();

            if (this.queueType == QueueTypes.INTRO_BOT)
            {
                matchMakerParams.BotDifficulty = "INTRO";
            }
            else if (this.queueType == QueueTypes.BEGINNER_BOT)
            {
                matchMakerParams.BotDifficulty = "EASY";
            }
            else if (this.queueType == QueueTypes.MEDIUM_BOT)
            {
                matchMakerParams.BotDifficulty = "MEDIUM";
            }
            if (this.sumLevel == 3.0 && this.actualQueueType == QueueTypes.NORMAL_5x5)
            {
                this.queueType = this.actualQueueType;
            }
            else if (this.sumLevel == 6.0 && this.actualQueueType == QueueTypes.ARAM)
            {
                this.queueType = this.actualQueueType;
            }
            else if (this.sumLevel == 7.0 && this.actualQueueType == QueueTypes.NORMAL_3x3)
            {
                this.queueType = this.actualQueueType;
            }
            matchMakerParams.QueueIds = new int[]
            {
                (int)this.queueType
            };
            SearchingForMatchNotification searchingForMatchNotification = await this.connection.AttachToQueue(matchMakerParams);

            if (searchingForMatchNotification.PlayerJoinFailures == null)
            {
                this.updateStatus("In Queue: " + this.queueType.ToString(), this.Accountname);
            }
            else
            {
                foreach (QueueDodger current in searchingForMatchNotification.PlayerJoinFailures)
                {
                    if (current.ReasonFailed == "LEAVER_BUSTED")
                    {
                        this.m_accessToken = current.AccessToken;
                        if (current.LeaverPenaltyMillisRemaining > this.m_leaverBustedPenalty)
                        {
                            this.m_leaverBustedPenalty = current.LeaverPenaltyMillisRemaining;
                        }
                    }
                    else if (current.ReasonFailed == "LEAVER_BUSTER_TAINTED_WARNING")
                    {
                        await this.connection.ackLeaverBusterWarning();

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

                        this.connection_OnMessageReceived(null, new EndOfGameStats());
                    }
                }
                if (!string.IsNullOrEmpty(this.m_accessToken))
                {
                    this.updateStatus("Waiting out leaver buster: " + (float)(this.m_leaverBustedPenalty / 1000) / 60f + " minutes!", this.Accountname);
                    Thread.Sleep(TimeSpan.FromMilliseconds((double)this.m_leaverBustedPenalty));
                    searchingForMatchNotification = await this.connection.AttachToLowPriorityQueue(matchMakerParams, this.m_accessToken);

                    if (searchingForMatchNotification.PlayerJoinFailures == null)
                    {
                        this.updateStatus("Succesfully joined lower priority queue!", this.Accountname);
                    }
                    else
                    {
                        this.updateStatus("There was an error in joining lower priority queue.\nDisconnecting.", this.Accountname);
                        this.connection.Disconnect();
                        this.parent.lognNewAccount();
                    }
                }
            }
        }
Example #17
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);
                    }
                }
            }
        }
Example #18
0
        private async void handleLobbyStatus(object messageIn)
        {
            LobbyStatus lobby        = messageIn as LobbyStatus;
            int         totalMembers = (lobby.Invitees.FindAll(member => member.InviteeState == "ACCEPTED").Count + 1);

            Logger.Push("Lobby just updated, accepted members:" + totalMembers, "info", username);
            if (totalMembers == smurf.totalGroupLength && isHost)
            {
                Thread.Sleep(2000);
                Logger.Push("We have enough members to join queue, joining queue", "info", username);
                lobbyReady = false;
                lobbyInviteQuery.Clear();

                //Starting
                MatchMakerParams matchParams = new MatchMakerParams();
                if (queue == QueueTypes.INTRO_BOT)
                {
                    matchParams.BotDifficulty = "INTRO";
                }
                else if (queue == QueueTypes.BEGINNER_BOT)
                {
                    matchParams.BotDifficulty = "EASY";
                }
                else if (queue == QueueTypes.MEDIUM_BOT)
                {
                    matchParams.BotDifficulty = "MEDIUM";
                }
                matchParams.QueueIds = new Int32[1] {
                    (int)queue
                };
                matchParams.InvitationId = lobby.InvitationID;
                matchParams.Team         = lobby.Invitees.Select(member => Convert.ToInt32(member.SummonerId)).ToList();
                SearchingForMatchNotification message = await connection.attachTeamToQueue(matchParams);

                if (message.PlayerJoinFailures == null)
                {
                    Logger.Push("Group joined to queue", "info", username);
                }
                else
                {
                    dynamic failure = message.PlayerJoinFailures[0];
                    foreach (QueueDodger current in message.PlayerJoinFailures)
                    {
                        if (current.ReasonFailed == "LEAVER_BUSTED")
                        {
                            m_accessToken = current.AccessToken;
                            if (current.LeaverPenaltyMillisRemaining > this.m_leaverBustedPenalty)
                            {
                                this.m_leaverBustedPenalty = current.LeaverPenaltyMillisRemaining;
                            }
                        }

                        if (current.ReasonFailed == "QUEUE_DODGER")
                        {
                            m_accessToken = current.AccessToken;
                            if (current.DodgePenaltyRemainingTime > this.m_leaverBustedPenalty)
                            {
                                this.m_leaverBustedPenalty = current.DodgePenaltyRemainingTime;
                            }
                        }

                        if (current.ReasonFailed == "LEAVER_BUSTER_TAINTED_WARNING")
                        {
                            Logger.Push("Login to your account using your real client and accept the popup you will see", "danger", username);
                            connection.Disconnect();
                            break;
                        }

                        if (current.ReasonFailed == "QUEUE_RESTRICTED")
                        {
                            Logger.Push("You are too far apart in ranked to queue together.", "danger", username);
                            connection.Disconnect();
                        }
                        if (current.ReasonFailed == "QUEUE_PARTICIPANTS")
                        {
                            Logger.Push("Not enough players for this queue type.", "danger", username);
                            connection.Disconnect();
                        }
                    }
                    if (m_leaverBustedPenalty > 0)
                    {
                        double minutes = ((float)(this.m_leaverBustedPenalty / 0x3e8)) / 60f;
                        smurf.updateTimer(Convert.ToInt32(Math.Round(minutes) + 10) * 60);
                        Logger.Push("Waiting out leaver buster: " + minutes + " minutes!", "warning", username);
                        Thread.Sleep(TimeSpan.FromMilliseconds((double)this.m_leaverBustedPenalty));

                        if (!m_disposed)
                        {
                            try
                            {
                                message = await connection.attachTeamToQueue(matchParams, this.m_accessToken);

                                if (message.PlayerJoinFailures == null)
                                {
                                    Logger.Push("Succesfully joined lower priority queue!", "info", username);
                                    smurf.updateTimer(150);
                                }
                                else
                                {
                                    Logger.Push("There was an error in joining lower priority queue.Disconnecting...", "danger", username);
                                    smurf.restartHard();
                                }
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                    }
                }
            }
        }
Example #19
0
        private void EnteredQueue(SearchingForMatchNotification result)
        {
            if (result.PlayerJoinFailures != null)
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async() =>
                {
                    Client.HasPopped = false;
                    var messageOver  = new MessageOverlay();
                    messageOver.MessageTitle.Content = "Could not join the queue";
                    foreach (var item in result.PlayerJoinFailures)
                    {
                        var x         = (QueueDodger)item;
                        TimeSpan time = TimeSpan.FromMilliseconds(x.PenaltyRemainingTime);
                        switch (x.ReasonFailed)
                        {
                        case "LEAVER_BUSTER_TAINTED_WARNING":
                            messageOver.MessageTextBox.Text += " - You have left a game in progress. Please use the official client to remove the warning for now.";
                            //Need to implement their new warning for leaving.
                            break;

                        case "QUEUE_DODGER":
                            messageOver.MessageTextBox.Text += " - " + x.Summoner.Name + " is unable to join the queue as they recently dodged a game." + Environment.NewLine;
                            messageOver.MessageTextBox.Text += " - You have " + string.Format("{0:D2}m:{1:D2}s", time.Minutes, time.Seconds) + " remaining until you may queue again";
                            break;

                        case "QUEUE_RESTRICTED":
                            messageOver.MessageTextBox.Text += " - You are too far apart in ranked to queue together.";
                            messageOver.MessageTextBox.Text += " - For instance, Silvers can only queue with Bronze, Silver, or Gold players.";
                            break;

                        case "RANKED_RESTRICTED":
                            messageOver.MessageTextBox.Text += " - You are not currently able to queue for ranked for: " + x.PenaltyRemainingTime + " games. If this is inaccurate please report it as an issue on the github page. Thanks!";
                            break;

                        case "RANKED_MIN_LEVEL":
                            messageOver.MessageTextBox.Text += " - Level 30 is required to played ranked games.";
                            break;

                        case "QUEUE_PARTICIPANTS":
                            messageOver.MessageTextBox.Text += " - Not enough players for this queue type.";
                            break;

                        case "LEAVER_BUSTED":
                            var xm = (BustedLeaver)x;
                            Client.Log("LeaverBuster, Access token is: " + xm.AccessToken);
                            var message = new MessageOverlay
                            {
                                MessageTitle   = { Content = "LeaverBuster" },
                                MessageTextBox = { Text = "" }
                            };
                            Timer t = new Timer {
                                Interval = 1000
                            };
                            var timeleft = xm.LeaverPenaltyMilisRemaining;
                            t.Elapsed   += (messafge, mx) =>
                            {
                                timeleft  = timeleft - 1000;
                                var timex = TimeSpan.FromMilliseconds(timeleft);
                                Dispatcher.BeginInvoke(
                                    DispatcherPriority.Input, new ThreadStart(() =>
                                {
                                    //Can not bypass this sadly, it just relaunches
                                    message.MessageTextBox.Text =
                                        @"Abandoning a match or being AFK results in a negative experience for your teammates, and is a punishable offense in League of Legends.
You've been placed in a lower priority queue" + Environment.NewLine;
                                    message.MessageTextBox.Text += "You have " +
                                                                   string.Format(
                                        "{0:D2}m:{1:D2}s", timex.Minutes, timex.Seconds) +
                                                                   " remaining until you may queue again" + Environment.NewLine;

                                    message.MessageTextBox.Text += "You can close this window and you will still be in queue";

                                    Client.OverlayContainer.Content = message.Content;
                                    if (timeleft < 0)
                                    {
                                        t.Stop();
                                        Client.OverlayContainer.Visibility = Visibility.Hidden;
                                    }
                                }));
                            };
                            t.Start();
                            Client.OverlayContainer.Content    = message.Content;
                            Client.OverlayContainer.Visibility = Visibility.Visible;
                            if (CurrentLobby.Owner.SummonerId.MathRound() !=
                                Client.LoginPacket.AllSummonerData.Summoner.SumId.MathRound())
                            {
                                return;
                            }
                            EnteredQueue(await RiotCalls.AttachTeamToQueue(parameters, new AsObject {
                                { "LEAVER_BUSTER_ACCESS_TOKEN", xm.AccessToken }
                            }));
                            break;

                        case "RANKED_NUM_CHAMPS":
                            messageOver.MessageTextBox.Text += " - You require at least 16 owned champions to play a Normal Draft / Ranked game.";
                            break;

                        default:
                            messageOver.MessageTextBox.Text += "Please submit: - " + x.ReasonFailed + " - as an Issue on github explaining what it meant. Thanks!";
                            break;
                        }
                    }
                    Client.OverlayContainer.Content    = messageOver.Content;
                    Client.OverlayContainer.Visibility = Visibility.Visible;
                }));
                return;
            }
            Client.RiotConnection.MessageReceived += GotQueuePop;
            setStartButtonText("Joining Queue");
            startTime         = 1;
            inQueue           = true;
            Client.GameStatus = "inQueue";
            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                if (Client.inQueueTimer.Visibility == Visibility.Hidden)
                {
                    Client.inQueueTimer.Visibility = Visibility.Visible;
                }
                TeamListView.Opacity = 0.3D;
            }));
            Client.timeStampSince = (DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime()).TotalMilliseconds;
            Client.SetChatHover();
        }
Example #20
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();
                    }
                }
            }
        }
Example #21
0
        private async void EnterQueue()
        {
            MatchMakerParams matchParams = new MatchMakerParams();

            //Set BotParams
            if (queueType == QueueTypes.BOT_INTO)
            {
                matchParams.BotDifficulty = "INTRO";
            }
            else if (queueType == QueueTypes.BOT_BEGINNER)
            {
                matchParams.BotDifficulty = "EASY";
            }
            else if (queueType == QueueTypes.BOT_MEDIUM)
            {
                matchParams.BotDifficulty = "MEDIUM";
            }
            else if (queueType == QueueTypes.BOT_3x3) //TT Map
            {
                matchParams.BotDifficulty = "EASY";
            }

            //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;
            }
            else if (sumLevel == 10 && actualQueueType == QueueTypes.TT_HEXAKILL)
            {
                queueType = actualQueueType;
            }

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

            if (m.PlayerJoinFailures == null)
            {
                Tools.ConsoleMessage("In Queue: " + queueType.ToString() + " as " + loginPacket.AllSummonerData.Summoner.Name + ".", ConsoleColor.Cyan);
            }
            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")
                    {
                        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
                {
                    Tools.ConsoleMessage("Waiting leaver buster time: " + m_leaverBustedPenalty / 1000 / (float)60 + " minutes!", ConsoleColor.White);
                    System.Threading.Thread.Sleep(TimeSpan.FromMilliseconds(m_leaverBustedPenalty));
                    m = await connection.AttachToLowPriorityQueue(matchParams, m_accessToken);

                    if (m.PlayerJoinFailures == null)
                    {
                        Tools.ConsoleMessage("Joined lower priority queue! as " + loginPacket.AllSummonerData.Summoner.Name + ".", ConsoleColor.Cyan);
                    }
                    else
                    {
                        Tools.ConsoleMessage("There was an error in joining lower priority queue.\nDisconnecting.", ConsoleColor.White);
                        connection.Disconnect();
                    }
                }
            }
        }
Example #22
0
        private void connection_OnLogin(object sender, string username, string ipAddress)
        {
            new Thread(async() =>
            {
                App.gameMask.findAndKillHflWindow(info.username, info.region.ToString());

                loginDataPacket = await connection.GetLoginDataPacketForUser();

                #region createSummoner
                if (loginDataPacket.AllSummonerData == null)
                {
                    Random random       = new Random();
                    string summonerName = info.username;
                    if (summonerName.Length > 16)
                    {
                        summonerName = summonerName.Substring(0, 12) + new Random().Next(1000, 9999).ToString();
                    }
                    await connection.CreateDefaultSummoner(summonerName);
                    updateStatus(msgStatus.INFO, "Created Summoner: " + summonerName);
                }
                #endregion

                loginDataPacket = await connection.GetLoginDataPacketForUser();

                #region registerMessages
                await connection.Subscribe("bc", loginDataPacket.AllSummonerData.Summoner.AcctId);
                await connection.Subscribe("cn", loginDataPacket.AllSummonerData.Summoner.AcctId);
                await connection.Subscribe("gn", loginDataPacket.AllSummonerData.Summoner.AcctId);
                #endregion

                #region ackDialogBusterWarning
                await connection.ackLeaverBusterWarning();
                await connection.callPersistenceMessaging(new SimpleDialogMessageResponse()
                {
                    AccountID = loginDataPacket.AllSummonerData.Summoner.SumId,
                    MsgID     = loginDataPacket.AllSummonerData.Summoner.SumId,
                    Command   = "ack"
                });
                #endregion

                #region fetchSummonerData
                info.summonerId     = loginDataPacket.AllSummonerData.Summoner.SumId;
                info.currentLevel   = loginDataPacket.AllSummonerData.SummonerLevel.Level;
                info.currentIp      = loginDataPacket.IpBalance;
                info.expToNextLevel = loginDataPacket.AllSummonerData.SummonerLevel.ExpToNextLevel;;
                info.currentXp      = loginDataPacket.AllSummonerData.SummonerLevelAndPoints.ExpPoints;
                info.currentRp      = loginDataPacket.RpBalance;
                info.summonerName   = loginDataPacket.AllSummonerData.Summoner.Name;
                myChampions         = await connection.GetAvailableChampions();
                await connection.CreatePlayer();
                sessionManager.smurfStart(info.username, info.region, info.currentXp, info.currentIp, info.currentLevel, info.expToNextLevel);
                updateStatus(msgStatus.INFO, "Logged in as " + info.summonerName + " @ level " + info.currentLevel);
                #endregion

                #region checkReconnectState
                if (loginDataPacket.ReconnectInfo != null && loginDataPacket.ReconnectInfo.Game != null)
                {
                    connection_OnMessageReceived(sender, loginDataPacket.ReconnectInfo.PlayerCredentials);
                    return;
                }
                #endregion

                #region startSoloSequence
                if (type == RotationType.SmurfDone)
                {
                    if (info.desiredLevel <= loginDataPacket.AllSummonerData.SummonerLevel.Level)
                    {
                        connection.Disconnect();
                        return;
                    }
                }

                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";
                }
                updateStatus(msgStatus.INFO, QueueType.ToString());
                if (QueueType != 0)
                {
                    matchParams.QueueIds = new int[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;
                                }
                            }
                        }

                        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(); ->Visual Timer
                            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();
                            }
                        }
                    }
                }
                #endregion
            }).Start();
        }
Example #23
0
        private void EnteredQueue(SearchingForMatchNotification result)
        {
            if (result.PlayerJoinFailures != null)
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    var leaver = result.PlayerJoinFailures[0];
                    if (leaver.ReasonFailed == "LEAVER_BUSTED")
                    {
                        var x = (BustedLeaver)leaver;
                        Client.Log("LeaverBuster, Access token is: " + x.AccessToken);
                        var message = new MessageOverlay
                        {
                            MessageTitle   = { Content = "LeaverBuster" },
                            MessageTextBox = { Text = "" }
                        };
                        Timer t = new Timer {
                            Interval = 1000
                        };
                        var timeleft = x.LeaverPenaltyMilisRemaining;
                        t.Elapsed   += (messafge, mx) =>
                        {
                            timeleft      = timeleft - 1000;
                            TimeSpan time = TimeSpan.FromMilliseconds(timeleft);
                            Dispatcher.BeginInvoke(
                                DispatcherPriority.Input, new ThreadStart(async() =>
                            {
                                //Can not bypass this sadly, it just relaunches
                                message.MessageTextBox.Text =
                                    @"Abandoning a match or being AFK results in a negative experience for your teammates, and is a punishable offense in League of Legends.
You've been placed in a lower priority queue" + Environment.NewLine;
                                message.MessageTextBox.Text += "You have " +
                                                               string.Format(
                                    "{0:D2}m:{1:D2}s", time.Minutes, time.Seconds) +
                                                               " remaining until you may queue again" + Environment.NewLine;

                                message.MessageTextBox.Text += "You can close this window and you will still be in queue";

                                Client.OverlayContainer.Content = message.Content;
                                if (timeleft < 0)
                                {
                                    t.Stop();
                                    Client.OverlayContainer.Visibility = Visibility.Hidden;
                                    var obj = new AsObject {
                                        { "LEAVER_BUSTER_ACCESS_TOKEN", x.AccessToken }
                                    };
                                    EnteredQueue(await RiotCalls.AttachToQueue(param, obj));
                                }
                            }));
                        };
                        t.Start();
                        Client.OverlayContainer.Content    = message.Content;
                        Client.OverlayContainer.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        Button item  = LastSender;
                        var settings = (QueueButtonConfig)LastSender.Tag;
                        var config   = settings.GameQueueConfig;
                        Queues.Remove(config.Id);
                        var failure = result.PlayerJoinFailures[0];
                        var message = new MessageOverlay
                        {
                            MessageTitle   = { Content = "Failed to join queue" },
                            MessageTextBox = { Text = failure.ReasonFailed }
                        };
                        switch (failure.ReasonFailed)
                        {
                        case "QUEUE_DODGER":
                            {
                                message.MessageTextBox.Text =
                                    "Unable to join the queue due to you recently dodging a game." +
                                    Environment.NewLine;
                                TimeSpan time = TimeSpan.FromMilliseconds(failure.PenaltyRemainingTime);
                                message.MessageTextBox.Text = "You have " +
                                                              string.Format(
                                    "{0:D2}m:{1:D2}s", time.Minutes, time.Seconds) +
                                                              " remaining until you may queue again";
                            }
                            break;

                        case "RANKED_MIN_LEVEL":
                            message.MessageTextBox.Text =
                                "You do not meet the requirements for this queue." + Environment.NewLine;
                            break;

                        case "QUEUE_PARTICIPANTS":
                            message.MessageTextBox.Text =
                                "This queue is in dev. Please use this queue on the real league of legends client." +
                                Environment.NewLine;
                            break;
                        }
                        Client.OverlayContainer.Content    = message.Content;
                        Client.OverlayContainer.Visibility = Visibility.Visible;
                    }
                }));
            }
            else if (result.JoinedQueues != null)
            {
                Button item = new Button();
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    item           = LastSender;
                    var fakeButton = new Button
                    {
                        Tag = item
                    };
                    item.Content = "00:00";
                }));
                if (t.Enabled)
                {
                    t.Stop();
                }
                t = new Timer {
                    Interval = 1000
                };
                t.Start();
                time       = 0;
                t.Elapsed += (gg, easy) =>
                {
                    time = time + 1000;
                    TimeSpan timespan = TimeSpan.FromMilliseconds(time);
                    Dispatcher.BeginInvoke(
                        DispatcherPriority.Input,
                        new ThreadStart(() => item.Content = string.Format("{0:D2}m:{1:D2}s", timespan.Minutes, timespan.Seconds)));
                };
                InQueue               = true;
                Client.GameStatus     = "inQueue";
                Client.timeStampSince =
                    (DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime()).TotalMilliseconds;
                Client.SetChatHover();
                Client.RiotConnection.MessageReceived += GotQueuePop;
                Client.Log("Now in Queue");
            }
        }
Example #24
0
 private async void handleSearchingForMatchNotification(SearchingForMatchNotification message)
 {
 }