Exemplo n.º 1
0
        private void HitButton_Click(object sender, EventArgs e)
        {
            // Deal card
            Card c = TwentyOne_Game.DealOneCardTo(0);

            // If ace is dealt
            if (c.GetFaceValue() == FaceValue.Ace)
            {
                DialogResult result = MessageBox.Show("Count Ace as one?", "", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    TwentyOne_Game.IncrementNumOfUserAcesWithValueOne();
                }
            }

            // If player has busted
            if (TwentyOne_Game.CalculateHandTotal(0) > 21)
            {
                // Update button enabled values
                DealBtn.Enabled  = true;
                HitBtn.Enabled   = false;
                StandBtn.Enabled = false;

                // Show busted label
                BustedPlayer.Visible = true;
            }

            // Update the GUI
            UpdateGUI();
        }
Exemplo n.º 2
0
        }// End UpdateGUI

        private void DealButton_Click(object sender, EventArgs e)
        {
            // Set up a new game
            TwentyOne_Game.SetUpGame();

            // Deal cards and then display them
            for (int i = 0; i < 2; i++)
            {
                TwentyOne_Game.DealOneCardTo(0);    // Deal two cards to player
                TwentyOne_Game.DealOneCardTo(1);    // Deal two cards to dealer
            }
            DisplayGuiHand(TwentyOne_Game.GetHand(0), playerTable);
            DisplayGuiHand(TwentyOne_Game.GetHand(1), dealerTable);

            // Update labels
            AceCountOne.Text     = TwentyOne_Game.GetNumOfUserAcesWithValueOne().ToString();
            BustedDealer.Visible = false;
            BustedPlayer.Visible = false;
            PointsPlayer.Text    = TwentyOne_Game.CalculateHandTotal(0).ToString();
            PointsPlayer.Visible = true;
            PointsDealer.Text    = TwentyOne_Game.CalculateHandTotal(1).ToString();
            PointsDealer.Visible = true;

            // Enable and disable buttons
            StandBtn.Enabled = true;
            HitBtn.Enabled   = true;
            DealBtn.Enabled  = false;
        }