#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.Classes;
using Arthea.Connections.Players;
using Arthea.Continents.Areas.Characters;
using Arthea.Continents.Areas.Characters.Enums;
namespace Arthea.Abilities.Skills
{
/// <summary>
/// Implementation of a skill.
/// </summary>
public abstract class Skill : Ability
{
#region [rgn] Constructors (1)
/// <summary>
/// Initializes a new instance of the <see cref="Skill"/> class.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="levels">The levels.</param>
/// <param name="pos">The pos.</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 Skill(string name, ClassValues levels, Position pos, byte wait,
byte difficulty, string damage, AbilityFlags flags)
: base(name, levels, pos, wait, difficulty, damage, flags)
{
}
#endregion [rgn]
#region [rgn] Methods (4)
// [rgn] Public Methods (4)
/// <summary>
/// Determines whether this instance [can use skill] the specified character.
/// </summary>
/// <param name="ch">The character.</param>
/// <returns>
/// <c>true</c> if this instance [can use skill] the specified from; otherwise, <c>false</c>.
/// </returns>
public bool CanUseSkill(Character ch)
{
if (ch == null || !(ch is Player))
return false;
Player player = ch as Player;
if (player.Learned[Name] == 0)
{
player.WriteLine("You don't know how to use that skill.");
return false;
}
if (Level[player.Class] == 0
|| Level[player.Class] > player.Level)
{
player.WriteLine("You don't know how to use {0}.", Name);
return false;
}
return true;
}
/// <summary>
/// Executes the specified skill.
/// </summary>
/// <param name="skill">The skill.</param>
/// <param name="player">The player.</param>
/// <param name="argument">The argument.</param>
public static void Execute(Skill skill, Player player, String argument)
{
if (!skill.CanUseSkill(player))
return;
skill.Process(player, argument);
skill.SetWaitTime(player);
}
/// <summary>
/// Processes this skill for a character.
/// </summary>
/// <param name="ch">The character.</param>
/// <param name="argument">The argument.</param>
public abstract void Process(Character ch, String argument);
/// <summary>
/// Sets the wait time for a player.
/// </summary>
/// <param name="ch">The character.</param>
public void SetWaitTime(Player ch)
{
ch.Connection.Wait = WaitTime;
}
#endregion [rgn]
}
}