/// <summary> /// The player should now have the option of hitting, staying, splitting or doubling down. /// This function should run through the motions of the actual game of blackjack /// </summary> /// <param name="player"></param> private void PlayerPlay(Player player, Hand thisHand) { int total = thisHand.Total; thisHand.Status = HandStatus.InPlay; string option = PlayerOption.begin.ToString(); string probabilityOptions = ""; string probOption = ""; while (total < 21 && (option.ToLower() == PlayerOption.hit.ToString() || option.ToLower() == PlayerOption.begin.ToString() || option.ToLower() == PlayerOption.prob.ToString()) && thisHand.Status != HandStatus.Bust) { if (probabilityOptions != "") { show.ProbabilityOfCards(Deck.ProbabilityOfCard(probabilityOptions)); probabilityOptions = ""; } UpdateTable(true, true); show.PlayerOptions(player.Name); option = player.GetPlayInput(thisHand, Dealer.Hands[0].Cards.First()); if (option.IndexOf(' ') != -1) { probOption = option; option = option.Substring(0, option.IndexOf(' ')); } show.Clear(); string lowerOption = option.ToLower(); PlayerOption playerOption = GetIntOption(lowerOption); switch (playerOption) { case PlayerOption.hit: Hit(thisHand); break; case PlayerOption.dbl: if (!Double(player, thisHand)) { var message = "You do not have enough money to double"; show.AddToMessage(message); option = PlayerOption.begin.ToString(); } else if (thisHand.Status != HandStatus.Bust) { thisHand.Status = HandStatus.Played; } break; case PlayerOption.split: if (thisHand.Cards[0].Name == thisHand.Cards[1].Name) { // We also need to verify that the player has enough money to split. Split(ref player); option = PlayerOption.stand.ToString(); thisHand.Status = HandStatus.Played; } else { var message = "Split is not valid in this situation."; show.AddToMessage(message); option = PlayerOption.begin.ToString(); } break; case PlayerOption.prob: probabilityOptions = CheckProbability(probOption); break; case PlayerOption.stand: default: thisHand.Status = HandStatus.Played; break; } } }