#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] } }