Exemplo n.º 1
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");
            }
        }
Exemplo n.º 2
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();
        }