Beispiel #1
0
        static void NewRound(CardShuffler cs, Player player, Dealer dealer)
        {
            if (cs.RestockRequired())
            {
                cs.Restock();
            }

            player.AddToHand(cs.Deal());
            dealer.AddToHand(cs.Deal());
            player.AddToHand(cs.Deal());
            dealer.AddToHand(cs.Deal(), false);

            Console.WriteLine();

            dealer.CheckBlackjack();

            if (!dealer.Blackjack)
            {
                Console.WriteLine();

                player.ShowHand();

                player.Turn(cs);

                ConsoleKeyInfo keyInfo;

                if (player.HandValue <= 21 && !player.Blackjack)
                {
                    player.ShowHand();
                    Console.WriteLine("Player has been dealt\n");
                    Console.WriteLine("Dealer's turn");
                    Console.WriteLine("Press 'Enter' to continue\n");

                    do
                    {
                        keyInfo = Console.ReadKey(true);
                    }while (keyInfo.Key != ConsoleKey.Enter);

                    dealer.ShowHand();

                    dealer.Turn(cs);

                    if (!dealer.Blackjack)
                    {
                        Console.WriteLine("Player: " + player.HandValue);
                        Console.WriteLine("Dealer: " + dealer.HandValue);
                    }
                }

                Console.WriteLine();
            }
            else
            {
                player.CheckBlackjack();
            }

            Player.DetermineResult(player, dealer);
            player.ShowRecord();
            dealer.ShowRecord();
        }
Beispiel #2
0
        public void SetUp()
        {
            _deck = new CardDeck();
            _deck.MakeDeck();
            _deck.Shuffle();
            _player = new Player();
            _dealer = new Player();

            _player.AddToHand(_deck.Draw());
            _player.AddToHand(_deck.Draw());

            _dealer.AddToHand(_deck.Draw());
            _dealer.AddToHand(_deck.Draw());
        }
Beispiel #3
0
        public void AddCardToPlayerHand(Player player, string message)
        {
            var drawnCard = _deck.Draw();

            player.AddToHand(drawnCard);
            Console.WriteLine($"{message} {drawnCard.ToString()}");
        }