예제 #1
0
        public void DetachData()
        {
            if (m_robber != null)
            {
                m_robber.UpdateMe -= OnRobberUpdate;
                m_robber           = null;

                this.Invalidate();
            }
        }
예제 #2
0
        public RobberControl()
        {
            InitializeComponent();
            this.brushText   = new SolidBrush(Color.Black);
            this.brushHeader = new SolidBrush(Color.Red);
            this.fontHeader  = new Font(this.Font.Name, this.Font.Size, FontStyle.Bold);

            m_robber = null;

            offset          = new Size(0, 0);  // отступ от клиентской области
            space           = new Size(1, -1); // отступ между линиями по Y и расстояние до верт.разделителя по X
            spaceV_Boundary = 2;               // расстояние до гориз.черты (отступ через черту = 2 * spaceV_Boundary + 1)
            size1           = this.CreateGraphics().MeasureString("00000", this.Font);
            size1.Width     = (this.Width - offset.Width * 2 - space.Width * 2 - 1) / 2;
            height_Header   = (int)this.CreateGraphics().MeasureString("NS", this.fontHeader).Height;
            spaceV_Header   = 4; // расстояние между заголовком и началом линий счета
        }
예제 #3
0
        public void AttachData(Robber r)
        {
            if (m_robber == r)
            {
                return;
            }

            // detach old
            if (m_robber != null)
            {
                m_robber.UpdateMe -= OnRobberUpdate;
                m_robber           = null;
            }

            // attach new
            m_robber           = r;
            m_robber.UpdateMe += OnRobberUpdate;

            this.Invalidate();
        }
예제 #4
0
        public RobberControl()
        {
            InitializeComponent();
            this.brushText = new SolidBrush(Color.Black);
            this.brushHeader = new SolidBrush(Color.Red);
            this.fontHeader = new Font(this.Font.Name, this.Font.Size, FontStyle.Bold);

            m_robber = null;

            offset = new Size(0, 0); // отступ от клиентской области
            space = new Size(1, -1);  // отступ между линиями по Y и расстояние до верт.разделителя по X
            spaceV_Boundary = 2; // расстояние до гориз.черты (отступ через черту = 2 * spaceV_Boundary + 1)
            size1 = this.CreateGraphics().MeasureString("00000", this.Font);
            size1.Width = (this.Width - offset.Width * 2 - space.Width * 2 - 1) / 2;
            height_Header = (int) this.CreateGraphics().MeasureString("NS", this.fontHeader).Height;
            spaceV_Header = 4; // расстояние между заголовком и началом линий счета
        }
예제 #5
0
 public void Insert(int index, Robber value)
 {
     List.Insert(index, value);
 }
예제 #6
0
 public void Remove(Robber value)
 {
     List.Remove(value);
 }
예제 #7
0
 public bool Contains(Robber value)
 {
     return (List.Contains(value));
 }
예제 #8
0
 public int IndexOf(Robber value)
 {
     return (List.IndexOf(value));
 }
예제 #9
0
 public int Add(Robber value)
 {
     return(List.Add(value));
 }
예제 #10
0
 public int Add(Robber value)
 {
     return (List.Add(value));
 }
예제 #11
0
        public void CleanUnnecessaryRDealsInRobber(Robber rob, int robFirstLine)
        {
            // при загрузке данных из БД не очищать роббер!
            if (loadingFromDB)
                return;

            // Найти последнюю сдачу:
            int robdealNo_last = -1;
            for (int i = 0; i < rob.ScoreArray.Count; i++)
            {
                if (rob.WhereCompleted() != -1 && rob.WhereCompleted() == i)
                {
                    robdealNo_last = i;
                    break;
                }
            }

            // Удаление лишних сдач в текущем роббере:
            if (robdealNo_last != -1)
            {
                int dealNo_delete = robdealNo_last + 1;
                while ((rob.ScoreArray.Count - dealNo_delete) > 0)
                {
                    DB_DeleteLine(robFirstLine + dealNo_delete); //даже если неудачно - продолжить цикл
                    DeleteLine(robFirstLine + dealNo_delete);
                }

                // Передвинуть нижние строки
                ReMoveUnderLine(robFirstLine + robdealNo_last);

                // Обновить таблицу
                AutoScroll_Optimize();
                this.Invalidate();
            }
        }
