コード例 #1
0
        private void button2_Click(object sender, EventArgs e)                              // ОТВЕТНАЯ СТАВКА (DOUBLE)
        {
            int temp;
            int len = p_hand.Length;

            chips       -= ante_bet;
            label10.Text = "Chips = " + Convert.ToString(chips);

            GetCard(this.pictureBox4, k_hand[0]);
            GetCard(this.pictureBox5, k_hand[1]);
            GetCard(this.pictureBox6, k_hand[2]);

            //сортировка карт в руках обоих игроков

            for (int i = 0; i < len - 1; i++)
            {
                for (int j = i + 1; j < len; j++)
                {
                    if (p_hand[i] % 100 > p_hand[j] % 100)
                    {
                        temp      = p_hand[i];
                        p_hand[i] = p_hand[j];
                        p_hand[j] = temp;
                    }
                }
            }

            for (int i = 0; i < len - 1; i++)
            {
                for (int j = i + 1; j < len; j++)
                {
                    if (k_hand[i] % 100 > k_hand[j] % 100)
                    {
                        temp      = k_hand[i];
                        k_hand[i] = k_hand[j];
                        k_hand[j] = temp;
                    }
                }
            }


            //анализ комбинаций

            Combinations combinations = new Combinations();

            highest_combination_p = combinations.combo(p_hand[0], p_hand[1], p_hand[2]);
            highest_combination_k = combinations.combo(k_hand[0], k_hand[1], k_hand[2]);


            Exceptions exceptions = new Exceptions();

            ChipsAnalys chipsAnalys = new ChipsAnalys();

            //Результат игры:

            if (highest_combination_p == highest_combination_k)
            {
                high_card_result = exceptions.uexception(highest_combination_p, p_hand[0], p_hand[1], p_hand[2], k_hand[0], k_hand[1], k_hand[2]);

                //1 - Игрок победил || 2 - пк победил || 3 - ничья || 0 - у крупье нет игры

                if (high_card_result == 1)
                {
                    quantity     = chipsAnalys.hardbets(highest_combination_p, ante_bet, pairplus_bet, high_card_result);
                    label9.Text  = "Победил ИГРОК! Комбинация + Старшая карта ";
                    chips       += quantity;
                    label10.Text = "Chips = " + Convert.ToString(chips);
                }
                else if (high_card_result == 2)
                {
                    label9.Text = "Победил ПК! Комбинация + Старшая карта";

                    label10.Text = "Chips = " + Convert.ToString(chips);
                }
                else if (high_card_result == 3)
                {
                    label9.Text  = "Ничья!";
                    chips       += (ante_bet + pairplus_bet);
                    label10.Text = "Chips = " + Convert.ToString(chips);
                }
                else
                {
                    quantity     = chipsAnalys.hardbets(highest_combination_p, ante_bet, pairplus_bet, high_card_result);
                    label9.Text  = "У крупье нет игры!";
                    chips       += quantity;
                    label10.Text = "Chips = " + Convert.ToString(chips);
                }
            }
            else
            {
                if (highest_combination_p > highest_combination_k)
                {
                    if ((k_hand[0] % 100) >= 12 || (k_hand[1] % 100) >= 12 || (k_hand[2] % 100) >= 12)
                    {
                        high_card_result = 1;
                    }
                    else
                    {
                        high_card_result = 0;
                    }

                    quantity = chipsAnalys.simplebets(highest_combination_p, ante_bet, pairplus_bet, high_card_result);

                    if (highest_combination_p == 2)
                    {
                        congratulations = "Победил ИГРОК! Комб - Пара";
                        chips          += quantity;
                        label10.Text    = "Chips = " + Convert.ToString(chips);
                    }
                    else if (highest_combination_p == 3)
                    {
                        congratulations = "Победил ИГРОК! Комб - Флеш";
                        chips          += quantity;
                        label10.Text    = "Chips = " + Convert.ToString(chips);
                    }
                    else if (highest_combination_p == 4)
                    {
                        congratulations = "Победил ИГРОК! Комб - Стрит";
                        chips          += quantity;
                        label10.Text    = "Chips = " + Convert.ToString(chips);
                    }
                    else if (highest_combination_p == 5)
                    {
                        congratulations = "Победил ИГРОК! Комб - Тройка";
                        chips          += quantity;
                        label10.Text    = "Chips = " + Convert.ToString(chips);
                    }
                    else
                    {
                        congratulations = "Победил ИГРОК! Комб - Стрит-флеш";
                        chips          += quantity;
                        label10.Text    = "Chips = " + Convert.ToString(chips);
                    }
                }
                else
                {
                    if (highest_combination_k == 2)
                    {
                        congratulations = "Победил ПК! Комб - Пара";

                        label10.Text = "Chips = " + Convert.ToString(chips);
                    }
                    else if (highest_combination_k == 3)
                    {
                        congratulations = "Победил ПК! Комб - Флеш";

                        label10.Text = "Chips = " + Convert.ToString(chips);
                    }
                    else if (highest_combination_k == 4)
                    {
                        congratulations = "Победил ПК! Комб - Стрит";

                        label10.Text = "Chips = " + Convert.ToString(chips);
                    }
                    else if (highest_combination_k == 5)
                    {
                        congratulations = "Победил ПК! Комб - Тройка";

                        label10.Text = "Chips = " + Convert.ToString(chips);
                    }
                    else
                    {
                        congratulations = "Победил ПК! Комб - Стрит-флеш";
                        label10.Text    = "Chips = " + Convert.ToString(chips);
                    }
                }

                label9.Text = congratulations;
            }

            (sender as Button).Enabled = false;
            button8.Enabled            = true;
            button3.Enabled            = false;
        }
