コード例 #1
0
ファイル: BotThread.cs プロジェクト: Acanguven/HFL-Remastered
        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)
                            {
                            }
                        }
                    }
                }
            }
        }