Exemple #1
0
 /// <summary>
 /// Allows the computer to have a turn
 /// Pre: User had stood or has reached 21
 /// Post: Allows the Comptuer to have a turn
 /// </summary>
 private void ComputersTurn()
 {
     TwentyOne.DealACard(DEALER);
     DisplayHandValue(DEALER);
     TwentyOne.DetermineWinner();
     DisplayGamesWon();
     if (TwentyOne.HandValue(DEALER) > TwentyOne.MAXVALUE)
     {
         DealerHasBusted.Visible = true;
     }
 }
Exemple #2
0
 /// <summary>
 /// Displays the Users hand Value and updates the players hand image
 /// </summary>
 private void DisplayHandValue(int player)
 {
     if (player == PLAYER)
     {
         lblPlayersHandValue.Text = TwentyOne.HandValue(PLAYER).ToString();
         DisplayGuiHand(TwentyOne.GetHand(PLAYER), playerTableLayoutPanel);
     }
     else
     {
         lblDealersHandvalue.Text = TwentyOne.HandValue(DEALER).ToString();
         DisplayGuiHand(TwentyOne.GetHand(DEALER), dealerTableLayoutPanel);
     }
 }
Exemple #3
0
 /// <summary>
 /// Adds a card to a Users Hand and then checks if they have gone bust or not
 /// Pre: They must not have 21 already and have hit the hit button
 /// Post: Deals a card to the player
 /// </summary>
 private void btnHit_Click(object sender, EventArgs e)
 {
     TwentyOne.AddCard(PLAYER);
     DisplayGuiHand(TwentyOne.GetHand(PLAYER), playerTableLayoutPanel);
     CheckHandForAce();
     lblPlayersHandValue.Text = TwentyOne.HandValue(PLAYER).ToString();
     if (TwentyOne.HandValue(PLAYER) > TwentyOne.MAXVALUE)
     {
         TwentyOne.DetermineWinner();
         PlayerHasBusted.Visible = true;
         DisplayGamesWon();
         DisableButtons();
     }
 }
Exemple #4
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();
     }
 }