//Called when either the dealer or the player has a Natural Blackjack. //Flips the dealer's second card, then simply compares the hands to determine //who has the Blackjack. private IEnumerator Blackjack() { cardScript script = hand[1].GetComponent <cardScript>(); yield return(StartCoroutine(script.LiftAndFlip(5))); if (options.GetShowOnUIToggle()) { UI.SetDealerHandValueText(GetHandValue()); } yield return(new WaitForSeconds(0.5f)); if (player.GetHandValue() > GetHandValue()) { StartCoroutine(React(blackjackUIScript.Result.PlayerBlackjack)); } else if (GetHandValue() > player.GetHandValue()) { StartCoroutine(React(blackjackUIScript.Result.DealerBlackjack)); } else { StartCoroutine(React(blackjackUIScript.Result.BothHaveBlackjack)); } }
//Dealer behaves according to standard Blackjack rules. //The second card is flipped over. The dealer draws until his hand is above soft 17. public IEnumerator Stand() { cardScript script = hand[1].GetComponent <cardScript>(); yield return(StartCoroutine(script.LiftAndFlip(5))); if (GetHandValue() > 21) { CheckAces(); } if (options.GetShowOnUIToggle()) { UI.SetDealerHandValueText(GetHandValue()); } while (GetHandValue() < 17 && (GetHandSize() < 5 || options.GetFiveCardCharlieToggleDisabled())) { yield return(StartCoroutine(DealCardToSelf())); yield return(new WaitForSeconds(0.25f)); if (GetHandValue() > 21) { CheckAces(); } } if (GetHandValue() == 17 && hand.FirstOrDefault(i => i.GetComponent <cardScript>().GetValue() == 11) != null) { do { yield return(StartCoroutine(DealCardToSelf())); if (GetHandValue() > 21) { CheckAces(); } yield return(new WaitForSeconds(0.25f)); }while (GetHandValue() < 17 && (GetHandSize() < 5 || options.GetFiveCardCharlieToggleDisabled())); } if (GetHandValue() > 21 && !CheckAces()) { StartCoroutine(React(blackjackUIScript.Result.DealerBust)); } else { StartCoroutine(EvaluateHands()); } }