示例#1
0
        public int Compare(PokerPattern p1, PokerPattern p2)
        {
            if (p1 == null || p2 == null)
            {
                return(CompareResult.PATTERN_NOT_MATCH);
            }

            if (p1.IsNull && !p2.IsNull)
            {
                return(CompareResult.SMALLER);
            }

            if (!p1.IsNull && p2.IsNull)
            {
                return(CompareResult.BIGGER);
            }

            if (p1.IsNull && p2.IsNull)
            {
                return(CompareResult.EQUAL);
            }

            if (p1.Type == PatternType.XXDD)
            {
                return(CompareResult.BIGGER);
            }

            if (p2.Type == PatternType.XXDD)
            {
                return(CompareResult.SMALLER);
            }

            if (PatternType.IsBomb(p1.Type) && !PatternType.IsBomb(p2.Type))
            {
                return(CompareResult.BIGGER);
            }

            if (!PatternType.IsBomb(p1.Type) && PatternType.IsBomb(p2.Type))
            {
                return(CompareResult.SMALLER);
            }

            if (PatternType.IsBomb(p1.Type) && PatternType.IsBomb(p2.Type))
            {
                float c1 = 0;
                float c2 = 0;

                if (p1.Type == PatternType.XXXX)
                {
                    c1 = p1.PokerCount;
                }
                else if (p1.Type == PatternType.SuperABCDE)
                {
                    c1 = 5.5f;
                }

                if (p2.Type == PatternType.XXXX)
                {
                    c2 = p2.PokerCount;
                }
                else if (p2.Type == PatternType.SuperABCDE)
                {
                    c2 = 5.5f;
                }

                float res = c1 - c2;
                if (res > 0.4)
                {
                    return(CompareResult.BIGGER);
                }
                else if (res < -0.4)
                {
                    return(CompareResult.SMALLER);
                }
                else
                {
                    int v1 = ValueOf(p1);
                    int v2 = ValueOf(p2);

                    if (v1 == v2)
                    {
                        return(CompareResult.EQUAL);
                    }

                    if (v1 > v2)
                    {
                        return(CompareResult.BIGGER);
                    }
                    else
                    {
                        return(CompareResult.SMALLER);
                    }
                }
            }

            if (p1.Type == p2.Type && p1.PokerCount == p2.PokerCount)
            {
                int v1 = ValueOf(p1);
                int v2 = ValueOf(p2);

                if (v1 == v2)
                {
                    return(CompareResult.EQUAL);
                }

                if (v1 > v2)
                {
                    return(CompareResult.BIGGER);
                }
                else
                {
                    return(CompareResult.SMALLER);
                }
            }

            return(CompareResult.PATTERN_NOT_MATCH);
        }
示例#2
0
        public PokerPattern GetSmallestPatternBiggerThan(PokerPattern lastChuPai, bool chaiPai, bool needBomb,
                                                         int endSelectSize)
        {
            BuildPokerPool();

            if (lastChuPai == null ||
                lastChuPai.IsNull ||
                lastChuPai.Type == PatternType.BUCHU)
            {
                return(SelectChuPai());
            }

            if (lastChuPai.Type == PatternType.XXDD)
            {
                // 如果是王炸就没必要再找下去了。
                return(PokerPattern.NULL);
            }

            if (PatternType.IsBomb(lastChuPai.Type))
            {
                if (needBomb)
                {
                    return(SelectBiggerXXXXOrSuperABCDE(lastChuPai, _heartHosts.Count, chaiPai));
                }
                else
                {
                    return(PokerPattern.NULL);
                }
            }

            var selectChain = BuildSelectChain(lastChuPai);

            if (selectChain == null)
            {
                return(PokerPattern.NULL);
            }

            PokerPile result = SelectNormal(PatternType.IsStraight(lastChuPai.Type), selectChain, 0, null,
                                            _heartHosts.Count, chaiPai, endSelectSize);

            if (result != null)
            {
                int majorNumType = result.NumType == PokerNumType.PHost ? _value.CurrentHost : result.NumType;
                result = AdjustPileOrder(result, lastChuPai.Type);
                return(new PokerPattern(
                           lastChuPai.Type,
                           result,
                           majorNumType,
                           GetAllPokers(result, false)
                           ));
            }
            else
            {
                if (needBomb)
                {
                    return(SelectBiggerXXXXOrSuperABCDE(null, _heartHosts.Count, chaiPai));
                }
                else
                {
                    return(PokerPattern.NULL);
                }
            }
        }