namespace Moserware.Skills { /// /// Represents a player who has a . /// public class Player : ISupportPartialPlay, ISupportPartialUpdate { private const double DefaultPartialPlayPercentage = 1.0; // = 100% play time private const double DefaultPartialUpdatePercentage = 1.0; // = receive 100% update private readonly T _Id; private readonly double _PartialPlayPercentage; private readonly double _PartialUpdatePercentage; /// /// Constructs a player. /// /// The identifier for the player, such as a name. public Player(T id) : this(id, DefaultPartialPlayPercentage, DefaultPartialUpdatePercentage) { } /// /// Constructs a player. /// /// The identifier for the player, such as a name. /// The weight percentage to give this player when calculating a new rank. public Player(T id, double partialPlayPercentage) : this(id, partialPlayPercentage, DefaultPartialUpdatePercentage) { } /// /// Constructs a player. /// /// The identifier for the player, such as a name. /// The weight percentage to give this player when calculating a new rank. /// /// Indicated how much of a skill update a player should receive where 0 represents no update and 1.0 represents 100% of the update. public Player(T id, double partialPlayPercentage, double partialUpdatePercentage) { // If they don't want to give a player an id, that's ok... Guard.ArgumentInRangeInclusive(partialPlayPercentage, 0, 1.0, "partialPlayPercentage"); Guard.ArgumentInRangeInclusive(partialUpdatePercentage, 0, 1.0, "partialUpdatePercentage"); _Id = id; _PartialPlayPercentage = partialPlayPercentage; _PartialUpdatePercentage = partialUpdatePercentage; } /// /// The identifier for the player, such as a name. /// public T Id { get { return _Id; } } #region ISupportPartialPlay Members /// /// Indicates the percent of the time the player should be weighted where 0.0 indicates the player didn't play and 1.0 indicates the player played 100% of the time. /// public double PartialPlayPercentage { get { return _PartialPlayPercentage; } } #endregion #region ISupportPartialUpdate Members /// /// Indicated how much of a skill update a player should receive where 0.0 represents no update and 1.0 represents 100% of the update. /// public double PartialUpdatePercentage { get { return _PartialUpdatePercentage; } } #endregion public override string ToString() { if (Id != null) { return Id.ToString(); } return base.ToString(); } } /// /// Represents a player who has a . /// public class Player : Player { /// /// Constructs a player. /// /// The identifier for the player, such as a name. public Player(object id) : base(id) { } /// /// Constructs a player. /// /// The identifier for the player, such as a name. /// The weight percentage to give this player when calculating a new rank. /// Indicated how much of a skill update a player should receive where 0 represents no update and 1.0 represents 100% of the update. public Player(object id, double partialPlayPercentage) : base(id, partialPlayPercentage) { } /// /// Constructs a player. /// /// The identifier for the player, such as a name. /// The weight percentage to give this player when calculating a new rank. /// Indicated how much of a skill update a player should receive where 0 represents no update and 1.0 represents 100% of the update. public Player(object id, double partialPlayPercentage, double partialUpdatePercentage) : base(id, partialPlayPercentage, partialUpdatePercentage) { } } }