Beispiel #1
0
 /// <summary>
 /// 分组牌面大小
 /// [203,403,405,103]=> [0:[],1:[],2:[],3:[203,403,103],4:[],5:[405]]
 /// </summary>
 /// <param name="cards"></param>
 public CardGroup ParseCardGroup(int[] cards)
 {
     int len = cards.Length;
     CardGroup cardGroup = new CardGroup();
     while (len-- > 0)
     {
         int card = cards[len];
         int val = GetCardSize(card);
         cardGroup.Add(card, (CardSize)val);
     }
     return cardGroup;
 }
Beispiel #2
0
 /// <summary>
 /// 四张
 /// </summary>
 /// <param name="cards">需要排序后</param>
 /// <param name="groupObj"></param>
 /// <param name="cardSize"></param>
 /// <returns></returns>
 public bool IsFour(int[] cards, CardGroup groupObj, out int cardSize)
 {
     cardSize = 0;
     if (cards.Length != 4)
     {
         return false;
     }
     int val = GetCardSize(cards[0]);
     if (groupObj.GetSameSizeCount(val) == 4)
     {
         cardSize = val;
         return true;
     }
     return false;
 }
Beispiel #3
0
 /// <summary>
 /// 四张带二或二对
 /// </summary>
 /// <param name="cards"></param>
 /// <param name="groupObj"></param>
 /// <param name="cardSize"></param>
 /// <returns></returns>
 public bool IsFourAndTwo(int[] cards, CardGroup groupObj, out int cardSize)
 {
     cardSize = 0;
     if (cards.Length != 6 && cards.Length != 8)
     {
         return false;
     }
     var list = groupObj.FindSame(4);
     if (list.Length > 0)
     {
         if (cards.Length == 8 && groupObj.FindSameCount(2).Length != 2)
         {
             return false;
         }
         cardSize = GetCardSize(list[0]);
         return true;
     }
     return false;
 }
Beispiel #4
0
        /// <summary>
        /// 三张连续
        /// </summary>
        /// <param name="cards">需要排序后</param>
        /// <param name="groupObj"></param>
        /// <param name="cardSize"></param>
        /// <returns></returns>
        public bool IsThee(int[] cards, CardGroup groupObj, out int cardSize)
        {
            cardSize = 0;
            if (cards.Length % 3 != 0)
            {
                return false;
            }
            int val = GetCardSize(cards[0]), count = 0;

            for (var i = 0; i < cards.Length; i = i + 3)
            {
                int val1 = GetCardSize(cards[i]);
                if (val1 != val + count ||
                    groupObj.GetSameSizeCount(val1) != 3 ||
                    val1 >= (int)CardSize.C_2)
                {
                    return false;
                }
                count++;
            }
            cardSize = val;
            return true;
        }