예제 #12
0
 public static void DefineRobberZone(ZoneSwitcher out_zone, Robber rob, int robdealNo)
 {
     out_zone.Zone = rob.WhatZone(robdealNo);
 }
예제 #13
0
 public bool Contains(Robber value)
 {
     return(List.Contains(value));
 }
예제 #14
0
 public static void RobberScore(DealScoreExt out_score_ext, PairSwitcher pair, ZoneSwitcher zone, Contract contract, Result result, bool BonusForWholeRobber, Robber rob, int robdealNo, OnersSwitcher oners)
 {
     RobberScore(out_score_ext, pair, zone, contract, result, BonusForWholeRobber, rob, robdealNo, true, oners);
 }
예제 #15
0
 public void Remove(Robber value)
 {
     List.Remove(value);
 }
예제 #16
0
 public void Insert(int index, Robber value)
 {
     List.Insert(index, value);
 }
예제 #17
0
 public int IndexOf(Robber value)
 {
     return(List.IndexOf(value));
 }
예제 #18
0
        public void AttachData(Robber r)
        {
            if(m_robber == r)
                return;

            // detach old
            if(m_robber != null)
            {
                m_robber.UpdateMe -= OnRobberUpdate;
                m_robber = null;
            }

            // attach new
            m_robber = r;
            m_robber.UpdateMe += OnRobberUpdate;

            this.Invalidate();
        }
예제 #19
0
 void OnRobberUpdate(object sender, Robber.UpdateEventArgs e)
 {
     //if(e.robNo == m_robber.) ?????????????????
         this.Invalidate();
 }
예제 #20
0
        public void DetachData()
        {
            if (m_robber != null)
            {
                m_robber.UpdateMe -= OnRobberUpdate;
                m_robber = null;

                this.Invalidate();
            }
        }
