Пример #1
0
        /// <summary>
        /// Performs the substituion for a regular player.
        /// </summary>
        /// <param name="outPlayer">The player to sub out.</param>
        /// <param name="team">The team to move the sub to (outPlayer's team).</param>
        /// <param name="inPlayer">The player to sub in.</param>
        public async Task DoPlayerSub(string outPlayer, Team team, string inPlayer)
        {
            // Set as successful sub so user doesn't get counted as no-show
            _sst.ServerInfo.CurrentPlayers[outPlayer].HasMadeSuccessfulSubRequest = true;
            // Sub old player out
            await _sst.QlCommands.CustCmdPutPlayerDelayed(outPlayer, Team.Spec, 2);

            // Sub new player in
            await _sst.QlCommands.CustCmdPutPlayerDelayed(inPlayer, team, 2);

            // Set player as active
            _manager.AddActivePickupPlayer(inPlayer);
            // Announce
            await
            _sst.QlCommands.QlCmdSay(string.Format(
                                         "^5[PICKUP]^7 Subbed out old {0} ^7player: {1} for new {0} ^7player: {2}",
                                         ((team == Team.Red) ? "^1RED" : "^5BLUE"), outPlayer, inPlayer), false);

            // Tell the player the rules
            await _manager.NotifyNewPlayer(inPlayer, team);

            // Remove from sub candidates
            _manager.RemoveEligibility(inPlayer);
            // Record the outgoing player's substituion for tracking/banning purposes
            _manager.Subs.Append(string.Format("{0}->{1},", inPlayer, outPlayer));
            var pickupDb = new DbPickups();

            pickupDb.IncrementUserSubsUsedCount(outPlayer);
        }
Пример #2
0
        /// <summary>
        /// Removes a user's ban and removes/resets any other extraneous ban-related database
        /// properties for the user.
        /// </summary>
        /// <param name="banInfo">The ban information.</param>
        /// <param name="updateUi">
        /// if set to <c>true</c> then update relevant datasources in the user interface.
        /// </param>
        /// <returns><c>true</c> if the ban was deleted, otherwise <c>false</c>.</returns>
        /// <remarks>
        /// This method is typically used when access to the user interface is needed and when the
        /// unban command needs to be directly sent to the game. The underlying SST database classes
        /// are not given access to the main SST class.
        /// </remarks>
        public async Task <bool> RemoveBan(BanInfo banInfo, bool updateUi = true)
        {
            if (banInfo == null)
            {
                return(false);
            }
            // If the user was banned for quitting early, then also remove the user from the early
            // quit database when we clear the expired ban
            if (banInfo.BanType == BanType.AddedByEarlyQuit)
            {
                var eQuitDb = new DbQuits();
                eQuitDb.DeleteUserFromDb(banInfo.PlayerName);

                // UI: reflect changes
                if (updateUi)
                {
                    _sst.UserInterface.RefreshCurrentQuittersDataSource();
                }
            }
            // If the user was banned for using too many substitutes in pickup games, reset the
            // sub-used count
            if (banInfo.BanType == BanType.AddedByPickupSubs)
            {
                var pickupDb = new DbPickups();
                pickupDb.ResetSubsUsedCount(banInfo.PlayerName);
            }
            // If the user was banned for too many no-shows in pickup games, reset the user's
            // no-show count
            if (banInfo.BanType == BanType.AddedByPickupNoShows)
            {
                var pickupDb = new DbPickups();
                pickupDb.ResetNoShowCount(banInfo.PlayerName);
            }
            // Remove the ban from the database. This "on-demand" method of removing the ban is
            // preferred instead of using some mechanism such as a timer that would check every X
            // time period; In other words, leave the user banned until he tries to reconnect then
            // silently remove the ban.
            // Note: expired bans are also removed at various points during the bot's existence, for example,
            // they are also removed when admins try to add, list, or check bans with the timeban
            // command or can be removed using the UI.
            _banDb.DeleteUserFromDb(banInfo.PlayerName);

            // remove from QL's external temp kickban system as well
            if (_sst.IsMonitoringServer)
            {
                await _sst.QlCommands.CmdUnban(banInfo.PlayerName);
            }

            // UI: reflect changes
            if (updateUi)
            {
                _sst.UserInterface.RefreshCurrentBansDataSource();
            }

            return(true);
        }
Пример #3
0
        /// <summary>
        /// Executes the specified command asynchronously.
        /// </summary>
        /// <param name="c">The command argument information.</param>
        /// <returns><c>true</c> if the command was successfully executed, otherwise <c>false</c>.</returns>
        public async Task <bool> ExecAsync(Cmd c)
        {
            var pickupDb      = new DbPickups();
            var topTenPlayers = pickupDb.GetTopTenUsers();

            StatusMessage = string.Format("^5[PICKUP]^7 {0}", string.IsNullOrEmpty(topTenPlayers)
                ? "Top 10 pickup game players are unavailable."
                : string.Format("Top 10 by pickup games played: ^5{0}", topTenPlayers));

            await SendServerSay(c, StatusMessage);

            return(true);
        }
