Esempio n. 1
0
 private void standButton_Click(object sender, EventArgs e)
 {
     doubleButton.Enabled = false;
     if (dealer.Hand.Count == 2)
     {
         dealer.Hand[1].ShowFace = true;
         label2.Text             = "Dealer Hand Value: " + dealer.HandValue().ToString();
         label4.Text             = "Dealer Hand: " + dealer.ShowHand();
     }
     if (player.isBlackJack() && !dealer.isBlackJack())
     {
         MessageBox.Show("You win with Black Jack.");
         blackJackWin();
         newRound();
         return;
     }
     while (dealer.HandValue() < 17)
     {
         deck.DealerHit(dealer);
         label2.Text = "Dealer Hand Value: " + dealer.HandValue().ToString();
         label4.Text = "Dealer Hand: " + dealer.ShowHand();
     }
     if (dealer.HandValue() > 21 || dealer.HandValue() < player.Hand1Value())
     {
         MessageBox.Show("Player Won");
         playerWon();
         newRound();
         return;
     }
     if (dealer.HandValue() == player.Hand1Value())
     {
         if (dealer.isBlackJack() && !player.isBlackJack())
         {
             MessageBox.Show("You lose.");
             playerLost();
             newRound();
             return;
         }
         else if (!dealer.isBlackJack() && player.isBlackJack())
         {
             MessageBox.Show("You win with Black Jack.");
             blackJackWin();
             newRound();
             return;
         }
         else
         {
             MessageBox.Show("Push");
             push();
             newRound();
             return;
         }
     }
     if (dealer.HandValue() <= 21 && dealer.HandValue() > player.Hand1Value())
     {
         MessageBox.Show("You lose.");
         playerLost();
         newRound();
         return;
     }
 }