Exemple #1
0
 /// <summary>
 /// Sets up the game of 21
 /// </summary>
 private void btnDealCards_Click(object sender, EventArgs e)
 {
     TwentyOne.SetUpGame();
     DisplayGuiHand(TwentyOne.GetHand(DEALER), dealerTableLayoutPanel);
     DisplayGuiHand(TwentyOne.GetHand(PLAYER), playerTableLayoutPanel);
     TwentyOne.DisplayHand(DEALER);
     TwentyOne.DisplayHand(PLAYER);
     DisplayHandValue(PLAYER);
     DisplayHandValue(DEALER);
     lblValue.Text           = TwentyOne.GetNumOfUserAcesWithValueOne().ToString();
     DealerHasBusted.Visible = false;
     PlayerHasBusted.Visible = false;
     btnDealCards.Enabled    = false;
     btnHit.Enabled          = true;
     btnStand.Enabled        = true;
     CheckHandForAce();
     CheckHandForAce();
 }
Exemple #2
0
 /// <summary>
 /// Checks the hand if it has an Ace or not, and allows the user to specify its value
 /// Pre: A Ace in the players hand
 /// Post: Changes the value of the Ace
 /// </summary>
 public void CheckHandForAce()
 {
     if (TwentyOne.CheckAces(PLAYER))
     {
         DialogResult dialogResult = MessageBox.Show("Would You like the ace to be 1?",
                                                     "You have been dealt and Ace", // The MessageBox's caption.
                                                     MessageBoxButtons.YesNo,
                                                     MessageBoxIcon.Question);
         if (dialogResult == DialogResult.Yes)
         {
             TwentyOne.IncreaseNumOfUserAcesWithValueOne();
             lblValue.Text = TwentyOne.GetNumOfUserAcesWithValueOne().ToString();
         }
     }
     DisplayHandValue(PLAYER);
     if (TwentyOne.HandValue(PLAYER) == TwentyOne.MAXVALUE)
     {
         DisableButtons();
         ComputersTurn();
     }
 }