public void __LoadDataInTable__(ArrayList arr_data, int data_columns, ArrayList arr_joints, ArrayOfInt widths, ArrayOfInt heights, int headerLinesUp, int headerLinesLeft, int data_height)
        {
            // Таблица
            DATA__arr     = arr_data;
            DATA__columns = data_columns;

            // Объединения
            DATA__joints = arr_joints;

            // Отображение таблицы
            PAINT__columns_widths  = widths;
            PAINT__columns_heights = heights;
            PAINT__data_height     = data_height;
            PAINT__headerLinesUp   = headerLinesUp;
            PAINT__headerLinesLeft = headerLinesLeft;


            // Определение размеров
            total_width = 0;
            for (int i = 0; i < PAINT__columns_widths.Count; i++)
            {
                total_width += (PAINT__columns_widths[i] + 2 * 1);
            }
            total_width += (DATA__columns - 1) * PAINT__border_delay + 2 * (PAINT__border_delay + 1);
            total_height = 0;
            for (int i = 0; i < DATA__arr.Count; i++)
            {
                total_height += (i < PAINT__columns_heights.Count ? PAINT__columns_heights[i] : PAINT__data_height) + 2 * 1;
            }
            total_height += (DATA__arr.Count - 1) * PAINT__border_delay + 2 * (PAINT__border_delay + 1);

            // Новые размеры:
            this.Width  = total_width;
            this.Height = total_height;
        }
        // Решение зависимостей
        public static ArrayOfInt SolveDependences(ArrayOfArrayOfInt a)
        {
            ArrayOfInt b = new ArrayOfInt();

            while (true)
            {
                int solved = 0;
                for (int i = 0; i < a.Count; i++)
                {
                    if (!b.Contains(i) && IsFreeOfDependences(i, a, b))
                    {
                        solved++;
                        b.Add(i);
                    }
                }
                if (a.Count == b.Count)
                {
                    break;
                }
                else if (solved == 0)
                {
                    throw new Exception("Невозможно распутать зависимости!");
                }
            }
            return(b);
        }
        void OnHelp_IMPToVP(object sender, EventArgs e)
        {
            // Подготовить данные:
            ArrayList arr_data = new ArrayList();

            arr_data.Add(new ArrayList());
            (arr_data[0] as ArrayList).Add("VP");
            (arr_data[0] as ArrayList).Add("IMP");
            arr_data.Add(new ArrayList());
            (arr_data[1] as ArrayList).Add(null);

            Dictionary <int, ArrayOfInt> .KeyCollection.Enumerator keys_en = BridgeGameScoring.VP_Table.Keys.GetEnumerator();
            while (keys_en.MoveNext())
            {
                (arr_data[1] as ArrayList).Add(keys_en.Current + "x");
            }

            for (int i = 0; i < BridgeGameScoring.vp_total / 2; i++)
            {
                arr_data.Add(new ArrayList());
                (arr_data[i + 2] as ArrayList).Add((BridgeGameScoring.vp_total / 2 - i) + ":" + ((BridgeGameScoring.vp_total / 2 + i) > BridgeGameScoring.vp_max ? BridgeGameScoring.vp_max : (BridgeGameScoring.vp_total / 2 + i)));
            }

            keys_en = BridgeGameScoring.VP_Table.Keys.GetEnumerator();
            while (keys_en.MoveNext())
            {
                for (int j = 0; j < BridgeGameScoring.vp_total / 2; j++)
                {
                    (arr_data[j + 2] as ArrayList).Add((j == 0 ? 0 : (BridgeGameScoring.VP_Table[keys_en.Current])[j - 1] + 1) + "-" + (BridgeGameScoring.VP_Table[keys_en.Current])[j]);
                }
            }


            ArrayList arr_joints = new ArrayList();

            arr_joints.Add(new ShporaControl.table_joint(0, 0, 1, 2));
            arr_joints.Add(new ShporaControl.table_joint(1, 0, BridgeGameScoring.VP_Table.Keys.Count, 1));

            ArrayOfInt widths = new ArrayOfInt();

            widths.Add(50);
            for (int i = 0; i < BridgeGameScoring.VP_Table.Keys.Count; i++)
            {
                widths.Add(46);
            }
            widths[widths.Count - 1] = 54;
            ArrayOfInt heights = new ArrayOfInt();

            heights.Add(new int[] { 24 });

            // Показать форму:
            ShporaForm f = new ShporaForm();

            f.t.Font     = new System.Drawing.Font("Tahoma", 6, System.Drawing.FontStyle.Regular);
            f.t.FontBold = new System.Drawing.Font("Tahoma", 6, System.Drawing.FontStyle.Bold);
            f.t.__LoadDataInTable__(arr_data, BridgeGameScoring.VP_Table.Keys.Count + 1, arr_joints, widths, heights, 2, 0, 20);
            f.t.Location = new System.Drawing.Point((f.Width - f.t.Width) / 2, f.label.Bottom + 5);
            f.label.Text = "Перевод IMP в VP";
            f.ShowDialog();
        }
        public static bool IsFreeOfDependences(int x, ArrayOfArrayOfInt a, ArrayOfInt b)
        {
            int free = 0;

            for (int j = 0; j < a[x].Count; j++)
            {
                if (b.Contains(a[x, j]))
                {
                    free++;
                }
            }
            return(a[x].Count == free);
        }
        void OnHelp_CompensationMoscow(object sender, EventArgs e)
        {
            // Подготовить данные:
            ArrayList arr_data = new ArrayList();

            arr_data.Add(new ArrayList());
            (arr_data[0] as ArrayList).Add("PC");
            (arr_data[0] as ArrayList).Add("до зоны");
            (arr_data[0] as ArrayList).Add("в зоне");
            for (int i = 20; i <= 36; i++)
            {
                int index = arr_data.Add(new ArrayList());
                if (i == 36)
                {
                    (arr_data[index] as ArrayList).Add("36+");
                }
                else
                {
                    (arr_data[index] as ArrayList).Add(i);
                }
                (arr_data[index] as ArrayList).Add(BridgeGameScoring.Compens_Moscow(i, false));
                (arr_data[index] as ArrayList).Add(BridgeGameScoring.Compens_Moscow(i, true));
            }

            ArrayList arr_joints = new ArrayList();

            ArrayOfInt widths = new ArrayOfInt();

            widths.Add(new int[] { 40, 72, 70 });
            ArrayOfInt heights = new ArrayOfInt();

            heights.Add(new int[] { 24 });

            // Показать форму:
            ShporaForm f = new ShporaForm();

            f.t.Font     = new System.Drawing.Font("Tahoma", 6, System.Drawing.FontStyle.Regular);
            f.t.FontBold = new System.Drawing.Font("Tahoma", 6, System.Drawing.FontStyle.Bold);
            f.t.__LoadDataInTable__(arr_data, 3, arr_joints, widths, heights, 1, 0, 20);
            f.t.Location = new System.Drawing.Point((f.Width - f.t.Width) / 2, f.label.Bottom + 5);
            f.label.Text = "Московская компенсация";
            f.ShowDialog();
        }
        void CountScore()
        {
            bool ready = true;

            bool inzone            = checkBox1.Checked;
            int  contract_quantity = 0;

            if (comboBox1.SelectedIndex == -1)
            {
                ready = false;
            }
            else
            {
                contract_quantity = int.Parse(comboBox1.Items[comboBox1.SelectedIndex] as string);
            }
            CardTrump contract_trump = CardTrump.NotYetDefined;

            if (comboBox2.SelectedIndex == -1)
            {
                ready = false;
            }
            else
            {
                string trump_str = (string)comboBox2.Items[comboBox2.SelectedIndex];
                switch (trump_str)
                {
                case "Hearts":
                    contract_trump = CardTrump.Hearts;
                    break;

                case "Diamonds":
                    contract_trump = CardTrump.Diamonds;
                    break;

                case "Clubs":
                    contract_trump = CardTrump.Clubs;
                    break;

                case "Spades":
                    contract_trump = CardTrump.Spades;
                    break;

                case "NT":
                    contract_trump = CardTrump.NT;
                    break;
                }
            }
            bool contract_double   = checkBox2.Checked;
            bool contract_redouble = checkBox3.Checked;
            int  result            = -1;

            if (comboBox3.SelectedIndex == -1)
            {
                ready = false;
            }
            else
            {
                result = int.Parse(comboBox3.Items[comboBox3.SelectedIndex] as string);
            }


            //---------------------------------
            int score = 0;
            int bonus = 0;

            if (ready)
            {
                int result_diff = result - (6 + contract_quantity);
                // ----------------------------- robber ---------------------------
                if (IsRobber)
                {
                    // --- Если контракт сыгран ---
                    if (result_diff >= 0)
                    {
                        // Очки за взятки:
                        score = contract_quantity * (SmallHelper.WhatTrumpType(contract_trump) == TrumpType.Minor ? 20 : 30) + (contract_trump == CardTrump.NT ? 10 : 0);
                        if (contract_double)
                        {
                            score *= 2;
                        }
                        else if (contract_redouble)
                        {
                            score *= 4;
                        }
                        // Премия за превышение взяток:
                        ArrayOfInt bonuses = new ArrayOfInt();
                        if (result_diff > 0)
                        {
                            if (contract_double)
                            {
                                bonuses.Add(result_diff * (inzone ? 200 : 100));
                            }
                            else if (contract_redouble)
                            {
                                bonuses.Add(result_diff * (inzone ? 400 : 200));
                            }
                            else
                            {
                                bonuses.Add(result_diff * (SmallHelper.WhatTrumpType(contract_trump) == TrumpType.Minor ? 20 : 30));
                            }
                        }
                        if (contract_quantity == 6) //малый шлем
                        {
                            bonuses.Add(inzone ? 750 : 500);
                        }
                        else if (contract_quantity == 7) //большой шлем
                        {
                            bonuses.Add(inzone ? 1500 : 1000);
                        }
                        // Дополнительная премия за оскорбление:
                        if (contract_double)
                        {
                            bonuses.Add(50);
                        }
                        else if (contract_redouble)
                        {
                            bonuses.Add(100);
                        }

                        // Посчитать сумму бонусов
                        for (int i = 0; i < bonuses.Count; i++)
                        {
                            bonus += bonuses[i];
                        }
                    }
                    // --- Если контракт проигран ---
                    else
                    {
                        int enemy_score = 0;
                        for (int i = -1; i >= result_diff; i--)
                        {
                            if (i == -1)
                            {
                                if (contract_double)
                                {
                                    enemy_score += (inzone ? 200 : 100);
                                }
                                else if (contract_redouble)
                                {
                                    enemy_score += (inzone ? 400 : 200);
                                }
                                else
                                {
                                    enemy_score += (inzone ? 100 : 50);
                                }
                            }
                            else
                            {
                                if (contract_double)
                                {
                                    enemy_score += (inzone ? 300 : 200);
                                }
                                else if (contract_redouble)
                                {
                                    enemy_score += (inzone ? 600 : 400);
                                }
                                else
                                {
                                    enemy_score += (inzone ? 100 : 50);
                                }
                            }
                        }

                        bonus = -enemy_score;
                    }
                }
                // ----------------------------- sport ---------------------------
                else
                {
                    // --- Если контракт сыгран ---
                    if (result_diff >= 0)
                    {
                        // Очки за взятки:
                        score = contract_quantity * (SmallHelper.WhatTrumpType(contract_trump) == TrumpType.Minor ? 20 : 30) + (contract_trump == CardTrump.NT ? 10 : 0);
                        if (contract_double)
                        {
                            score *= 2;
                        }
                        else if (contract_redouble)
                        {
                            score *= 4;
                        }
                        // Премия за превышение взяток:
                        if (result_diff > 0)
                        {
                            if (contract_double)
                            {
                                bonus += result_diff * (inzone ? 200 : 100);
                            }
                            else if (contract_redouble)
                            {
                                bonus += result_diff * (inzone ? 400 : 200);
                            }
                            else
                            {
                                bonus += result_diff * (SmallHelper.WhatTrumpType(contract_trump) == TrumpType.Minor ? 20 : 30);
                            }
                        }
                        if (contract_quantity == 6) //малый шлем
                        {
                            bonus += (inzone ? 750 : 500);
                        }
                        if (contract_quantity == 7) //большой шлем
                        {
                            bonus += (inzone ? 1500 : 1000);
                        }
                        if (score >= 100) //за гейм
                        {
                            bonus += (inzone ? 500 : 300);
                        }
                        else //за частичную запись
                        {
                            bonus += 50;
                        }
                        // Дополнительная премия:
                        if (contract_double)
                        {
                            bonus += 50;
                        }
                        else if (contract_redouble)
                        {
                            bonus += 100;
                        }
                    }
                    // --- Если контракт проигран ---
                    else
                    {
                        int enemy_score = 0;
                        for (int i = -1; i >= result_diff; i--)
                        {
                            if (i == -1)
                            {
                                if (contract_double)
                                {
                                    enemy_score += (inzone ? 200 : 100);
                                }
                                else if (contract_redouble)
                                {
                                    enemy_score += (inzone ? 400 : 200);
                                }
                                else
                                {
                                    enemy_score += (inzone ? 100 : 50);
                                }
                            }
                            else if (i == -2 || i == -3)
                            {
                                if (contract_double)
                                {
                                    enemy_score += (inzone ? 300 : 200);
                                }
                                else if (contract_redouble)
                                {
                                    enemy_score += (inzone ? 600 : 400);
                                }
                                else
                                {
                                    enemy_score += (inzone ? 100 : 50);
                                }
                            }
                            else
                            {
                                if (contract_double)
                                {
                                    enemy_score += (inzone ? 300 : 300);
                                }
                                else if (contract_redouble)
                                {
                                    enemy_score += (inzone ? 600 : 600);
                                }
                                else
                                {
                                    enemy_score += (inzone ? 100 : 50);
                                }
                            }
                        }

                        bonus = -enemy_score;
                    }
                }
            }
            //---------------------------------



            if (IsRobber)
            {
                label6.Text = score.ToString();
                label7.Text = bonus.ToString();
            }
            else
            {
                label6.Text = (score + bonus).ToString();
            }
        }
        void OnHelp_CompensationEurope(object sender, EventArgs e)
        {
            // Подготовить данные:
            ArrayList arr_data = new ArrayList();

            arr_data.Add(new ArrayList());
            (arr_data[0] as ArrayList).Add("PC");
            (arr_data[0] as ArrayList).Add("до зоны");
            (arr_data[0] as ArrayList).Add(null);
            (arr_data[0] as ArrayList).Add(null);
            (arr_data[0] as ArrayList).Add("в зоне");
            (arr_data[0] as ArrayList).Add(null);
            (arr_data[0] as ArrayList).Add(null);
            arr_data.Add(new ArrayList());
            (arr_data[1] as ArrayList).Add(null);
            (arr_data[1] as ArrayList).Add("без\nфита");
            (arr_data[1] as ArrayList).Add("1\nфит");
            (arr_data[1] as ArrayList).Add("2\nфита");
            (arr_data[1] as ArrayList).Add("без\nфита");
            (arr_data[1] as ArrayList).Add("1\nфит");
            (arr_data[1] as ArrayList).Add("2\nфита");
            for (int i = 20; i <= 37; i++)
            {
                int index = arr_data.Add(new ArrayList());
                if (i == 37)
                {
                    (arr_data[index] as ArrayList).Add("36+");
                }
                else if (i == 23)
                {
                    (arr_data[index] as ArrayList).Add("23 (<)");
                }
                else if (i < 23)
                {
                    (arr_data[index] as ArrayList).Add(i);
                }
                else
                {
                    (arr_data[index] as ArrayList).Add(i - 1);
                }
                (arr_data[index] as ArrayList).Add(BridgeGameScoring.Compens_Europe((i <= 23 ? i : i - 1), 0, false, i == 23));
                (arr_data[index] as ArrayList).Add(BridgeGameScoring.Compens_Europe((i <= 23 ? i : i - 1), 1, false, i == 23));
                (arr_data[index] as ArrayList).Add(BridgeGameScoring.Compens_Europe((i <= 23 ? i : i - 1), 2, false, i == 23));
                (arr_data[index] as ArrayList).Add(BridgeGameScoring.Compens_Europe((i <= 23 ? i : i - 1), 0, true, i == 23));
                (arr_data[index] as ArrayList).Add(BridgeGameScoring.Compens_Europe((i <= 23 ? i : i - 1), 1, true, i == 23));
                (arr_data[index] as ArrayList).Add(BridgeGameScoring.Compens_Europe((i <= 23 ? i : i - 1), 2, true, i == 23));
            }

            ArrayList arr_joints = new ArrayList();

            arr_joints.Add(new ShporaControl.table_joint(1, 0, 3, 1));
            arr_joints.Add(new ShporaControl.table_joint(4, 0, 3, 1));
            arr_joints.Add(new ShporaControl.table_joint(0, 0, 1, 2));

            ArrayOfInt widths = new ArrayOfInt();

            widths.Add(new int[] { 54, 46, 46, 46, 46, 46, 46 });
            ArrayOfInt heights = new ArrayOfInt();

            heights.Add(new int[] { 22, 34 });

            // Показать форму:
            ShporaForm f = new ShporaForm();

            f.t.Font     = new System.Drawing.Font("Tahoma", 6, System.Drawing.FontStyle.Regular);
            f.t.FontBold = new System.Drawing.Font("Tahoma", 6, System.Drawing.FontStyle.Bold);
            f.t.__LoadDataInTable__(arr_data, 7, arr_joints, widths, heights, 2, 0, 20);
            f.t.Location = new System.Drawing.Point((f.Width - f.t.Width) / 2, f.label.Bottom + 5);
            f.label.Text = "Европейская компенсация";
            f.ShowDialog();
        }
        void OnHelp_ScoreToIMP(object sender, EventArgs e)
        {
            // Подготовить данные:
            ArrayList arr_data = new ArrayList();

            arr_data.Add(new ArrayList());
            (arr_data[0] as ArrayList).Add("Очки");
            (arr_data[0] as ArrayList).Add("IMP");

            int index = arr_data.Add(new ArrayList());

            (arr_data[index] as ArrayList).Add("20-40");
            (arr_data[index] as ArrayList).Add(1);

            index = arr_data.Add(new ArrayList());
            (arr_data[index] as ArrayList).Add("50-80");
            (arr_data[index] as ArrayList).Add(2);

            index = arr_data.Add(new ArrayList());
            (arr_data[index] as ArrayList).Add("90-120");
            (arr_data[index] as ArrayList).Add(3);

            index = arr_data.Add(new ArrayList());
            (arr_data[index] as ArrayList).Add("130-160");
            (arr_data[index] as ArrayList).Add(4);

            index = arr_data.Add(new ArrayList());
            (arr_data[index] as ArrayList).Add("170-210");
            (arr_data[index] as ArrayList).Add(5);

            index = arr_data.Add(new ArrayList());
            (arr_data[index] as ArrayList).Add("220-260");
            (arr_data[index] as ArrayList).Add(6);

            index = arr_data.Add(new ArrayList());
            (arr_data[index] as ArrayList).Add("270-310");
            (arr_data[index] as ArrayList).Add(7);

            index = arr_data.Add(new ArrayList());
            (arr_data[index] as ArrayList).Add("320-360");
            (arr_data[index] as ArrayList).Add(8);

            index = arr_data.Add(new ArrayList());
            (arr_data[index] as ArrayList).Add("370-420");
            (arr_data[index] as ArrayList).Add(9);

            index = arr_data.Add(new ArrayList());
            (arr_data[index] as ArrayList).Add("430-490");
            (arr_data[index] as ArrayList).Add(10);

            index = arr_data.Add(new ArrayList());
            (arr_data[index] as ArrayList).Add("500-590");
            (arr_data[index] as ArrayList).Add(11);

            index = arr_data.Add(new ArrayList());
            (arr_data[index] as ArrayList).Add("600-740");
            (arr_data[index] as ArrayList).Add(12);

            index = arr_data.Add(new ArrayList());
            (arr_data[index] as ArrayList).Add("750-890");
            (arr_data[index] as ArrayList).Add(13);

            index = arr_data.Add(new ArrayList());
            (arr_data[index] as ArrayList).Add("900-1090");
            (arr_data[index] as ArrayList).Add(14);

            index = arr_data.Add(new ArrayList());
            (arr_data[index] as ArrayList).Add("1100-1290");
            (arr_data[index] as ArrayList).Add(15);

            index = arr_data.Add(new ArrayList());
            (arr_data[index] as ArrayList).Add("1300-1490");
            (arr_data[index] as ArrayList).Add(16);

            index = arr_data.Add(new ArrayList());
            (arr_data[index] as ArrayList).Add("1500-1740");
            (arr_data[index] as ArrayList).Add(17);

            index = arr_data.Add(new ArrayList());
            (arr_data[index] as ArrayList).Add("1750-1990");
            (arr_data[index] as ArrayList).Add(18);

            index = arr_data.Add(new ArrayList());
            (arr_data[index] as ArrayList).Add("2000-2240");
            (arr_data[index] as ArrayList).Add(19);

            index = arr_data.Add(new ArrayList());
            (arr_data[index] as ArrayList).Add("2250-2490");
            (arr_data[index] as ArrayList).Add(20);

            index = arr_data.Add(new ArrayList());
            (arr_data[index] as ArrayList).Add("2500-2990");
            (arr_data[index] as ArrayList).Add(21);

            index = arr_data.Add(new ArrayList());
            (arr_data[index] as ArrayList).Add("3000-3490");
            (arr_data[index] as ArrayList).Add(22);

            index = arr_data.Add(new ArrayList());
            (arr_data[index] as ArrayList).Add("3500-3990");
            (arr_data[index] as ArrayList).Add(23);

            index = arr_data.Add(new ArrayList());
            (arr_data[index] as ArrayList).Add("4000+");
            (arr_data[index] as ArrayList).Add(24);

            ArrayList arr_joints = new ArrayList();

            ArrayOfInt widths = new ArrayOfInt();

            widths.Add(new int[] { 100, 50 });
            ArrayOfInt heights = new ArrayOfInt();

            heights.Add(new int[] { 20 });

            // Показать форму:
            ShporaForm f = new ShporaForm();

            f.t.Font     = new System.Drawing.Font("Tahoma", 6, System.Drawing.FontStyle.Regular);
            f.t.FontBold = new System.Drawing.Font("Tahoma", 6, System.Drawing.FontStyle.Bold);
            f.t.__LoadDataInTable__(arr_data, 2, arr_joints, widths, heights, 1, 0, 16);
            f.t.Location = new System.Drawing.Point((f.Width - f.t.Width) / 2, f.label.Bottom + 5);
            f.label.Text = "Перевод очков в IMP";
            f.ShowDialog();
        }
 public bool Contains(ArrayOfInt value)
 {
     return(List.Contains(value));
 }
Exemple #10
0
 public void Remove(ArrayOfInt value)
 {
     List.Remove(value);
 }
Exemple #11
0
 public void Insert(int index, ArrayOfInt value)
 {
     List.Insert(index, value);
 }
Exemple #12
0
 public int IndexOf(ArrayOfInt value)
 {
     return(List.IndexOf(value));
 }
Exemple #13
0
 public int Add(ArrayOfInt value)
 {
     return(List.Add(value));
 }