Пример #4
0
        /// <summary>
        /// Executes the specified command asynchronously.
        /// </summary>
        /// <param name="c">The command argument information.</param>
        /// <returns><c>true</c> if the command was successfully executed, otherwise <c>false</c>.</returns>
        public async Task <bool> ExecAsync(Cmd c)
        {
            var pickupDb = new DbPickups();
            var lastInfo = pickupDb.GetLastPickupInfo();

            StatusMessage = string.Format("^5[PICKUP]^7 {0}", (lastInfo == null)
               ? "Info for last pickup game is unavailable."
               : string.Format("last pickup game ^2{0} - ^1Red: {1} (C: {2}), ^5Blue: {3} (C: {4}), ^3Subs: {5}, ^6No-Shows: {6}",
                               lastInfo.StartDate.ToString("G", DateTimeFormatInfo.InvariantInfo), lastInfo.RedTeam, lastInfo.RedCaptain,
                               lastInfo.BlueTeam, lastInfo.BlueCaptain, lastInfo.Subs, lastInfo.NoShows));

            await SendServerSay(c, StatusMessage);

            return(true);
        }
Пример #5
0
        /// <summary>
        /// Performs the captain's player pick.
        /// </summary>
        /// <param name="c">The command argument information.</param>
        /// <param name="team">The team on which the player should be placed.</param>
        /// <returns></returns>
        private async Task DoPlayerPick(Cmd c, Team team)
        {
            if (!_manager.AvailablePlayers.Contains(Helpers.GetArgVal(c, 1)))
            {
                StatusMessage = string.Format("^1[ERROR]^3 {0} is not an eligible player!",
                                              Helpers.GetArgVal(c, 1));
                await SendServerTell(c, StatusMessage);

                await _manager.DisplayAvailablePlayers();
                await ShowWhosePick(team);

                return;
            }
            await _sst.QlCommands.QlCmdSay(string.Format("^5[PICKUP] {0} ^7({1}{2}^7) picked {1}{3}",
                                                         ((team == Team.Red) ? "^1RED" : "^5BLUE"), ((team == Team.Red) ? "^1" : "^5"),
                                                         ((team == Team.Red) ? RedCaptain : BlueCaptain), Helpers.GetArgVal(c, 1)), false);

            if (team == Team.Red)
            {
                _manager.RemoveEligibility(Helpers.GetArgVal(c, 1));
                await _sst.QlCommands.CustCmdPutPlayer(Helpers.GetArgVal(c, 1), Team.Red);

                _manager.AddActivePickupPlayer(Helpers.GetArgVal(c, 1));
                await SetPickingTeam(Team.Blue);

                Log.Write(string.Format("RED captain picked player {0}",
                                        Helpers.GetArgVal(c, 1)), _logClassType, _logPrefix);
            }
            else if (team == Team.Blue)
            {
                _manager.RemoveEligibility(Helpers.GetArgVal(c, 1));
                await _sst.QlCommands.CustCmdPutPlayer(Helpers.GetArgVal(c, 1), Team.Blue);

                _manager.AddActivePickupPlayer(Helpers.GetArgVal(c, 1));
                await SetPickingTeam(Team.Red);

                Log.Write(string.Format("BLUE captain picked player {0}",
                                        Helpers.GetArgVal(c, 1)), _logClassType, _logPrefix);
            }

            // Notify player
            await _manager.NotifyNewPlayer(Helpers.GetArgVal(c, 1), team);

            // Teams are full, we are ready to start
            if (_manager.AreTeamsFull)
            {
                //At this point, add the game to the pickupgames table
                var pickupDb = new DbPickups();
                pickupDb.AddPickupGame(_manager.CreatePickupInfo());

                _manager.HasTeamSelectionStarted = false;
                await
                _sst.QlCommands.QlCmdSay(
                    "^5[PICKUP]^4 *** ^7TEAMS ARE ^3FULL.^7 PLEASE ^2*READY UP (F3)*^7 TO START THE GAME! ^4***", false);

                await
                _sst.QlCommands.QlCmdSay(
                    "^5[PICKUP]^7 Any unpicked players or late-adders will be automatically added to the substitutes list when the game starts!",
                    false);

                Log.Write("Teams are now full!", _logClassType, _logPrefix);
            }
        }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PickupUserInfoCmd"/> class.
 /// </summary>
 /// <param name="sst">The main class.</param>
 public PickupUserInfoCmd(SynServerTool sst)
 {
     _sst      = sst;
     _pickupDb = new DbPickups();
 }