Exemple #1
0
        private int ScoreDifferent(CustomBasicList <int> thisCol, out bool receiveMults)
        {
            var temps = thisCol.GroupBy(Items => Items).ToCustomBasicList();

            if (temps.Count == 6)
            {
                receiveMults = true;
                return(thisCol.Sum(Items => Items));
            }
            else
            {
                receiveMults = false;
                return(temps.Sum(Items => Items.Key));
            }
        }
Exemple #2
0
        private ICustomBasicList <R> StraightSet(ICustomBasicList <R> objectList, int howMany, bool minOnly, ICustomBasicList <R> wildList, bool noWilds = false)
        {
            ICustomBasicList <R> output = new CustomBasicList <R>();
            bool tempwilds = HasWild;

            if (noWilds == true)
            {
                HasWild = false;
            }
            else if (HasWild == false)
            {
                HasWild = false;
            }
            else
            {
                HasWild = true;
            }
            IEnumerable <R> firstLinq; //we may need that unfortunately.

            if (UseSecond == false)
            {
                firstLinq = from Objects in _tempList
                            where Objects.IsObjectIgnored == false && Objects.IsObjectWild == false
                            orderby Objects.ReadMainValue
                            select Objects;
            }
            else
            {
                firstLinq = from Objects in _tempList
                            where Objects.IsObjectIgnored == false && Objects.IsObjectWild == false
                            select Objects;
            }
            CustomBasicList <R> firstList = new CustomBasicList <R>();

            firstList.AddRange(firstLinq);
            var exps = firstLinq.GroupBy(Items => Items.ReadMainValue).ToCustomBasicList();
            CustomBasicList <R> temps;

            if (NeedMatch == false)
            {
                temps = firstList.GroupBy(Items => Items.ReadMainValue).Select(Items => Items.First()).ToCustomBasicList();
            }
            else
            {
                temps = firstList.GroupBy(Items => new { Items.ReadMainValue, Items.GetSuit }).Select(Items => Items.First()).ToCustomBasicList();
            }
            firstList.ReplaceRange(temps);
            if (NeedMatch == true)
            {
                firstList = firstList.OrderBy(Items => Items.GetSuit).ThenBy(Items => Items.ReadMainValue).ToCustomBasicList();
            }
            else
            {
                firstList = firstList.OrderBy(Items => Items.ReadMainValue).ToCustomBasicList();
            }
            int[]? aObjectIndex;
            aObjectIndex = new int[1];
            bool bStraightFound = default;
            int  lngUnUsedWild  = default;
            int  Start          = default;

            if (HasValidStraight(firstList, wildList, false, howMany, minOnly, ref aObjectIndex, ref lngUnUsedWild, ref Start))
            {
                bStraightFound = true;
            }
            else
            {
                aObjectIndex = null;
                if (HasSecond == true)
                {
                    firstList = new CustomBasicList <R>();
                    firstList.AddRange(firstLinq);
                    if (NeedMatch == true)
                    {
                        firstList = (from Items in firstList
                                     orderby Items.GetSuit ascending, Items.GetSecondNumber ascending
                                     select Items).ToCustomBasicList();
                    }
                    else
                    {
                        firstList = (from Items in firstList
                                     orderby Items.GetSecondNumber
                                     select Items).ToCustomBasicList();
                    }
                }
                if (HasValidStraight(firstList, wildList, true, howMany, minOnly, ref aObjectIndex, ref lngUnUsedWild, ref Start))
                {
                    UseSecond      = true;
                    bStraightFound = true;
                }
            }
            int lngObjectInStraight;
            int lngIndex;

            if (bStraightFound == true)
            {
                lngObjectInStraight = aObjectIndex !.GetUpperBound(0) - 1; // i think
                var loopTo = (long)Start + lngObjectInStraight;
                for (lngIndex = Start; lngIndex <= loopTo; lngIndex++)
                {
                    output.Add(firstList[lngIndex]);
                    if (output.Count == _maxStraight)
                    {
                        break;
                    }
                }
                int intHigh = default;
                int intLow  = default;
                HighLow(ref firstList, output, howMany, minOnly, lngUnUsedWild, ref intHigh, ref intLow);
                FirstUsed = intLow;
                if (HasWild == true)
                {
                    var loopTo1 = wildList.Count() - 1;
                    for (lngIndex = 0; lngIndex <= loopTo1; lngIndex++)
                    {
                        if (lngIndex + 1 <= wildList.Count())
                        {
                            if (output.Count < howMany | minOnly == false)
                            {
                                output.Add(wildList[lngIndex]);
                            }
                        }
                        if (output.Count == _maxStraight)
                        {
                            return(output);
                        }
                    }
                }
            }
            if (output.Count == objectList.Count & UseAll == false)
            {
                firstLinq = from Objects in output
                            where Objects.ReadMainValue == FirstUsed
                            select Objects;
                if (firstLinq.Count() > 0)
                {
                    output.RemoveSpecificItem(firstLinq.First());
                }
                else
                {
                    output.RemoveLastItem();
                }
            }
            aObjectIndex = null;
            int newnum;

            newnum = FirstUsed + output.Count - 1;
            newnum = HighNumber - newnum;
            if (FirstUsed > 0 & newnum < 0)
            {
                FirstUsed += newnum;
            }
            HasWild = tempwilds;
            return(output);
        }