示例#1
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;
            }
        }
示例#2
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;
            }
        }
示例#3
0
        // IMP
        public static void ConvertToIMPs(SimpleScore out_imp, SimpleScore score)
        {
            if (out_imp == null)
                return;

            if (score == null || !score.IsDefined())
            {
                out_imp.Born = false;
            }
            else
            {
                int NS_IMP = IMP(score.Score.NS);
                int EW_IMP = IMP(score.Score.EW);
                out_imp.SetScore(NS_IMP, EW_IMP);
            }
        }
示例#4
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);
            }
        }
示例#5
0
        // Сумма очков
        public static void ScoreSumm(SimpleScore out_sum, SimpleScore score1, SimpleScore score2)
        {
            if (out_sum == null)
                return;

            if (score1 == null || !score1.IsDefined() || score2 == null || !score2.IsDefined())
            {
                out_sum.Born = false;
            }
            else
            {
                int iNS = score1.Score.NS + score2.Score.NS;
                int iEW = score1.Score.EW + score2.Score.EW;

                if (iNS >= iEW)
                {
                    iNS -= iEW;
                    iEW = 0;
                }
                else
                {
                    iEW -= iNS;
                    iNS = 0;
                }
                out_sum.SetScore(iNS, iEW);
            }
        }
示例#6
0
 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);
         }
     }
 }