Пример #1
0
        /// <summary>
        /// 从一堆牌中找出最大的牌,考虑主
        /// </summary>
        /// <param name="sendCards">一堆主</param>
        /// <param name="suit">花色</param>
        /// <param name="rank">主</param>
        /// <returns>最大的牌</returns>
        internal static int GetMaxCard(ArrayList sendCards,int suit,int rank)
        {
            CurrentPoker cp = new CurrentPoker();
            cp.Suit = suit;
            cp.Rank = rank;
            cp = parse(sendCards, suit, rank);
            int thisSuit = CommonMethods.GetSuit((int)sendCards[0]);


            if (cp.IsMixed())
            {
                return -1;
            }

            bool hasTractor = cp.HasTractors();
            int pairTotal = cp.GetPairs().Count;
            int count = cp.Count;

            //如果拖拉机
            if (hasTractor)
            {
                return cp.GetTractor();
            }
            else if (count == 1) //单张牌
            {
                return (int)sendCards[0];
            }
            else if (count == pairTotal * 2 && (count > 1)) //都是对
            {
                return (int)cp.GetPairs()[pairTotal - 1];
            }
            else //有对和有单张牌,得到对的最大值
            {
                if (pairTotal>0)
                {
                    return (int)cp.GetPairs()[pairTotal - 1];
                }
                else
                {
                    return cp.GetMaxCard(thisSuit);
                }
                
            }

          
        }