Beispiel #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            //odkrycie kart
            if (Computer.money > 0 || Computer.bet > 0)
            {
                Computer.cards[0].reverse = false;
                Computer.cards[1].reverse = false;
                pictureBox8.Image         = Computer.cards[0].image;
                pictureBox9.Image         = Computer.cards[1].image;
            }
            Dealer.cards[1].reverse = false;
            pictureBox16.Image      = Dealer.cards[1].image;


            //skroty
            int hp = Human.get_points(Human.cards);
            int cp = Computer.get_points(Computer.cards);
            int dp = Dealer.get_points(Dealer.cards);
            int hs = Human.get_points(Human.split_cards);
            int cs = Computer.get_points(Computer.split_cards);


            //komputer dobiera karty
            if (Computer.money > 0 || Computer.bet > 0)
            {
                bool split = false;
                if (Computer.cards[0].value == Computer.cards[1].value && Computer.money >= Computer.bet && Computer.get_points(Computer.split_cards) == 0)
                {
                    split = Computer.is_split(Computer, Dealer);
                }
                if (split)
                {
                    do_split();
                }

                if (Computer.cards[0].value == 1 || Computer.cards[1].value == 1)
                {
                    int r = rnd.Next(tmp_cards.Count);
                    Computer.do_ace(tmp_cards[r], Computer, Dealer);
                }

                while ((cp = Computer.get_points(Computer.cards)) < 22)
                {
                    if (Computer.evaluate(Computer, Dealer))
                    {
                        break;
                    }

                    int r = rnd.Next(tmp_cards.Count);
                    Computer.draw(tmp_cards[r], Computer.counter);
                    tmp_cards.Remove(tmp_cards[r]);
                    Computer.counter++;
                }
            }

            label2.Text = "Kapitał Gracza Komputerowego " + Computer.money.ToString() + "$" + "\nStawka " + Computer.bet.ToString() + "$   " + Computer.get_points(Computer.cards).ToString() + "pkt";
            if (Computer.get_points(Computer.cards) > 21)
            {
                label2.Text += " FURA";
            }

            //dealer dobiera karty
            while ((dp = Dealer.get_points(Dealer.cards)) < 17)
            {
                int r = rnd.Next(tmp_cards.Count);
                Dealer.draw(tmp_cards[r], Dealer.counter);
                tmp_cards.Remove(tmp_cards[r]);
                Dealer.counter++;
            }
            label3.Text = "Krupier\n" + Dealer.get_points(Dealer.cards).ToString() + "pkt";

            //czlowiek

            X tmp = Dealer.Results(Human, Dealer, true);

            if (tmp == X.w)
            {
                label8.Text += "\nWygrana +" + (2 * Human.bet).ToString() + "$";
            }
            else if (tmp == X.r)
            {
                label8.Text += "\nRemis, zwrot " + Human.bet.ToString() + "$";
            }
            else if (tmp == X.p)
            {
                label8.Text += "\nPrzegrana -" + Human.bet.ToString() + "$";
            }
            else
            {
                label8.Text = null;
            }

            tmp         = Dealer.Results(Human, Dealer);
            label1.Text = "Mój kapitał " + Human.money.ToString() + "$" + "\nStawka " + Human.bet.ToString() + "$   " + Human.get_points(Human.cards).ToString() + "pkt";

            if (tmp == X.w)
            {
                label1.Text += "\nWygrana +" + (2 * Human.bet).ToString() + "$";
            }
            else if (tmp == X.r)
            {
                label1.Text += "\nRemis, zwrot " + Human.bet.ToString() + "$";
            }
            else if (tmp == X.p)
            {
                label1.Text += "\nPrzegrana -" + Human.bet.ToString() + "$";
            }
            else
            {
                label1.Text = null;
            }



            //komputer
            tmp = Dealer.Results(Computer, Dealer, true);
            if (tmp == X.w)
            {
                label9.Text += "\nWygrana +" + (2 * Computer.bet).ToString() + "$";
            }
            else if (tmp == X.r)
            {
                label9.Text += "\nRemis, zwrot " + Computer.bet.ToString() + "$";
            }
            else if (tmp == X.p)
            {
                label9.Text += "\nPrzegrana -" + Computer.bet.ToString() + "$";
            }
            else
            {
                label9.Text = null;
            }

            tmp = Dealer.Results(Computer, Dealer);
            if (tmp == X.w)
            {
                label2.Text += "\nWygrana +" + (2 * Computer.bet).ToString() + "$";
            }
            else if (tmp == X.r)
            {
                label2.Text += "\nRemis, zwrot " + Computer.bet.ToString() + "$";
            }
            else if (tmp == X.p)
            {
                label2.Text += "\nPrzegrana -" + Computer.bet.ToString() + "$";
            }
            else
            {
                label2.Text = null;
            }


            button1.Enabled = false;
            button2.Enabled = false;
            button3.Enabled = false;
            button4.Enabled = false;
            button9.Enabled = false;
            if (Human.money < 1)
            {
                button7.Enabled = true;
                label1.Text     = "KONIEC GRY";
            }
            else
            {
                textBox1.Clear();
                textBox1.Enabled = true;
                button8.Enabled  = true;
            }

            do_color();
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //kopiowanie kart
            tmp_cards.Clear();
            for (int i = 0; i < 52; i++)
            {
                Card x = Cards[i];
                tmp_cards.Add(x);
            }

            //rozdanie kart
            int r;

            for (int i = 0; i < 3; i++)
            {
                if (Players[i].money < 1 && Players[i].bet == 0)
                {
                    continue;
                }
                for (int j = 0; j < 2; j++)
                {
                    r = rnd.Next(tmp_cards.Count);

                    //test

                    /*
                     * if (i == 1)
                     *  r = 4;
                     * if (i == 1 && j == 1)
                     *  r = 15;
                     * // if(i==2 && j==1)
                     * // r = 4;
                     */

                    Players[i].cards.Add(tmp_cards[r]);
                    tmp_cards.Remove(tmp_cards[r]);
                    Players[i].pic[j].Image = Players[i].cards[j].image;
                }
            }
            //ukrycie kart
            if (Computer.money > 0 || Computer.bet > 0)
            {
                Computer.cards[0].reverse_image = Computer.cards[0].image;
                Computer.cards[1].reverse_image = Computer.cards[0].image;
                Computer.cards[0].reverse       = true;
                Computer.cards[1].reverse       = true;
                pictureBox8.Image = BJ.Properties.Resources.rewers;
                pictureBox9.Image = BJ.Properties.Resources.rewers;
            }
            Dealer.cards[1].reverse_image = Dealer.cards[0].image;
            pictureBox16.Image            = BJ.Properties.Resources.rewers;
            Dealer.cards[1].reverse       = true;

            //porzadki
            label1.Text += "   " + Human.get_points(Human.cards).ToString() + "pkt";
            if (Computer.money > 0 || Computer.bet > 0 || Computer.bet > 0)
            {
                label2.Text = "Kapitał Gracza Komputerowego " + Computer.money.ToString() + "$" + "\nStawka " + Computer.bet.ToString() + "$   " + Computer.get_points(Computer.cards).ToString() + "pkt";
            }
            else
            {
                label2.Text = null;
            }
            label3.Text    += Dealer.get_points(Dealer.cards).ToString() + "pkt";
            button1.Enabled = false;
            button2.Enabled = true;
            button3.Enabled = true;
            if (Human.money >= Human.bet)
            {
                button9.Enabled = true;
            }

            if (Human.cards[0].value == Human.cards[1].value && Human.money >= Human.bet)
            {
                button4.Enabled = true;
            }

            do_color();
        }