Beispiel #1
0
        static void PlayerSomethingMessage([NotNull] IClassy player, [NotNull] string action, [NotNull] IClassy target, [CanBeNull] string reason)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }
            string message = String.Format("{0}&W* {1}&W was {2} by {3}&W",
                                           Color.IRCBold,
                                           target.ClassyName,
                                           action,
                                           player.ClassyName);

            if (!String.IsNullOrEmpty(reason))
            {
                message += " Reason: " + reason;
            }
            if (ConfigKey.IRCBotAnnounceServerEvents.Enabled())
            {
                SendAction(message);
            }
        }
Beispiel #2
0
        public void PrintDescription(Player player, IClassy target, string noun, string verb)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }
            if (noun == null)
            {
                throw new ArgumentNullException("noun");
            }
            if (verb == null)
            {
                throw new ArgumentNullException("verb");
            }
            PlayerListCollection list = ExceptionList;

            noun = Char.ToUpper(noun[0]) + noun.Substring(1);     // capitalize first letter

            StringBuilder message = new StringBuilder();

            if (NoRankRestriction)
            {
                message.AppendFormat("{0} {1}&S can be {2} by anyone",
                                     noun, target.GetClassyName(), verb);
            }
            else
            {
                message.AppendFormat("{0} {1}&S can only be {2} by {3}+&S",
                                     noun, target.GetClassyName(),
                                     verb, MinRank.GetClassyName());
            }

            if (list.Included.Length > 0)
            {
                message.AppendFormat(" and {0}&S", list.Included.JoinToClassyString());
            }

            if (list.Excluded.Length > 0)
            {
                message.AppendFormat(", except {0}", list.Excluded.JoinToClassyString());
            }

            message.Append('.');
            player.Message(message.ToString());
        }
Beispiel #3
0
        /// <summary> Creates a description string of the controller. </summary>
        /// <param name="target"> Name of the object that owns this controller. </param>
        /// <param name="noun"> The type of target (e.g. "world" or "zone"). </param>
        /// <param name="verb"> The action, in past tense, that this
        /// controller manages (e.g. "accessed" or "modified"). </param>
        public string GetDescription([NotNull] IClassy target, [NotNull] string noun, [NotNull] string verb)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }
            if (noun == null)
            {
                throw new ArgumentNullException("noun");
            }
            if (verb == null)
            {
                throw new ArgumentNullException("verb");
            }
            PlayerExceptions list = ExceptionList;

            StringBuilder message = new StringBuilder(noun);

            message[0] = Char.ToUpper(message[0]);   // capitalize first letter.

            if (HasRankRestriction)
            {
                message.AppendFormat(" {0}&S can only be {1} by {2}+&S",
                                     target.ClassyName,
                                     verb,
                                     MinRank.ClassyName);
            }
            else
            {
                message.AppendFormat(" {0}&S can be {1} by anyone",
                                     target.ClassyName,
                                     verb);
            }

            if (list.Included.Length > 0)
            {
                message.AppendFormat(" and {0}&S", list.Included.JoinToClassyString());
            }

            if (list.Excluded.Length > 0)
            {
                message.AppendFormat(", except {0}&S", list.Excluded.JoinToClassyString());
            }

            message.Append('.');
            return(message.ToString());
        }
Beispiel #4
0
        //Method: MyMethod
        //Purpose: Calls interface to use WriteALine method
        public static void MyMethod(object myObject)
        {
            IClassy iClass = (IClassy)myObject;

            iClass.WriteALine();
        }
        static bool SetPlayerInfoField([NotNull] Player player, [NotNull] string fieldName, [NotNull] IClassy info,
                                       [CanBeNull] string oldValue, [CanBeNull] string newValue)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (fieldName == null)
            {
                throw new ArgumentNullException("fieldName");
            }
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }
            if (newValue == oldValue)
            {
                if (newValue == null)
                {
                    player.Message("SetInfo: {0} for {1}&S is not set.",
                                   fieldName, info.ClassyName);
                }
                else
                {
                    player.Message("SetInfo: {0} for {1}&S is already set to \"{2}&S\"",
                                   fieldName, info.ClassyName, oldValue);
                }
                return(false);
            }

            if (oldValue == null)
            {
                player.Message("SetInfo: {0} for {1}&S set to \"{2}&S\"",
                               fieldName, info.ClassyName, newValue);
            }
            else if (newValue == null)
            {
                player.Message("SetInfo: {0} for {1}&S was reset (was \"{2}&S\")",
                               fieldName, info.ClassyName, oldValue);
            }
            else
            {
                player.Message("SetInfo: {0} for {1}&S changed from \"{2}&S\" to \"{3}&S\"",
                               fieldName, info.ClassyName,
                               oldValue, newValue);
            }
            return(true);
        }
Beispiel #6
0
        public void PrintDescription( Player player, IClassy target, string noun, string verb ) {
            if( player == null ) throw new ArgumentNullException( "player" );
            if( target == null ) throw new ArgumentNullException( "target" );
            if( noun == null ) throw new ArgumentNullException( "noun" );
            if( verb == null ) throw new ArgumentNullException( "verb" );
            PlayerListCollection list = ExceptionList;

            noun = Char.ToUpper( noun[0] ) + noun.Substring( 1 ); // capitalize first letter

            StringBuilder message = new StringBuilder();

            if( NoRankRestriction ) {
                message.AppendFormat( "{0} {1}&S can be {2} by anyone",
                                      noun, target.GetClassyName(), verb );

            } else {
                message.AppendFormat( "{0} {1}&S can only be {2} by {3}+&S",
                                      noun, target.GetClassyName(),
                                      verb, MinRank.GetClassyName() );
            }

            if( list.Included.Length > 0 ) {
                message.AppendFormat( " and {0}&S", list.Included.JoinToClassyString() );
            }

            if( list.Excluded.Length > 0 ) {
                message.AppendFormat( ", except {0}", list.Excluded.JoinToClassyString() );
            }

            message.Append( '.' );
            player.Message( message.ToString() );
        }