PlayerList.cs

src/Connections/Players/PlayerList.cs · 1.6 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;

namespace Arthea.Connections.Players
{
    /// <summary>
    /// Implementation of a player list.
    /// </summary>
    public class PlayerList : List<Player>
    {
        #region [rgn] Methods (3)

        // [rgn] Public Methods (3)

        /// <summary>
        /// Finds the name.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public Player FindName(String name)
        {
            if (!name) return null;

            return Find(delegate(Player player) { return name.IsPrefixOf(player.Name); });
        }

        /// <summary>
        /// Saves this instance.
        /// </summary>
        public void Save()
        {
            foreach (Player player in this)
                player.Save();
        }

        /// <summary>
        /// Writes a line to each player.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="args">The args.</param>
        public void WriteLine(string value, params object[] args)
        {
            foreach (Player player in this)
            {
                player.WriteLine(value, args);
            }
        }

        #endregion [rgn]
    }
}

Site Stats

Snippets: 1791
Codebases: 571