public async Task Standings(Moderator moderator) { EnsureAGameWasCreated(); EnsureAllowedToShowStandings(moderator); var sortedPlayers = _game.Players.OrderByDescending(x => x.CurrentScore.Value).ToList(); await _output.Write($"**{moderator.Name}** asked for the current standings:"); for (var i = 0; i < sortedPlayers.Count; i++) { await _output.Write( $"{i + 1}. is **{sortedPlayers[i].Name}** with **{sortedPlayers[i].CurrentScore.Value}** point(s)."); } }
public Game(Moderator moderator, IReadOnlyList <Player> players) { Moderator = moderator; var hasDuplicates = players.GroupBy(p => p).Any(g => g.Count() > 1); if (hasDuplicates) { throw new ArgumentException( "Can't create a game with duplicated players. Make sure your players have unique names."); } if (players.Count < 1) { throw new ArgumentException("You need at least one player to create a new game."); } _players = players.ToList(); }
public async Task StandingsAsync() { var moderator = new Moderator(Context.User.Username); await _gameCommander.Standings(moderator); }
public async Task New(params string[] playerNames) { var moderator = new Moderator(Context.User.Username); var players = playerNames.Select(p => new Player(p)).ToArray(); await _gameCommander.New(moderator, players); }
public bool Equals(Moderator other) { return(other?.Name == Name); }