コード例 #1
0
        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).");
            }
        }
コード例 #2
0
        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();
        }
コード例 #3
0
ファイル: GameModule.cs プロジェクト: selmaohneh/DiScored
 public async Task StandingsAsync()
 {
     var moderator = new Moderator(Context.User.Username);
     await _gameCommander.Standings(moderator);
 }
コード例 #4
0
ファイル: GameModule.cs プロジェクト: selmaohneh/DiScored
 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);
 }
コード例 #5
0
 public bool Equals(Moderator other)
 {
     return(other?.Name == Name);
 }