/
etc/
lib/
src/Abilities/
src/Abilities/Skills/
src/Abilities/Spells/
src/Abilities/Spells/Enums/
src/Affects/
src/ArtheaConsole/
src/ArtheaConsole/Properties/
src/ArtheaGUI/Properties/
src/Clans/Enums/
src/Commands/Communication/
src/Commands/ItemCommands/
src/Connections/
src/Connections/Colors/
src/Connections/Enums/
src/Connections/Players/
src/Connections/Players/Enums/
src/Continents/
src/Continents/Areas/
src/Continents/Areas/Characters/
src/Continents/Areas/Characters/Enums/
src/Continents/Areas/Items/
src/Continents/Areas/Items/Enums/
src/Continents/Areas/Rooms/
src/Continents/Areas/Rooms/Enums/
src/Continents/Areas/Rooms/Exits/
src/Creation/
src/Creation/Attributes/
src/Creation/Interfaces/
src/Database/
src/Database/Interfaces/
src/Environment/
src/Properties/
src/Scripts/Enums/
src/Scripts/Interfaces/
#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.Connections.Players;
using Arthea.Continents.Areas.Characters;
using Arthea.Continents.Areas.Items;
using Arthea.Environment;

namespace Arthea
{
    /// <summary>
    /// Social messages
    /// </summary>
    public class Social
    {
        #region [rgn] Fields (11)

        private string charFound;
        private string charNoArg;
        private string charNotFound;
        private string charObjFound;
        private string charSelf;
        private string name;
        private string othersFound;
        private string othersNoArg;
        private string othersObjFound;
        private string othersSelf;
        private string victimFound;

        #endregion [rgn]

        #region [rgn] Constructors (2)

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

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

        #endregion [rgn]

        #region [rgn] Properties (11)

        /// <summary>
        /// Gets or sets the char's message when a victim found.
        /// </summary>
        /// <value>The message.</value>
        public string CharFound
        {
            get { return charFound; }
            set { charFound = value; }
        }

        /// <summary>
        /// Gets or sets the char message with no arg.
        /// </summary>
        /// <value>The message.</value>
        public string CharNoArg
        {
            get { return charNoArg; }
            set { charNoArg = value; }
        }

        /// <summary>
        /// Gets or sets the char's message when a victim is not found.
        /// </summary>
        /// <value>The message.</value>
        public string CharNotFound
        {
            get { return charNotFound; }
            set { charNotFound = value; }
        }

        /// <summary>
        /// Gets or sets the char's message when an obj is found.
        /// </summary>
        /// <value>The message.</value>
        public string CharObjFound
        {
            get { return charObjFound; }
            set { charObjFound = value; }
        }

        /// <summary>
        /// Gets or sets the char message when applied to themself.
        /// </summary>
        /// <value>The message.</value>
        public string CharSelf
        {
            get { return charSelf; }
            set { charSelf = value; }
        }

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

        /// <summary>
        /// Gets or sets the others message when victim is found.
        /// </summary>
        /// <value>The message.</value>
        public string OthersFound
        {
            get { return othersFound; }
            set { othersFound = value; }
        }

        /// <summary>
        /// Gets or sets the others message with no arg.
        /// </summary>
        /// <value>The message.</value>
        public string OthersNoArg
        {
            get { return othersNoArg; }
            set { othersNoArg = value; }
        }

        /// <summary>
        /// Gets or sets the others message when an obj is found.
        /// </summary>
        /// <value>The others obj found.</value>
        public string OthersObjFound
        {
            get { return othersObjFound; }
            set { othersObjFound = value; }
        }

        /// <summary>
        /// Gets or sets the others message when char uses themself.
        /// </summary>
        /// <value>The message.</value>
        public string OthersSelf
        {
            get { return othersSelf; }
            set { othersSelf = value; }
        }

        /// <summary>
        /// Gets or sets the victims message.
        /// </summary>
        /// <value>The message.</value>
        public string VictimFound
        {
            get { return victimFound; }
            set { victimFound = value; }
        }

        #endregion [rgn]

        #region [rgn] Methods (3)

        // [rgn] Public Methods (3)

        /// <summary>
        /// Creates an instance for editing.
        /// </summary>
        /// <param name="player">the player creating</param>
        /// <param name="argument">additional arguments</param>
        public static void Create(Player player, String argument)
        {
            Social social = new Social(argument);

            Lists.Socials.Add(social);

            player.Connection.Edit(social);

            player.WriteLine("Social created.");
        }

        /// <summary>
        /// Parses a social caused by a player
        /// </summary>
        /// <param name="player">the player socializing</param>
        /// <param name="argument">additional arguments</param>
        public void Parse(Player player, String argument)
        {
            if (!argument)
            {
                player.Act(null, null, Act.ToRoom, othersNoArg);
                player.Act(null, null, Act.ToPlayer, charNoArg);
                return;
            }

            Character victim = player.Room.Characters.FindPlayer(argument);

            if (victim == null)
            {
                victim = player.Room.Characters.FindName(argument);
            }

            if (victim == null)
            {
                Item obj = player.Room.Items.FindName(argument);

                if (obj == null)
                {
                    player.WriteLine("That person or object is not here.");
                    return;
                }

                player.Act(obj, obj, Act.ToPlayer, charObjFound);
                player.Act(obj, obj, Act.ToRoom, othersObjFound);
                return;
            }

            if (victim == player)
            {
                player.Act(null, victim, Act.ToPlayer, charSelf);
                player.Act(null, victim, Act.ToRoom, othersSelf);
                return;
            }

            player.Act(null, victim, Act.ToPlayer, charFound);
            player.Act(null, victim, Act.ToRoom, othersFound);
            return;
        }

        /// <summary>
        /// Removes all links to this social
        /// </summary>
        public void Release()
        {
            Lists.Socials.Remove(this);
        }

        #endregion [rgn]
    }
}