Ejemplo n.º 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;
            }
        }
Ejemplo n.º 2
0
        private void Done_Click(object sender, EventArgs e)
        {
            Deck.Enabled = false;
            DealerGetCards : while (cd <= 16)
            {
                if (Dealer2.Image == null)
                {
                    i = r.Next(0, 3);
                    j = r.Next(0, 12);
                    while (d[i, j] == null)
                    {
                        i = r.Next(0, 3);
                        j = r.Next(0, 12);
                    }

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

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

                    goto DealerGetCards;
                }

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

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

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

                    goto DealerGetCards;
                }
                else if (Dealer4.Image == null)
                {
                    i = r.Next(0, 3);
                    j = r.Next(0, 12);
                    while (d[i, j] == null)
                    {
                        i = r.Next(0, 3);
                        j = r.Next(0, 12);
                    }

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

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

                    goto DealerGetCards;
                }
                else if (Dealer5.Image == null)
                {
                    i = r.Next(0, 3);
                    j = r.Next(0, 12);
                    while (d[i, j] == null)
                    {
                        i = r.Next(0, 3);
                        j = r.Next(0, 12);
                    }

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

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

                    goto DealerGetCards;
                }
                else if (Dealer6.Image == null)
                {
                    i = r.Next(0, 3);
                    j = r.Next(0, 12);
                    while (d[i, j] == null)
                    {
                        i = r.Next(0, 3);
                        j = r.Next(0, 12);
                    }

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

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

                    goto DealerGetCards;
                }
                else if (Dealer7.Image == null)
                {
                    i = r.Next(0, 3);
                    j = r.Next(0, 12);
                    while (d[i, j] == null)
                    {
                        i = r.Next(0, 3);
                        j = r.Next(0, 12);
                    }

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

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

                    goto DealerGetCards;
                }
                else if (Dealer8.Image == null)
                {
                    i = r.Next(0, 3);
                    j = r.Next(0, 12);
                    while (d[i, j] == null)
                    {
                        i = r.Next(0, 3);
                        j = r.Next(0, 12);
                    }

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

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

                    goto DealerGetCards;
                }
            }

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