示例#1
0
        private bool IsStraight()
        {
            bool output = default;
            bool bStraightFound;

            int[]? aObjectIndex;
            int lngUnUsedWild = default;

            UseSecond = false;
            int currentnum = default;
            int thismany   = default;
            int x          = default;
            CustomBasicList <R> filteredList;

            filteredList = (from Objects in _tempList
                            where Objects.IsObjectIgnored == false && Objects.IsObjectWild == false
                            select Objects).ToCustomBasicList();
            var loopTo = filteredList.Count - 1;

            for (x = 0; x <= loopTo; x++)
            {
                currentnum = filteredList[x].ReadMainValue;
                thismany   = filteredList.Count(Items => Items.ReadMainValue == currentnum);
                if (thismany > 1)
                {
                    return(false);
                }
            }
            CustomBasicList <R> newList = new CustomBasicList <R>();

            newList.AddRange(_tempList !);
            var wildList = newList.Where(Items => Items.IsObjectWild == true).ToCustomBasicList();

            _tempList = filteredList.ToCustomBasicList();
            if (NeedMatch == true)
            {
                _tempList = (from Items in _tempList
                             orderby Items.GetSuit ascending, Items.ReadMainValue ascending
                             select Items).ToCustomBasicList();
            }
            else
            {
                _tempList = (from Items in _tempList
                             orderby Items.ReadMainValue
                             select Items).ToCustomBasicList();
            }
            if (NeedMatch == true)
            {
                bool rets;
                rets = _tempList.HasOnlyOne(items => items.GetSuit);
                if (rets == false)
                {
                    return(false);
                }
            }
            bStraightFound = false;
            FirstUsed      = 0;
            aObjectIndex   = new int[1];
            var argStartAt1 = 0;

            if (HasValidStraight(_tempList, wildList, false, _tempList.Count + wildList.Count, false, ref aObjectIndex, ref lngUnUsedWild, ref argStartAt1))
            {
                bStraightFound = true;
            }
            else
            {
                aObjectIndex = null;
                if (HasSecond == true)
                {
                    _tempList = _tempList.OrderBy(items => items.GetSecondNumber).ToCustomBasicList();
                    var argStartAt = 0;
                    if (HasValidStraight(_tempList, wildList, true, _tempList.Count + wildList.Count, false, ref aObjectIndex, ref lngUnUsedWild, ref argStartAt))
                    {
                        bStraightFound = true;
                        UseSecond      = true;
                    }
                }
            }
            if (bStraightFound == true)
            {
                int lngCardInStraight;
                int lngIndex;
                CustomBasicList <R> straightset = new CustomBasicList <R>();
                lngCardInStraight = aObjectIndex !.GetUpperBound(0) - 1; // because its 0 based.
                var loopTo1 = lngCardInStraight;
                for (lngIndex = 0; lngIndex <= loopTo1; lngIndex++)
                {
                    straightset.Add(_tempList[lngIndex]);
                    if (straightset.Count == _maxStraight)
                    {
                        break;
                    }
                }
                int intHigh = default;
                int intLow  = default;
                HighLow(ref _tempList, straightset, _tempList.Count, false, lngUnUsedWild, ref intHigh, ref intLow);
                FirstUsed = intLow;
            }
            aObjectIndex = null;
            output       = bStraightFound;
            return(output);
        }