#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 Arthea.Classes;
using Arthea.Continents.Areas.Characters.Enums;
namespace Arthea.Abilities
{
/// <summary>
/// Implementation of a ability.
/// </summary>
public abstract class Ability
{
#region [rgn] Fields (7)
private string damageNoun;
private byte difficulty;
private AbilityFlags flags;
private ClassValues level;
private Position minimumPosition;
private string name;
private byte waitTime;
#endregion [rgn]
#region [rgn] Constructors (2)
/// <summary>
/// Initializes a new instance of the <see cref="Ability"/> class.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="levels">The class levels.</param>
/// <param name="pos">The position.</param>
/// <param name="wait">The wait.</param>
/// <param name="difficulty">The difficulty.</param>
/// <param name="damage">The damage.</param>
/// <param name="flags">The flags.</param>
public Ability(string name, ClassValues levels, Position pos,
byte wait, byte difficulty, string damage, AbilityFlags flags)
{
this.name = name;
level = levels;
minimumPosition = pos;
waitTime = wait;
this.difficulty = difficulty;
damageNoun = damage;
this.flags = flags ?? new AbilityFlags();
}
/// <summary>
/// Initializes a new instance of the <see cref="Ability"/> class.
/// </summary>
/// <param name="name">The name.</param>
public Ability(string name)
{
this.name = name;
level = new ClassValues();
}
#endregion [rgn]
#region [rgn] Properties (7)
/// <summary>
/// Gets or sets the damage noun.
/// </summary>
/// <value>The damage noun.</value>
public string DamageNoun
{
get { return damageNoun; }
set { damageNoun = value; }
}
/// <summary>
/// Gets or sets the difficulty.
/// </summary>
/// <value>The difficulty.</value>
public byte Difficulty
{
get { return difficulty; }
set { difficulty = value; }
}
/// <summary>
/// Gets or sets the flags.
/// </summary>
/// <value>The flags.</value>
public AbilityFlags Flags
{
get { return flags; }
set { flags = value; }
}
/// <summary>
/// Gets or sets the level.
/// </summary>
/// <value>The level.</value>
public ClassValues Level
{
get { return level; }
set { level = value; }
}
/// <summary>
/// Gets or sets the minimum position.
/// </summary>
/// <value>The minimum position.</value>
public Position MinimumPosition
{
get { return minimumPosition; }
set { minimumPosition = 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 wait time.
/// </summary>
/// <value>The wait time.</value>
public byte WaitTime
{
get { return waitTime; }
set { waitTime = value; }
}
#endregion [rgn]
#region [rgn] Methods (1)
// [rgn] Public Methods (1)
/// <summary>
/// Creates class levels.
/// </summary>
/// <param name="levels">the list of class names and levels
/// example - "warrior", 2, "thief", 3.</param>
/// <returns>a classvalues object</returns>
public static ClassValues CreateLevels(params object[] levels)
{
if (levels.Length%2 != 0)
throw new ArgumentException();
ClassValues foo = new ClassValues();
int i = 0;
while (i < levels.Length)
{
foo[levels[i++].ToString()] = Convert.ToByte(levels[i++]);
}
return foo;
}
#endregion [rgn]
}
/// <summary>
/// Implementation of a ability flags.
/// </summary>
public class AbilityFlags : Flag
{
#region [rgn] Constructors (3)
/// <summary>
/// Initializes a new instance of the <see cref="AbilityFlags"/> class.
/// </summary>
/// <param name="flag">The bit array.</param>
public AbilityFlags(Flag flag) : base(flag)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="AbilityFlags"/> class.
/// </summary>
/// <param name="mask">The mask.</param>
public AbilityFlags(ulong mask) : base(mask)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="AbilityFlags"/> class.
/// </summary>
public AbilityFlags()
{
}
#endregion [rgn]
}
}