示例#1
0
 public MatchNode(int pokerCount, int patternType, bool isMajor, IPileRelation validator)
 {
     PokerCount  = pokerCount;
     PatternType = patternType;
     IsMajor     = isMajor;
     Validator   = validator;
 }
示例#2
0
        public SelectNode(MatchNode matchNode)
        {
            PokerCount = matchNode.PokerCount;
            var curValidator = matchNode.Validator;

            if (curValidator is PRMatchNull)
            {
                Validator = new PRSelectNull();
            }
            else if (curValidator is PRMatchStraight)
            {
                Validator = new PRSelectStraight();
            }
        }
示例#3
0
        public PRVerifyResult Verify(SelectNode node, PokerPile previous, PokerPile current, int heartHostCount)
        {
            IPileRelation  validator = node.Validator;
            PRVerifyResult result;

            if (validator != null)
            {
                if (previous == null)
                {
                    result = validator.VerifyRoot(current, node.PokerCount, heartHostCount);
                }
                else
                {
                    result = validator.Verify(previous, current, node.PokerCount, heartHostCount);
                }
            }
            else
            {
                result = new PRVerifyResult(true, 0, 0, null);
            }

            return(result);
        }
示例#4
0
        public List <SelectNode> BuildSelectChain(PokerPattern pattern)
        {
            var list     = new List <SelectNode>();
            var pileList = new List <PokerPile>();
            var headPile = pattern.HeadPile;

            if (headPile == null)
            {
                return(null);
            }

            var nextPile = headPile;

            while (nextPile != null)
            {
                pileList.Add(nextPile);
                nextPile = nextPile.Next;
            }

            var majorCount = PatternType.GetMajorPileCount(pattern.Type);

            if (majorCount > pileList.Count)
            {
                return(null);
            }

            var majorPile = pileList[majorCount - 1];
            var majorNode = _matcher.GetRoot(majorPile.Count);

            if (majorNode == null)
            {
                return(null);
            }

            IPileRelation rootRelation = null;

            if (pattern.Type == PatternType.XXXX)
            {
                rootRelation = new PRSelectXXXX(majorPile.NumType, majorPile.Count, _value);
            }
            else
            {
                rootRelation = new PRSelectRoot(majorPile.NumType, PatternType.IsStraight(pattern.Type),
                                                PatternType.GetMajorPileCount(pattern.Type), _value);
            }

            var rootNode = new SelectNode(majorNode.PokerCount, rootRelation);

            list.Add(rootNode);

            var curNode = majorNode;

            for (int i = majorCount - 2; i >= 0; i--)
            {
                var pile = pileList[i];
                curNode = curNode.Next(pile.Count);
                if (curNode == null)
                {
                    return(null);
                }

                list.Add(new SelectNode(curNode));
            }

            for (int i = pileList.Count - 1, n = majorCount - 1; i > n; i--)
            {
                var pile = pileList[i];
                curNode = curNode.Next(pile.Count);
                if (curNode == null)
                {
                    return(null);
                }

                list.Add(new SelectNode(curNode));
            }

            return(list);
        }
示例#5
0
 public SelectNode(int pokerCount, IPileRelation validator)
 {
     PokerCount = pokerCount;
     Validator  = validator;
 }