コード例 #2
0
        private void button2_Click(object sender, EventArgs e)                              // ОТВЕТНАЯ СТАВКА (DOUBLE)
        {
            int temp;
            int len = PHand.Length;

            Chips       -= AnteBet;
            label10.Text = "Chips: " + Convert.ToString(Chips);

            GetCard(this.pictureBox4, DHand[0]);
            GetCard(this.pictureBox5, DHand[1]);
            GetCard(this.pictureBox6, DHand[2]);

            //сортировка карт в руках обоих игроков

            for (int i = 0; i < len - 1; i++)
            {
                for (int j = i + 1; j < len; j++)
                {
                    if (PHand[i] % 100 > PHand[j] % 100)
                    {
                        temp     = PHand[i];
                        PHand[i] = PHand[j];
                        PHand[j] = temp;
                    }
                }
            }

            for (int i = 0; i < len - 1; i++)
            {
                for (int j = i + 1; j < len; j++)
                {
                    if (DHand[i] % 100 > DHand[j] % 100)
                    {
                        temp     = DHand[i];
                        DHand[i] = DHand[j];
                        DHand[j] = temp;
                    }
                }
            }


            //анализ комбинаций

            Combinations combinations = new Combinations();

            PHighestCombination = combinations.Combo(PHand[0], PHand[1], PHand[2]);
            DHighestCombination = combinations.Combo(DHand[0], DHand[1], DHand[2]);


            Exceptions exceptions = new Exceptions();

            ChipsAnalys chipsAnalys = new ChipsAnalys();

            //Результат игры:

            if (PHighestCombination == DHighestCombination)
            {
                HighCardResult = exceptions.UException(PHighestCombination, PHand[0], PHand[1], PHand[2], DHand[0], DHand[1], DHand[2]);

                //1 - Игрок победил || 2 - пк победил || 3 - ничья || 0 - у крупье нет игры

                if (HighCardResult == 1)
                {
                    Quantity     = chipsAnalys.HardBets(PHighestCombination, AnteBet, PairplusBet, HighCardResult);
                    label9.Text  = "PLAYER wins! (Larger denomination/High card)";
                    Chips       += Quantity;
                    label10.Text = "Chips: " + Convert.ToString(Chips);
                }
                else if (HighCardResult == 2)
                {
                    label9.Text  = "Dealer won! (Larger denomination/High card)";
                    label10.Text = "Chips: " + Convert.ToString(Chips);
                }
                else if (HighCardResult == 3)
                {
                    label9.Text  = "Draw!";
                    Chips       += (AnteBet + PairplusBet);
                    label10.Text = "Chips: " + Convert.ToString(Chips);
                }
                else
                {
                    Quantity     = chipsAnalys.HardBets(PHighestCombination, AnteBet, PairplusBet, HighCardResult);
                    label9.Text  = "PLAYER wins! (The dealer has no game)";
                    Chips       += Quantity;
                    label10.Text = "Chips: " + Convert.ToString(Chips);
                }
            }
            else
            {
                if (PHighestCombination > DHighestCombination)
                {
                    if ((DHand[0] % 100) >= 12 || (DHand[1] % 100) >= 12 || (DHand[2] % 100) >= 12)
                    {
                        HighCardResult = 1;
                    }
                    else
                    {
                        HighCardResult = 0;
                    }

                    Quantity = chipsAnalys.SimpleBets(PHighestCombination, AnteBet, PairplusBet, HighCardResult);

                    if (PHighestCombination == 2)
                    {
                        Congratulations = "PLAYER wins! (Combination: One pair)";
                        Chips          += Quantity;
                        label10.Text    = "Chips: " + Convert.ToString(Chips);
                    }
                    else if (PHighestCombination == 3)
                    {
                        Congratulations = "PLAYER wins! (Combination: Flush)";
                        Chips          += Quantity;
                        label10.Text    = "Chips: " + Convert.ToString(Chips);
                    }
                    else if (PHighestCombination == 4)
                    {
                        Congratulations = "PLAYER wins! (Combination: Straight)";
                        Chips          += Quantity;
                        label10.Text    = "Chips: " + Convert.ToString(Chips);
                    }
                    else if (PHighestCombination == 5)
                    {
                        Congratulations = "PLAYER wins! (Combination: Three of a kind)";
                        Chips          += Quantity;
                        label10.Text    = "Chips: " + Convert.ToString(Chips);
                    }
                    else
                    {
                        Congratulations = "PLAYER wins! (Combination: Straight flush)";
                        Chips          += Quantity;
                        label10.Text    = "Chips: " + Convert.ToString(Chips);
                    }
                }
                else
                {
                    if (DHighestCombination == 2)
                    {
                        Congratulations = "Dealer won! (Combination: One pair)";
                        label10.Text    = "Chips: " + Convert.ToString(Chips);
                    }
                    else if (DHighestCombination == 3)
                    {
                        Congratulations = "Dealer won! (Combination: Flush)";
                        label10.Text    = "Chips: " + Convert.ToString(Chips);
                    }
                    else if (DHighestCombination == 4)
                    {
                        Congratulations = "Dealer won! (Combination: Straight)";
                        label10.Text    = "Chips: " + Convert.ToString(Chips);
                    }
                    else if (DHighestCombination == 5)
                    {
                        Congratulations = "Dealer won! (Combination: Three of a kind)";
                        label10.Text    = "Chips: " + Convert.ToString(Chips);
                    }
                    else
                    {
                        Congratulations = "Dealer won! (Combination: Straight flush)";
                        label10.Text    = "Chips: " + Convert.ToString(Chips);
                    }
                }

                label9.Text = Congratulations;
            }
            (sender as Button).Enabled = false;
            button8.Enabled            = true;
            button8.Visible            = true;
            button3.Enabled            = false;
        }