using System.Collections.Generic;
using System.Linq;
namespace Moserware.Skills
{
///
/// Helper class for working with a single team.
///
public class Team
{
private readonly Dictionary _PlayerRatings = new Dictionary();
///
/// Constructs a new team.
///
public Team()
{
}
///
/// Constructs a and populates it with the specified .
///
/// The player to add.
/// The rating of the .
public Team(TPlayer player, Rating rating)
{
AddPlayer(player, rating);
}
///
/// Adds the to the team.
///
/// The player to add.
/// The rating of the .
/// The instance of the team (for chaining convenience).
public Team AddPlayer(TPlayer player, Rating rating)
{
_PlayerRatings[player] = rating;
return this;
}
///
/// Returns the as a simple dictionary.
///
/// The as a simple dictionary.
public IDictionary AsDictionary()
{
return _PlayerRatings;
}
}
///
/// Helper class for working with a single team.
///
public class Team : Team
{
///
/// Constructs a new team.
///
public Team()
{
}
///
/// Constructs a and populates it with the specified .
///
/// The player to add.
/// The rating of the .
public Team(Player player, Rating rating)
: base(player, rating)
{
}
}
///
/// Helper class for working with multiple teams.
///
public static class Teams
{
///
/// Concatenates multiple teams into a list of teams.
///
/// The teams to concatenate together.
/// A sequence of teams.
public static IEnumerable> Concat(params Team[] teams)
{
return teams.Select(t => t.AsDictionary());
}
}
}