private static BlackJackPlayerModel MapPlayer(BlackJackPlayer player, bool showAll)
 {
     return(new BlackJackPlayerModel
     {
         Name = player.Name,
         Id = player.Identifier,
         Hands = MapHand(player.Hands, showAll),
         Status = player.Status
     });
 }
示例#2
0
 public BlackJackGame(ICardProvider cardProvider, BlackJackPlayer dealer, int maxPlayers)
 {
     Dealer = dealer ?? throw new ArgumentNullException(nameof(dealer));
     if (maxPlayers < 1)
     {
         throw new ArgumentOutOfRangeException(nameof(maxPlayers));
     }
     this.cardProvider = cardProvider ?? throw new ArgumentNullException(nameof(cardProvider));
     MaxPlayerCount    = maxPlayers;
 }
示例#3
0
        public void AddPlayer(BlackJackPlayer player)
        {
            _ = player ?? throw new ArgumentNullException(nameof(player));
            if (players.Count >= MaxPlayerCount)
            {
                throw new InvalidOperationException($"{player.Name} can NOT join game, The game Status is {Status}.");
            }
            players.Add(player);

            SetCurrentPlayerOnFirstPlayerAdd();
            AddDealerToListAfterFinalPlayer();
            SetReadyOnMaxPlayers();
        }
示例#4
0
 private void UpdateCurrentPlayer(BlackJackPlayer player) =>
 CurrentPlayer = player.Identifier == Dealer.Identifier
                                 ? _players.First()
                                 : _players.SkipWhile(p => p.Identifier != player.Identifier)
                 .Skip(1).Take(1).Single();