/
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 System;
using System.IO;
using Arthea.Clans.Enums;
using Arthea.Environment;

namespace Arthea.Clans
{
    /// <summary>
    /// Implements clans
    /// </summary>
    public abstract class Clan
    {
        #region [rgn] Fields (4)

        private Alignment alignment;
        private Ethos ethos;
        private ClanMemberList members = new ClanMemberList();
        private string name;

        #endregion [rgn]

        #region [rgn] Constructors (2)

        /// <summary>
        /// Initializes a new instance of the <see cref="Clan"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="ethos">The ethos.</param>
        /// <param name="align">The align.</param>
        public Clan(string name, Ethos ethos, Alignment align)
        {
            this.name = name;
            this.ethos = ethos;
            alignment = align;

            string fileName = Paths.ClanDir + Persistance.MakeFileName(Name);

            if (!Persistance.XmlFileExists(fileName))
            {
                Persistance.Save(fileName, members);
            }
            else
            {
                members = Persistance.Load<ClanMemberList>(fileName);
            }
        }

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

        #endregion [rgn]

        #region [rgn] Properties (4)

        /// <summary>
        /// Gets or sets the alignment.
        /// </summary>
        /// <value>The alignment.</value>
        public Alignment Alignment
        {
            get { return alignment; }
            set { alignment = value; }
        }

        /// <summary>
        /// Gets or sets the ethos.
        /// </summary>
        /// <value>The ethos.</value>
        public Ethos Ethos
        {
            get { return ethos; }
            set { ethos = value; }
        }

        /// <summary>
        /// Gets or sets the members.
        /// </summary>
        /// <value>The members.</value>
        public ClanMemberList Members
        {
            get { return members; }
            set { members = value; }
        }

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        /// <value>The name.</value>
        public string Name
        {
            get { return name; }
            set
            {
                if (string.IsNullOrEmpty(value))
                    throw new Exception("Name cannot be empty.");

                string fileName = Paths.ClanDir + Persistance.MakeFileName(name);

                if (Persistance.XmlFileExists(fileName)
                    && name != value)
                {
                    File.Move(Persistance.XmlFileName(fileName),
                              Persistance.XmlFileName(Paths.ClanDir + Persistance.MakeFileName(value)));
                }

                name = value;
            }
        }

        #endregion [rgn]

        #region [rgn] Methods (1)

        // [rgn] Public Methods (1)

        /// <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()
        {
            return name;
        }

        #endregion [rgn]
    }
}