private static int PlayerTurn(Deck deck) { int playerScore = 0; //Deal 2 cards for User Card c1 = deck.GetNextCard(); Card c2 = deck.GetNextCard(); //Describe Cards Console.WriteLine(c1); Console.WriteLine(c2); // Give score - check that not bust playerScore = GetCardValue(c1) + GetCardValue(c2); Console.WriteLine(string.Format("Your score is {0}", playerScore)); //// Ask if stick or twist - loop until stick or bust bool twist = true; while (playerScore < 21 & twist) { string response = ""; do { Console.WriteLine("Do you want to stick or twist - select S or T ?"); response = Console.ReadLine().ToLower(); } while (!IsValidInput(response, "s", "stick", "t", "twist")); if (response.Equals("t") | response.Equals("twist")) { Console.WriteLine("Twist selected"); // If twist give another card Card nextCard = deck.GetNextCard(); Console.WriteLine(nextCard); // Calculate score playerScore += GetCardValue(nextCard); Console.WriteLine(string.Format("Your score is {0}", playerScore)); } else { Console.WriteLine("Stick selected"); twist = false; } } return(playerScore); }
private static int DealerTurn(Deck deck) { int dealerScore = 0; Card c; Console.WriteLine("Dealers turn"); while (dealerScore < 17) { c = deck.GetNextCard(); Console.WriteLine(c); dealerScore += GetCardValue(c); Console.WriteLine("Total score is {0}", dealerScore); } return(dealerScore); }