示例#1
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;
                        }
                    }
                }
            }
        }
示例#2
0
 // Если контракт "ВСЕ ПАС", пара - пусто
 public static void NoPairIfNoContract(PairSwitcher out_pair, Contract contract)
 {
     if (contract != null && contract.NoContract)
     {
         out_pair.Pair = Pairs.NotDefinedYet;
     }
 }
示例#3
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);
 }
示例#4
0
        //Компенсация  !!!!! С ФИТАМИ !!!!!
        public static void GetCompensation_WithFits(SimpleScore out_comp, CardsDistribution cd, IntData fig, ZoneSwitcher zone, bool useReletivePair, PairSwitcher pair, /*fits:*/ FitsSwitcher fits, BoolData strongest, bool TenCardsIsTwoFits, bool LessCompFor2Fits23PC)
        {
            if (out_comp == null)
                return;

            if (zone != null && zone.IsDefined() && cd != null && cd.IsDefined()) //распределение приоритетнее, чем поле "фигуры" и "фиты"
            {
                Pairs pairStrongest = Pairs.NotDefinedYet;
                int figs_NS = CountFigurs(cd, Pairs.NS);
                int figs_EW = 40 - figs_NS;

                if(figs_NS > figs_EW)
                    pairStrongest = Pairs.NS;
                else if(figs_NS < figs_EW)
                    pairStrongest = Pairs.EW;
                else
                    pairStrongest = DefineStrongest(cd);

                int fitsOfStrongPair = CountFits(cd, pairStrongest, TenCardsIsTwoFits);

                int iNS_comp = 0, iEW_comp = 0;
                if(pairStrongest == Pairs.NS)
                    iNS_comp = Compens_Europe(figs_NS, fitsOfStrongPair, ZoneSwitcher.IsPairInZone(Pairs.NS, zone.Zone), LessCompFor2Fits23PC);
                else
                    iEW_comp = Compens_Europe(figs_EW, fitsOfStrongPair, ZoneSwitcher.IsPairInZone(Pairs.EW, zone.Zone), LessCompFor2Fits23PC);
                out_comp.SetScore(iEW_comp, iNS_comp);
            }
            else if (zone != null && zone.IsDefined() && fig != null && fig.IsDefined() && (pair != null && pair.IsDefined() || useReletivePair) && fits != null && fits.IsDefined() && (fig.Value != 20 || fig.Value == 20 && strongest != null && strongest.IsDefined()))
            {
                int NS_figs, EW_figs;
                if (!useReletivePair && pair.Pair == Pairs.NS || useReletivePair && RelativePair == Pairs.NS) //!!!!
                {
                    NS_figs = fig.Value;
                    EW_figs = 40 - NS_figs;
                }
                else
                {
                    EW_figs = fig.Value;
                    NS_figs = 40 - EW_figs;
                }

                Pairs pairStrongest = Pairs.NotDefinedYet;
                if(NS_figs > EW_figs)
                    pairStrongest = Pairs.NS;
                else if(NS_figs < EW_figs)
                    pairStrongest = Pairs.EW;
                else
                    pairStrongest = (strongest.Value ? Pairs.NS : Pairs.EW);

                int fitsOfStrongPair = fits.Choise;

                int iNS_comp = 0, iEW_comp = 0;
                if(pairStrongest == Pairs.NS)
                    iNS_comp = Compens_Europe(NS_figs, fitsOfStrongPair, ZoneSwitcher.IsPairInZone(Pairs.NS, zone.Zone), LessCompFor2Fits23PC);
                else
                    iEW_comp = Compens_Europe(EW_figs, fitsOfStrongPair, ZoneSwitcher.IsPairInZone(Pairs.EW, zone.Zone), LessCompFor2Fits23PC);
                out_comp.SetScore(iEW_comp, iNS_comp);
            }
            else
            {
                out_comp.Born = false;
            }
        }
示例#5
0
        public static void GetCompensation(SimpleScore out_comp, CardsDistribution cd, IntData fig, ZoneSwitcher zone, bool useReletivePair, PairSwitcher pair, int type_of_compens)
        {
            if (out_comp == null)
                return;

            // Определить тип компенсации и соотв. функцию
            TypeOfCompensation comp_type = (TypeOfCompensation)type_of_compens;
            CompensFunction comp_f;
            switch (comp_type)
            {
                case TypeOfCompensation.Chicago:
                    comp_f = Compens_Chicago;
                    break;
                case TypeOfCompensation.Moscow:
                    comp_f = Compens_Moscow;
                    break;
                case TypeOfCompensation.Milton_York:
                    comp_f = Compens_MiltonYork;
                    break;
                default:
                    throw new Exception("Не могу определить тип компесации: " + type_of_compens.ToString());
            }

            if (zone != null && zone.IsDefined() && cd != null && cd.IsDefined()) //распределение приоритетнее, чем поле "фигуры"
            {
                int NS_figs, EW_figs;
                NS_figs = CountFigurs(cd, Pairs.NS);
                EW_figs = 40 - NS_figs;

                int iNS_comp = comp_f(NS_figs, ZoneSwitcher.IsPairInZone(Pairs.NS, zone.Zone));
                int iEW_comp = comp_f(EW_figs, ZoneSwitcher.IsPairInZone(Pairs.EW, zone.Zone));
                out_comp.SetScore(iEW_comp, iNS_comp);
            }
            else if (zone != null && zone.IsDefined() && fig != null && fig.IsDefined() && (pair != null && pair.IsDefined() || useReletivePair))
            {
                int NS_figs, EW_figs;
                if (!useReletivePair && pair.Pair == Pairs.NS || useReletivePair && RelativePair == Pairs.NS) //!!!!
                {
                    NS_figs = fig.Value;
                    EW_figs = 40 - NS_figs;
                }
                else
                {
                    EW_figs = fig.Value;
                    NS_figs = 40 - EW_figs;
                }
                int iNS_comp = comp_f(NS_figs, ZoneSwitcher.IsPairInZone(Pairs.NS, zone.Zone));
                int iEW_comp = comp_f(EW_figs, ZoneSwitcher.IsPairInZone(Pairs.EW, zone.Zone));
                out_comp.SetScore(iEW_comp, iNS_comp);
            }
            else
            {
                out_comp.Born = false;
            }
        }
