Ejemplo n.º 1
0
        public void PlayerHits(string playerIdentifier, string handIdentifier)
        {
            _ = playerIdentifier ?? throw new ArgumentNullException(nameof(playerIdentifier));
            _ = handIdentifier ?? throw new ArgumentNullException(nameof(handIdentifier));
            if (CurrentPlayer.Identifier != playerIdentifier)
            {
                throw new ArgumentException(nameof(playerIdentifier), $"Please wait your turn, Current player is {CurrentPlayer.Name}");
            }

            var player = GetPlayerById(playerIdentifier);

            player.AddCard(handIdentifier, _cardProvider.Cards(1).Single());

            if (player.Status == PlayerStatusTypes.Complete)
            {
                UpdateCurrentPlayer(player);
            }

            if (CurrentPlayer == Dealer)
            {
                DealersTurn();
            }

            SetGameCompleteOnAllPlayersComplete();
        }
Ejemplo n.º 2
0
        public void PlayerHits(string playerIdentifier, string handIdentifier)
        {
            _ = playerIdentifier ?? throw new ArgumentNullException(nameof(playerIdentifier));
            _ = handIdentifier ?? throw new ArgumentNullException(nameof(handIdentifier));
            if (CurrentPlayer.Identifier != playerIdentifier)
            {
                throw new ArgumentException(nameof(playerIdentifier), $"Please wait your turn, Current player is {CurrentPlayer.Name}");
            }

            Players.Single(p => p.Identifier == playerIdentifier)
            .Hit(handIdentifier, cardProvider.Cards(1).Single());
            SetGameCompleteOnAllPlayersComplete();
        }