예제 #21
0
        public static void RobberScore(DealScoreExt out_score_ext, PairSwitcher pair, ZoneSwitcher zone, Contract contract, Result result, bool BonusForWholeRobber, Robber rob, int robdealNo, bool useOners, OnersSwitcher oners)
        {
            if (rob.WhereCompleted() != -1 && rob.WhereCompleted() < robdealNo)
            {
                out_score_ext.Clear();
            }
            else if (contract.NoContract)
            {
                out_score_ext.DealWasNotPlayed();
            }
            else if (!pair.IsDefined() || !zone.IsDefined() || !contract.IsDefined() || !result.IsDefined() || (useOners && !oners.IsDefined()))
            {
                out_score_ext.Clear();
            }
            else
            {
                bool inzone = ZoneSwitcher.IsPairInZone(pair.Pair, zone.Zone);
                bool enemy_inzone = ZoneSwitcher.IsPairInZone(pair.Pair == Pairs.EW ? Pairs.NS : Pairs.EW, zone.Zone);
                if (result.Quantity >= 0)
                {
                    // --- Если контракт сыгран ---
                    // Очки за взятки:
                    int score = contract.Quantity * (SmallHelper.WhatTrumpType(contract.Trump) == TrumpType.Minor ? 20 : 30) + (contract.Trump == CardTrump.NT ? 10 : 0);
                    if (contract.Contra)
                        score *= 2;
                    else if (contract.ReContra)
                        score *= 4;
                    // Премия за превышение взяток:
                    ArrayList bonuses = new ArrayList();
                    if (result.Quantity > 0)
                    {
                        if (contract.Contra)
                            bonuses.Add(result.Quantity * (inzone ? 200 : 100));
                        else if (contract.ReContra)
                            bonuses.Add(result.Quantity * (inzone ? 400 : 200));
                        else
                            bonuses.Add(result.Quantity * (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.Contra)
                        bonuses.Add(50);
                    else if (contract.ReContra)
                        bonuses.Add(100);

                    switch (pair.Pair)
                    {
                        case Pairs.EW:
                            out_score_ext.EW_down = score;

                            // Премия за роббер:
                            if (BonusForWholeRobber)
                            {
                                if (rob.WhereCompleted() == robdealNo)
                                    bonuses.Add(enemy_inzone ? 500 : 700);
                            }
                            // Премия за гейм:
                            else
                            {
                                if (rob.WhereCompleted() == robdealNo)
                                    bonuses.Add(500);
                                else if (rob.DoesDealMakeGame(robdealNo))
                                    bonuses.Add(200);
                            }

                            out_score_ext.EW_up = new int[bonuses.Count];
                            for (int i = 0; i < bonuses.Count; i++)
                                out_score_ext.EW_up[i] = (int)bonuses[i];
                            out_score_ext.NS_down = 0;
                            out_score_ext.NS_up = null;
                            break;
                        case Pairs.NS:
                            out_score_ext.NS_down = score;

                            // Премия за роббер:
                            if (BonusForWholeRobber)
                            {
                                if (rob.WhereCompleted() == robdealNo)
                                    bonuses.Add(enemy_inzone ? 500 : 700);
                            }
                            // Премия за гейм:
                            else
                            {
                                if (rob.WhereCompleted() == robdealNo)
                                    bonuses.Add(500);
                                else if (rob.DoesDealMakeGame(robdealNo))
                                    bonuses.Add(200);
                            }

                            out_score_ext.NS_up = new int[bonuses.Count];
                            for (int i = 0; i < bonuses.Count; i++)
                                out_score_ext.NS_up[i] = (int)bonuses[i];
                            out_score_ext.EW_down = 0;
                            out_score_ext.EW_up = null;
                            break;
                    }
                }
                else
                {
                    // --- Если контракт проигран ---
                    int enemy_score = 0;
                    for (int i = -1; i >= result.Quantity; i--)
                    {
                        if (i == -1)
                        {
                            if (contract.Contra)
                                enemy_score += (inzone ? 200 : 100);
                            else if (contract.ReContra)
                                enemy_score += (inzone ? 400 : 200);
                            else
                                enemy_score += (inzone ? 100 : 50);
                        }
                        else
                        {
                            if (contract.Contra)
                                enemy_score += (inzone ? 300 : 200);
                            else if (contract.ReContra)
                                enemy_score += (inzone ? 600 : 400);
                            else
                                enemy_score += (inzone ? 100 : 50);
                        }
                    }
                    switch (pair.Pair)
                    {
                        case Pairs.EW:
                            out_score_ext.EW_down = 0;
                            out_score_ext.EW_up = null;
                            out_score_ext.NS_down = 0;
                            out_score_ext.NS_up = new int[1] { enemy_score };
                            break;
                        case Pairs.NS:
                            out_score_ext.NS_down = 0;
                            out_score_ext.NS_up = null;
                            out_score_ext.EW_down = 0;
                            out_score_ext.EW_up = new int[1] { enemy_score };
                            break;
                    }
                }

                // Премия за онеры !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                if (useOners && oners.Choise != 0)
                {
                    int bonus_for_oners = 0;
                    if (oners.Choise == 1 || oners.Choise == 4) //4o
                        bonus_for_oners = 100;
                    else if (oners.Choise == 2 || oners.Choise == 5) //5o
                        bonus_for_oners = 150;
                    else if (oners.Choise == 3 || oners.Choise == 6) //4A
                        bonus_for_oners = 150;

                    if (oners.Choise >= 1 && oners.Choise <= 3) //премия NS
                    {
                        if (out_score_ext.NS_up == null)
                            out_score_ext.NS_up = new int[] { bonus_for_oners };
                        else
                        {
                            int[] old = out_score_ext.NS_up;
                            out_score_ext.NS_up = new int[old.Count() + 1];
                            for (int i = 0; i < old.Count(); i++)
                                out_score_ext.NS_up[i] = old[i];
                            out_score_ext.NS_up[old.Count()] = bonus_for_oners;
                        }
                    }
                    else if (oners.Choise >= 4 && oners.Choise <= 6) //премия EW
                    {
                        if (out_score_ext.EW_up == null)
                            out_score_ext.EW_up = new int[] { bonus_for_oners };
                        else
                        {
                            int[] old = out_score_ext.EW_up;
                            out_score_ext.EW_up = new int[old.Count() + 1];
                            for (int i = 0; i < old.Count(); i++)
                                out_score_ext.EW_up[i] = old[i];
                            out_score_ext.EW_up[old.Count()] = bonus_for_oners;
                        }
                    }
                }
            }
        }
예제 #22
0
 public void InvalidateRobber(Robber rob)
 {
     //rob.OnUpdate(null, new Robber.UpdateEventArgs(robNo));
     rob.OnUpdate(null, null);
 }
예제 #23
0
 // Подсчет total score роббера
 public static void SetRobberScore(Robber rob, RobberScore robTScore)
 {
     rob.SetTotalScore(robTScore);
 }