Exemple #1
0
        /// <summary>
        /// Evaluates the addition of a captain to see if it is possible to add the captain, and
        /// adds if so.
        /// </summary>
        /// <param name="c">The command argument information.</param>
        /// <returns><c>true</c> if it is possible to add the captain; otherwise <c>false</c>.</returns>
        /// <remarks>This is called in response to input received from <see cref="PickupCapCmd"/>.</remarks>
        public async Task <bool> ProcessAddCaptain(Cmd c)
        {
            if (_manager.IsQlGameInProgress)
            {
                StatusMessage = "^1[ERROR]^3 Cannot become a pickup captain because a game is in progress.";
                await SendServerTell(c, StatusMessage);

                return(false);
            }
            if (!_manager.HasCaptainSelectionStarted)
            {
                StatusMessage =
                    "^1[ERROR]^3 Cannot become a pickup captain because captain selection hasn't started yet.";
                await SendServerTell(c, StatusMessage);

                return(false);
            }
            if (!_manager.AvailablePlayers.Contains(c.FromUser))
            {
                StatusMessage =
                    string.Format(
                        "^1[ERROR]^3 You can't cap because you're not signed up. ^7{0}{1}^3 to sign up.",
                        CommandList.GameCommandPrefix, CommandList.CmdPickupAdd);
                await SendServerTell(c, StatusMessage);

                return(false);
            }
            if (RedCaptain.Equals(c.FromUser))
            {
                StatusMessage = "^1[ERROR]^3 You've already been assigned as the RED captain.";
                await SendServerTell(c, StatusMessage);

                return(false);
            }
            if (BlueCaptain.Equals(c.FromUser))
            {
                StatusMessage = "^1[ERROR]^3 You've already been assigned as the BLUE captain.";
                await SendServerTell(c, StatusMessage);

                return(false);
            }
            if (!RedCaptainExists)
            {
                await SetCaptain(c.FromUser, Team.Red, false);
            }
            else if (!BlueCaptainExists)
            {
                await SetCaptain(c.FromUser, Team.Blue, false);
            }
            return(true);
        }
Exemple #2
0
        /// <summary>
        /// Processes and evaluates the captain's player pick and performs it if's possible to do so.
        /// </summary>
        /// <param name="c">The command argument information.</param>
        /// <returns><C>true</C> if the player could be picked, otherwise <c>false</c>.</returns>
        /// <remarks>This is called in response to input received from <see cref="PickupPickCmd"/>.</remarks>
        public async Task <bool> ProcessPlayerPick(Cmd c)
        {
            if (!RedCaptain.Equals(c.FromUser) && !BlueCaptain.Equals(c.FromUser))
            {
                StatusMessage = "^1[ERROR]^3 You cannot pick because you are not a captain!";
                await SendServerTell(c, StatusMessage);

                return(false);
            }
            if ((RedCaptain.Equals(c.FromUser) && !IsRedTurnToPick) ||
                (BlueCaptain.Equals(c.FromUser) && !IsBlueTurnToPick))
            {
                StatusMessage = "^1[ERROR]^3 It is not your turn to pick!";
                await SendServerTell(c, StatusMessage);

                return(false);
            }
            if (_manager.IsQlGameInProgress)
            {
                StatusMessage = "^1[ERROR]^3 Cannot pick a player because a game is in progress.";
                await SendServerTell(c, StatusMessage);

                return(false);
            }
            if (!_manager.HasTeamSelectionStarted)
            {
                StatusMessage = "^1[ERROR]^3 Cannot pick a player because team selection hasn't started.";
                await SendServerTell(c, StatusMessage);

                return(false);
            }

            if (RedCaptain.Equals(c.FromUser))
            {
                await DoPlayerPick(c, Team.Red);
            }
            else if (BlueCaptain.Equals(c.FromUser))
            {
                await DoPlayerPick(c, Team.Blue);
            }
            return(true);
        }