예제 #1
0
        internal override bool Execute(List <string> args, TextMessage message, PersonDb db)
        {
            StringBuilder outMessage = new StringBuilder();
            Error         result     = DbInterface.AddPlayer(message.InvokerUid, message.InvokerName, db, args.Count > 0 ? args[0] : "");

            outMessage.Append("\n");

            switch (result)
            {
            case Error.OK:
                outMessage.Append("Player added successfully!");
                break;

            case Error.DUPLICATE:
                outMessage.Append("Player already exists in the Database");
                break;

            case Error.INVALIDNAME:
                outMessage.Append("Name already exists within the Database");
                break;

            case Error.SAVEERROR:
                outMessage.Append("Player could not be saved to the Database!");
                break;

            case Error.UNKNOWN:
            default:
                outMessage.Append("An Unknown Error Occured");
                break;
            }
            CommandManager.AnswerCall(message, outMessage.ToString());

            return(false);
        }
예제 #2
0
        internal override CCR Execute(List <string> args, PersonDb db)
        {
            if (args.Count < 2)
            {
                return(CCR.INVALIDPARAM);
            }

            int points = 0;

            if (args.Count > 3)
            {
                if (!Int32.TryParse(args[3], out points))
                {
                    return(CCR.NOTANUMBER);
                }
            }

            //Most checks are in addplayer function
            Error result = DbInterface.AddPlayer(args[0], args[1], db, args.Count > 2 ? args[2] : "", points);

            StringBuilder outMessage = new StringBuilder();

            switch (result)
            {
            case Error.OK:
                outMessage.Append("Player added successfully!");
                break;

            case Error.DUPLICATE:
                outMessage.Append("Player already exists in the Database");
                break;

            case Error.INVALIDNAME:
                outMessage.Append("Name already exists within the Database");
                break;

            case Error.SAVEERROR:
                outMessage.Append("Player could not be saved to the Database!");
                break;

            case Error.UNKNOWN:
            default:
                outMessage.Append("An Unknown Error Occured!");
                break;
            }
            Console.WriteLine(outMessage.ToString());

            return(CCR.OK);
        }