Ejemplo n.º 1
0
        /// <summary>
        /// Evaluates the early quit clear command to see if it can be successfully processed.
        /// </summary>
        /// <param name="c">The command argument information.</param>
        /// <returns><c>true</c> if the evaluation was successful, otherwise <c>false</c>.</returns>
        private async Task <bool> EvalEarlyQuitClear(Cmd c)
        {
            if (c.Args.Length != (c.FromIrc ? 5 : 4))
            {
                StatusMessage =
                    string.Format(
                        "^1[ERROR]^3 Usage: {0}{1} {2} clear <name> ^7 - name is without the clan tag",
                        CommandList.GameCommandPrefix, c.CmdName,
                        ((c.FromIrc)
                            ? (string.Format("{0} {1}", c.Args[1],
                                             NameModule))
                            : NameModule));
                await SendServerTell(c, StatusMessage);

                return(false);
            }
            var quitDb = new DbQuits();

            if (!quitDb.UserExistsInDb(Helpers.GetArgVal(c, 3)))
            {
                StatusMessage = string.Format("^1[ERROR] {0}^3 has no early quits.",
                                              Helpers.GetArgVal(c, 3));
                await SendServerTell(c, StatusMessage);

                return(false);
            }
            await ClearEarlyQuits(c, quitDb);

            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Processes the early quit.
        /// </summary>
        /// <param name="player">The player.</param>
        /// <param name="doublePenalty">
        /// if set to <c>true</c> double the penalty for particularly egregious early quits (i.e.
        /// during countdown).
        /// </param>
        private async Task ProcessEarlyQuit(string player, bool doublePenalty)
        {
            if (_usersDb.GetUserLevel(player) >= UserLevel.SuperUser)
            {
                Log.Write(string.Format(
                              "Player {0} quit early, but will not be evaluated for early quitting due to excluded userlevel",
                              player), _logClassType, _logPrefix);
                return;
            }
            if (_quitsDb.UserExistsInDb(player))
            {
                _quitsDb.IncrementUserQuitCount(player, doublePenalty);

                // UI: reflect changes
                _sst.UserInterface.RefreshCurrentQuittersDataSource();
            }
            else
            {
                _quitsDb.AddUserToDb(player, doublePenalty);

                // UI: reflect changes
                _sst.UserInterface.RefreshCurrentQuittersDataSource();
            }

            var qCount = await EvaluateUserQuitCount(player);

            if (doublePenalty)
            {
                await
                _sst.QlCommands.QlCmdSay(
                    string.Format(
                        "^3{0}'s^7 penalty was doubled for unbalancing teams during match start!",
                        player), false);

                Log.Write(string.Format("Active player {0} left during count-down. Penalty will be doubled.",
                                        player), _logClassType, _logPrefix);
            }
            // Only show the log msg if we're not banning the user this time (ban msg is shown in
            // that case)
            if (qCount < _maxQuitsAllowed)
            {
                await
                _sst.QlCommands.QlCmdSay(
                    string.Format("^5[EARLYQUIT]^7 Early quit detected and logged for player ^3{0}",
                                  player), false);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Evaluates the early quit forgive command to see if it can be successfully processed.
        /// </summary>
        /// <param name="c">The command argument information.</param>
        /// <returns><c>true</c> if the evaluation was successful, otherwise <c>false</c>.</returns>
        private async Task <bool> EvalEarlyQuitForgive(Cmd c)
        {
            if (c.Args.Length != (c.FromIrc ? 6 : 5))
            {
                StatusMessage = string.Format(
                    "^1[ERROR]^3 Usage: {0}{1} {2} forgive <name> <# of quits> ^7 - name is without the clan" +
                    " tag. # quits is amount to forgive",
                    CommandList.GameCommandPrefix, c.CmdName,
                    ((c.FromIrc)
                        ? (string.Format("{0} {1}", c.Args[1],
                                         NameModule))
                        : NameModule));
                await SendServerTell(c, StatusMessage);

                return(false);
            }
            var quitDb = new DbQuits();

            if (!quitDb.UserExistsInDb(Helpers.GetArgVal(c, 3)))
            {
                StatusMessage = string.Format("^1[ERROR]^7 {0}^3 has no early quits.", Helpers.GetArgVal(c, 3));
                await SendServerTell(c, StatusMessage);

                return(false);
            }
            int numQuitsToForgive;

            if (!int.TryParse(Helpers.GetArgVal(c, 4), out numQuitsToForgive))
            {
                StatusMessage = "^1[ERROR]^3 # of quits must be a number greater than zero!";
                await SendServerTell(c, StatusMessage);

                return(false);
            }
            if (numQuitsToForgive == 0)
            {
                StatusMessage = "^1[ERROR]^3 # of quits must be greater than zero.";
                await SendServerTell(c, StatusMessage);

                return(false);
            }
            var userTotalQuits = quitDb.GetUserQuitCount(Helpers.GetArgVal(c, 3));

            if (numQuitsToForgive >= userTotalQuits)
            {
                StatusMessage =
                    string.Format(
                        "^1[ERROR]^3 {0} has^1 {1}^3 total quits. This would remove all. If that's" +
                        " what you want: ^1{2}{3} {4} clear {0}",
                        Helpers.GetArgVal(c, 3), userTotalQuits,
                        CommandList.GameCommandPrefix, c.CmdName,
                        ((c.FromIrc)
                            ? (string.Format("{0} {1}", c.Args[1],
                                             NameModule))
                            : NameModule));
                await SendServerTell(c, StatusMessage);

                return(false);
            }
            await ForgiveEarlyQuits(c, numQuitsToForgive, Helpers.GetArgVal(c, 3), quitDb);

            return(true);
        }