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 new void Turn(CardShuffler cs) { ConsoleKeyInfo keyInfo; if (HandValue < 17) { do { Console.WriteLine("Dealer hits"); AddToHand(cs.Deal()); Console.WriteLine(); ShowHand(); if (HandValue < 17) { Console.WriteLine("Press 'Enter' for dealer's next card\n"); } else if (HandValue > 21) { Console.WriteLine("BUST\n"); Console.WriteLine("Press 'Enter' to continue\n"); } else { Console.WriteLine("Dealer stands.\n"); Console.WriteLine("Press 'Enter' to continue\n"); } do { keyInfo = Console.ReadKey(true); }while (keyInfo.Key != ConsoleKey.Enter); }while (HandValue < 17); } else { Console.WriteLine("Dealer stands.\n"); Console.WriteLine("Press 'Enter' to continue\n"); do { keyInfo = Console.ReadKey(true); }while (keyInfo.Key != ConsoleKey.Enter); } }
protected void ProposeHit(CardShuffler cs) { Console.WriteLine("Would you like another card?"); Console.WriteLine("Press 'H' to hit"); Console.WriteLine("Press 'S' to stand"); Console.WriteLine("Press 'V' to view your hand\n"); ConsoleKeyInfo keyInfo; bool hitAvailable = true; do { keyInfo = Console.ReadKey(true); if (keyInfo.Key == ConsoleKey.H) { AddToHand(cs.Deal()); hitAvailable = CanHit(hitAvailable); if (hitAvailable) { Console.WriteLine("\nWould you like another card?"); Console.WriteLine("Press 'H' to hit"); Console.WriteLine("Press 'S' to stand"); Console.WriteLine("Press 'V' to view your hand\n"); } } if (keyInfo.Key == ConsoleKey.V) { ShowHand(); } if (keyInfo.Key == ConsoleKey.S) { Console.WriteLine("Player stands\n"); } }while (keyInfo.Key != ConsoleKey.S && hitAvailable); }