示例#6
0
        // Сколько очков за фигуры?
        public static void FiguresPoints(IntData out_figs, CardsDistribution cd, bool useReletivePair, PairSwitcher pair)
        {
            if (out_figs == null)
                return;

            if (!useReletivePair) //использовать pair
            {
                // Если пара неизвестна, то не принимать введенные фигуры
                if (pair == null || !pair.IsDefined())
                {
                    out_figs.Born = false;
                }
                else
                {
                    // Если известно распределение карт, то заблокировать кол-во фигур на полученное из распределения
                    if (cd != null && cd.IsDefined())
                    {
                        out_figs.Value = CountFigurs(cd, pair.Pair);
                    }
                    else
                    {

                    }
                }
            }
            else //использовать RelativePair !!!!!
            {
                if (cd != null && cd.IsDefined())
                {
                    out_figs.Value = CountFigurs(cd, RelativePair);
                }
                else
                {

                }
            }
        }
示例#7
0
 // Подсчёт очков в спортивном бридже
 public static void SportScoreInvert(SimpleScore out_score, PairSwitcher pair, ZoneSwitcher zone, Contract contract, Result result)
 {
     SportScore(out_score, pair, zone, contract, result, true);
 }
示例#8
0
        public static void SportScore(SimpleScore out_score, PairSwitcher pair, ZoneSwitcher zone, Contract contract, Result result, bool bInvertScore)
        {
            if (out_score == null)
                return;

            if (contract.NoContract)
            {
                out_score.SetScore(0, 0);
            }
            else if (pair == null || zone == null || contract == null || result == null || !pair.IsDefined() || !zone.IsDefined() || !contract.IsDefined() || !result.IsDefined())
            {
                out_score.Born = false;
            }
            else
            {
                bool inzone = ZoneSwitcher.IsPairInZone(pair.Pair, zone.Zone);
                int iNS = 0, iEW = 0;
                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;
                    // Премия за превышение взяток:
                    int bonus = 0;
                    if (result.Quantity > 0)
                    {
                        if (contract.Contra)
                            bonus += result.Quantity * (inzone ? 200 : 100);
                        else if (contract.ReContra)
                            bonus += result.Quantity * (inzone ? 400 : 200);
                        else
                            bonus += result.Quantity * (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;
                    }
                    // Дополнительная премия:
                    int bonus_plus = 0;
                    if (contract.Contra)
                        bonus_plus = 50;
                    else if (contract.ReContra)
                        bonus_plus = 100;

                    // Присвоение очков:
                    if(pair.Pair == Pairs.NS && !bInvertScore || pair.Pair == Pairs.EW && bInvertScore)
                        iNS = score + bonus + bonus_plus;
                    else if(pair.Pair == Pairs.EW && !bInvertScore || pair.Pair == Pairs.NS && bInvertScore)
                        iEW = score + bonus + bonus_plus;
                }
                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 (i == -2 || i == -3)
                        {
                            if (contract.Contra)
                                enemy_score += (inzone ? 300 : 200);
                            else if (contract.ReContra)
                                enemy_score += (inzone ? 600 : 400);
                            else
                                enemy_score += (inzone ? 100 : 50);
                        }
                        else
                        {
                            if (contract.Contra)
                                enemy_score += (inzone ? 300 : 300);
                            else if (contract.ReContra)
                                enemy_score += (inzone ? 600 : 600);
                            else
                                enemy_score += (inzone ? 100 : 50);
                        }
                    }

                    // Присвоение очков:
                    if (pair.Pair == Pairs.NS && !bInvertScore || pair.Pair == Pairs.EW && bInvertScore)
                        iEW = enemy_score;
                    else if (pair.Pair == Pairs.EW && !bInvertScore || pair.Pair == Pairs.NS && bInvertScore)
                        iNS = enemy_score;
                }

                // !!! Запись очков в объект данных:
                out_score.SetScore(iNS, iEW);
            }
        }