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(); }
public void DealerTurn(Deck deck1) { System.Console.WriteLine($"{dealer.name}'s hidden card is {dealer.hand[1].stringVal} of {dealer.hand[1].suit}."); System.Console.WriteLine($"{dealer.name} has {dealer.DisplayPoints()}."); if (dealer.CheckBlackjack() == true) { System.Console.WriteLine("Blackjack!"); } while (dealer.DisplayPoints() < 17) { dealer.PlayerDraw(deck1); System.Console.WriteLine($"{dealer.name} has {dealer.DisplayPoints()}."); } if (dealer.DisplayPoints() > 21) { Console.ForegroundColor = ConsoleColor.Red; System.Console.WriteLine($"{player1.name} Won!"); } else if (player1.DisplayPoints() < dealer.DisplayPoints()) { System.Console.WriteLine($"{player1.name} Lost."); } else if (player1.DisplayPoints() == dealer.DisplayPoints()) { if (player1.CheckBlackjack() == true && dealer.CheckBlackjack() != true) { Console.ForegroundColor = ConsoleColor.Red; System.Console.WriteLine($"{player1.name} Won!"); } else if (player1.CheckBlackjack() != true && dealer.CheckBlackjack() == true) { System.Console.WriteLine($"{player1.name} Lost."); } else { System.Console.WriteLine($"{player1.name} Tied with the dealer."); } } else { Console.ForegroundColor = ConsoleColor.Red; System.Console.WriteLine($"{player1.name} Won!"); } Console.ResetColor(); }