private void DealerPlay() { // Flag to keep track of blackjack, bust or preferred value. var playing = true; while (playing) { // Get possible out comes. var isBlackjack = BlackjackRules.IsBlackjack(dealer.Hand); var isBust = BlackjackRules.IsBusted(dealer.Hand); var shouldStay = BlackjackRules.ShouldStay(dealer.Hand); // Act according to outcome. if (isBlackjack) { console.WriteDealerInfo("blackjack!"); } else if (isBust) { console.WriteDealerInfo("bust!"); } else if (shouldStay) { console.WriteDealerInfo("staying at my current hand"); } else { // Deal self one card and reveal new hand. console.WriteDealerInfo("dealing myself one"); dealer.DealSelf(); RevealDealerHand(); } playing = !(isBlackjack || isBust || shouldStay); clock.Delay(DelayTime); } console.WriteDealerInfo("my turn is over"); }