#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.Creation;
using Arthea.Creation.Attributes;
using Arthea.Database.Interfaces;
using Arthea.Environment;
using Arthea.Interfaces;
namespace Arthea.Scripts
{
/// <summary>
/// Implementation of a script's code.
/// </summary>
public class ScriptCode : CustomEditType, Indexed
{
#region [rgn] Fields (3)
private string description;
private uint id;
[TextEdit] private string text;
#endregion [rgn]
#region [rgn] Constructors (2)
/// <summary>
/// Initializes a new instance of the <see cref="ScriptCode"/> class.
/// </summary>
/// <param name="id">The id.</param>
public ScriptCode(uint id)
{
this.id = id;
}
/// <summary>
/// Initializes a new instance of the <see cref="ScriptCode"/> class.
/// </summary>
public ScriptCode()
{
}
#endregion [rgn]
#region [rgn] Properties (3)
/// <summary>
/// Gets or sets the description.
/// </summary>
/// <value>The description.</value>
public string Description
{
get { return description; }
set { description = value; }
}
/// <summary>
/// Gets or sets the code.
/// </summary>
/// <value>The code.</value>
public string Text
{
get { return text; }
set { text = value; }
}
/// <summary>
/// Gets or sets the id.
/// </summary>
/// <value>The id.</value>
public uint Id
{
get { return id; }
set { id = value; }
}
#endregion [rgn]
#region [rgn] Methods (4)
// [rgn] Public Methods (4)
/// <summary>
/// Attaches this instance.
/// </summary>
public void Attach()
{
Lists.Scripts.Add(this);
}
/// <summary>
/// Gets the next available id.
/// </summary>
/// <returns>a uint</returns>
public static uint GetNextId()
{
uint count = (uint) Lists.Scripts.Count;
while (Lists.Scripts.ContainsKey(count))
count++;
return count + 1;
}
/// <summary>
/// Releases this instance.
/// </summary>
public void Release()
{
Lists.Scripts.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()
{
return Id.ToString();
}
#endregion [rgn]
#region CustomEditType Members
/// <summary>
/// Allows custom editing of this type by player.
/// </summary>
/// <param name="player">The player.</param>
/// <param name="editor">The editor values.</param>
/// <param name="argument">The argument.</param>
public void CustomEdit(Player player, OlcField editor, String argument)
{
player.Connection.Edit(this);
}
#endregion
}
}