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