Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            i = r.Next(0, 3);
            j = r.Next(0, 12);

            if (Dealer1.Image == null)
            {
                Deck DealOne = new Deck(j, d[i, j]);
                Dealer1.Image   = DealOne.pic;
                Dealer1.Visible = true;

                d[i, j]            = null;
                cd                 = DealOne.GetDealerValue();
                DealCountText.Text = cd.ToString();
            }

            if (Card1.Image == null)
            {
                if (d[i, j] == null)
                {
                    i = r.Next(0, 3);
                    j = r.Next(0, 12);

                    Deck Uno = new Deck(j, d[i, j]);
                    Card1.Image   = Uno.pic;
                    Card1.Visible = true;

                    d[i, j]        = null;
                    c              = Uno.GetValue();
                    CountText.Text = c.ToString();
                }

                else
                {
                    Deck Uno = new Deck(j, d[i, j]);
                    Card1.Image   = Uno.pic;
                    Card1.Visible = true;

                    d[i, j]        = null;
                    c              = Uno.GetValue();
                    CountText.Text = c.ToString();
                }
            }

            else if (Card2.Image == null)
            {
                if (d[i, j] == null)
                {
                    i = r.Next(0, 3);
                    j = r.Next(0, 12);

                    Deck Dos = new Deck(j, d[i, j]);
                    Card2.Image   = Dos.pic;
                    Card2.Visible = true;

                    d[i, j]        = null;
                    c              = Dos.GetValue();
                    CountText.Text = c.ToString();
                }

                else
                {
                    Deck Dos = new Deck(j, d[i, j]);
                    Card2.Image   = Dos.pic;
                    Card2.Visible = true;

                    d[i, j]        = null;
                    c              = Dos.GetValue();
                    CountText.Text = c.ToString();
                }
            }

            else if (Card3.Image == null)
            {
                if (d[i, j] == null)
                {
                    i = r.Next(0, 3);
                    j = r.Next(0, 12);

                    Deck Tres = new Deck(j, d[i, j]);
                    Card3.Image   = Tres.pic;
                    Card3.Visible = true;

                    d[i, j]        = null;
                    c              = Tres.GetValue();
                    CountText.Text = c.ToString();
                }
                else
                {
                    Deck Tres = new Deck(j, d[i, j]);
                    Card3.Image   = Tres.pic;
                    Card3.Visible = true;

                    d[i, j]        = null;
                    c              = Tres.GetValue();
                    CountText.Text = c.ToString();
                }
            }

            else if (Card4.Image == null)
            {
                if (d[i, j] == null)
                {
                    i = r.Next(0, 3);
                    j = r.Next(0, 12);

                    Deck Cuatro = new Deck(j, d[i, j]);
                    Card4.Image   = Cuatro.pic;
                    Card4.Visible = true;

                    d[i, j]        = null;
                    c              = Cuatro.GetValue();
                    CountText.Text = c.ToString();
                }

                else
                {
                    Deck Cuatro = new Deck(j, d[i, j]);
                    Card4.Image   = Cuatro.pic;
                    Card4.Visible = true;

                    d[i, j]        = null;
                    c              = Cuatro.GetValue();
                    CountText.Text = c.ToString();
                }
            }

            else if (Card5.Image == null)
            {
                if (d[i, j] == null)
                {
                    i = r.Next(0, 3);
                    j = r.Next(0, 12);

                    Deck Cinco = new Deck(j, d[i, j]);
                    Card5.Image   = Cinco.pic;
                    Card5.Visible = true;

                    d[i, j]        = null;
                    c              = Cinco.GetValue();
                    CountText.Text = c.ToString();
                }
                else
                {
                    Deck Cinco = new Deck(j, d[i, j]);
                    Card5.Image   = Cinco.pic;
                    Card5.Visible = true;

                    d[i, j]        = null;
                    c              = Cinco.GetValue();
                    CountText.Text = c.ToString();
                }
            }

            else if (Card6.Image == null)
            {
                if (d[i, j] == null)
                {
                    i = r.Next(0, 3);
                    j = r.Next(0, 12);

                    Deck Seis = new Deck(j, d[i, j]);
                    Card6.Image   = Seis.pic;
                    Card6.Visible = true;

                    d[i, j]        = null;
                    c              = Seis.GetValue();
                    CountText.Text = c.ToString();
                }
                else
                {
                    Deck Seis = new Deck(j, d[i, j]);
                    Card6.Image   = Seis.pic;
                    Card6.Visible = true;

                    d[i, j]        = null;
                    c              = Seis.GetValue();
                    CountText.Text = c.ToString();
                }
            }

            else if (Card7.Image == null)
            {
                if (d[i, j] == null)
                {
                    i = r.Next(0, 3);
                    j = r.Next(0, 12);

                    Deck Siete = new Deck(j, d[i, j]);
                    Card7.Image   = Siete.pic;
                    Card7.Visible = true;

                    d[i, j]        = null;
                    c              = Siete.GetValue();
                    CountText.Text = c.ToString();
                }

                else
                {
                    Deck Siete = new Deck(j, d[i, j]);
                    Card7.Image   = Siete.pic;
                    Card7.Visible = true;

                    d[i, j]        = null;
                    c              = Siete.GetValue();
                    CountText.Text = c.ToString();
                }
            }

            else if (Card8.Image == null)
            {
                if (d[i, j] == null)
                {
                    i = r.Next(0, 3);
                    j = r.Next(0, 12);

                    Deck Ocho = new Deck(j, d[i, j]);
                    Card8.Image   = Ocho.pic;
                    Card8.Visible = true;

                    d[i, j]        = null;
                    c              = Ocho.GetValue();
                    CountText.Text = c.ToString();
                }

                else
                {
                    Deck Ocho = new Deck(j, d[i, j]);
                    Card8.Image   = Ocho.pic;
                    Card8.Visible = true;

                    d[i, j]        = null;
                    c              = Ocho.GetValue();
                    CountText.Text = c.ToString();
                }
            }

            if (c > 21)
            {
                GameOver.Image   = (Bitmap)resm.GetObject("DEFEAT");
                GameOver.Visible = true;
            }
        }