Example #1
0
        public override bool Equals(object obj)
        {
            if (obj.GetType() != typeof(DealScoreExt))
            {
                return(false);
            }
            DealScoreExt ds2 = obj as DealScoreExt;

            if (this.all_players_passed != ds2.all_players_passed)
            {
                return(false);
            }

            if (this.NS_down != ds2.NS_down || this.EW_down != ds2.EW_down)
            {
                return(false);
            }
            if ((this.EW_up == null || this.EW_up.Length == 0) != (ds2.EW_up == null || ds2.EW_up.Length == 0))
            {
                return(false);
            }
            if ((this.NS_up == null || this.NS_up.Length == 0) != (ds2.NS_up == null || ds2.NS_up.Length == 0))
            {
                return(false);
            }

            if (this.EW_up != null && this.EW_up.Length != 0)
            {
                if (this.EW_up.Length != ds2.EW_up.Length)
                {
                    return(false);
                }
                for (int i = 0; i < this.EW_up.Length; i++)
                {
                    if (this.EW_up[i] != ds2.EW_up[i])
                    {
                        return(false);
                    }
                }
            }
            if (this.NS_up != null && this.NS_up.Length != 0)
            {
                if (this.NS_up.Length != ds2.NS_up.Length)
                {
                    return(false);
                }
                for (int i = 0; i < this.NS_up.Length; i++)
                {
                    if (this.NS_up[i] != ds2.NS_up[i])
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
        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;
                        }
                    }
                }
            }
        }
 public static void RobberScoreLight(SimpleScore out_score, DealScoreExt score_ext)
 {
     if (score_ext.IsEmpty())
     {
         out_score.Born = false;
     }
     else
     {
         {
             int iNS = score_ext.NS_down;
             int iEW = score_ext.EW_down;
             if(score_ext.NS_up != null)
             {
                 for (int i = 0; i < score_ext.NS_up.Length; i++)
                 {
                     iNS += score_ext.NS_up[i];
                 }
             }
             if (score_ext.EW_up != null)
             {
                 for (int i = 0; i < score_ext.EW_up.Length; i++)
                 {
                     iEW += score_ext.EW_up[i];
                 }
             }
             out_score.SetScore(iNS, iEW);
         }
     }
 }
 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);
 }
Example #5
0
 public bool Contains(DealScoreExt value)
 {
     return(List.Contains(value));
 }
Example #6
0
 public void Remove(DealScoreExt value)
 {
     List.Remove(value);
 }
Example #7
0
 public void Insert(int index, DealScoreExt value)
 {
     List.Insert(index, value);
 }
Example #8
0
 public int IndexOf(DealScoreExt value)
 {
     return(List.IndexOf(value));
 }
Example #9
0
 public int Add(DealScoreExt value)
 {
     return(List.Add(value));
 }