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 }); }
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; }
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(); }
private void UpdateCurrentPlayer(BlackJackPlayer player) => CurrentPlayer = player.Identifier == Dealer.Identifier ? _players.First() : _players.SkipWhile(p => p.Identifier != player.Identifier) .Skip(1).Take(1).Single();