Help.cs

src/Help.cs · 3.8 KB

From the archive Arthea-src-1.0.zip

Download the archive   « Back to the archive contents

#region Arthea License

/***********************************************************************
*  Arthea MUD by R. Jennings (2007)      http://arthea.googlecode.com/ *
*  By using this code you comply with the Artistic and GPLv2 Licenses. *
***********************************************************************/

#endregion

using Arthea.Collections;
using Arthea.Connections.Players;
using Arthea.Environment;

namespace Arthea
{
    /// <summary>
    /// Implements a help "file".
    /// </summary>
    public class Help
    {
        #region [rgn] Fields (4)

        private StringList keywords = new StringList();
        private byte level;
        private HelpList seeAlso = new HelpList();
        private string text;

        #endregion [rgn]

        #region [rgn] Constructors (2)

        /// <summary>
        /// Initializes a new instance of the <see cref="Help"/> class.
        /// </summary>
        /// <param name="keyword">The keyword.</param>
        public Help(string keyword)
        {
            keywords.Add(keyword);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Help"/> class.
        /// </summary>
        public Help()
        {
        }

        #endregion [rgn]

        #region [rgn] Properties (4)

        /// <summary>
        /// Gets or sets the keywords.
        /// </summary>
        /// <value>The keywords.</value>
        public StringList Keywords
        {
            get { return keywords; }
            set { keywords = value; }
        }

        /// <summary>
        /// Gets or sets the level.
        /// </summary>
        /// <value>The level.</value>
        public byte Level
        {
            get { return level; }
            set { level = value; }
        }

        /// <summary>
        /// Gets or sets the see also.
        /// </summary>
        /// <value>The see also.</value>
        public HelpList SeeAlso
        {
            get { return seeAlso; }
            set { seeAlso = value; }
        }

        /// <summary>
        /// Gets or sets the text.
        /// </summary>
        /// <value>The text.</value>
        public string Text
        {
            get { return text; }
            set { text = value; }
        }

        #endregion [rgn]

        #region [rgn] Methods (4)

        // [rgn] Public Methods (4)

        /// <summary>
        /// Attaches this instance to the help list.
        /// </summary>
        public void Attach()
        {
            Lists.Helps.Add(this);
        }

        /// <summary>
        /// Creates an instance for editing by a player.
        /// </summary>
        /// <param name="player">The player.</param>
        /// <param name="argument">The argument.</param>
        public static void Create(Player player, String argument)
        {
            Help help = new Help(argument);

            help.Attach();

            player.WriteLine("Help created.");

            player.Connection.Edit(help);
        }

        /// <summary>
        /// Releases this instance from the help list.
        /// </summary>
        public void Release()
        {
            Lists.Helps.Remove(this);
        }

        /// <summary>
        /// Returns a <see cref="T:System.String"></see> that represents the current <see cref="T:System.Object"></see>.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"></see> that represents the current <see cref="T:System.Object"></see>.
        /// </returns>
        public override string ToString()
        {
            if (keywords.Count > 0)
                return keywords[0].ToString();
            else
                return "<unknown>";
        }

        #endregion [rgn]
    }
}

Site Stats

Snippets: 1791
Codebases: 571