AbilityList.cs

src/Abilities/AbilityList.cs · 2.2 KB

From the archive Arthea-src-1.0.zip

Download the archive   « Back to the archive contents

#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.Collections.Generic;
using Arthea.Abilities.Skills;
using Arthea.Abilities.Spells;

namespace Arthea.Abilities
{
    /// <summary>
    /// Implementation of a ability list.
    /// </summary>
    public class AbilityList : List<Ability>
    {
        #region [rgn] Constructors (1)

        /// <summary>
        /// Initializes a new instance of the <see cref="AbilityList"/> class.
        /// </summary>
        public AbilityList()
        {
            Log.Info("Initializing abilities...");

            Add(new MagicMissileSpell());
            Add(new KickSkill());
        }

        #endregion [rgn]

        #region [rgn] Methods (3)

        // [rgn] Public Methods (3)

        /// <summary>
        /// Finds the name.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns>an ability</returns>
        public Ability FindName(String name)
        {
            return Find(delegate(Ability skill) { return name == skill.Name; });
        }

        /// <summary>
        /// Finds the skill.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns>a skill</returns>
        public Skill FindSkill(String name)
        {
            return
                Find(
                    delegate(Ability ability) { return ability is Skill && name.IsPrefixOf(ability.Name); }) as
                Skill;
        }

        /// <summary>
        /// Finds the spell.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns> a spell</returns>
        public Spell FindSpell(String name)
        {
            return
                Find(
                    delegate(Ability ability) { return ability is Spell && name.IsPrefixOf(ability.Name); }) as
                Spell;
        }

        #endregion [rgn]
    }
}

Site Stats

Snippets: 1791
Codebases: 571