Exemple #1
0
        /** 获得单张的个数,对子的个数,三张的个数,4张的个数 */

        public static CardCount getCardCount(List <Card> list)
        {
            CardCount card_index = new CardCount();

            int[] count = analyzeCards(list);
            for (int i = 0; i < 15; ++i)
            {
                int v = count[i];
                if (v == 0)
                {
                    continue;
                }
                if (v > 4)
                {
                    v = 4;
                }
                card_index.a[v - 1].Add(i + 3); //card's weight
            }
            return(card_index);
        }
Exemple #2
0
        /// <summary>
        /// 从服务器端copy的卡牌类型判断方法
        /// </summary>
        /// <param name="list"></param>
        /// <param name="orgCdsLen">原始牌组长度</param>
        /// <returns></returns>
        static CardTypeResult GetCardTypeResult(List <Card> list, int orgCdsLen)
        {
            int len = list.Count;

            if (len == 0)
            {
                //			GameUtil.logError("landlord getCardType error,len is 0",0);
                return(null);
            }
            int first = list[0].getWeight();
            int last  = list[len - 1].getWeight();

            if (len <= 4)
            {
                if (first == last)
                {
                    switch (len)
                    {
                    case 1:
                        return(new CardTypeResult(CardType.C1, first));

                    case 2:
                        return(new CardTypeResult(CardType.C2, first));

                    case 4:
                        return(new CardTypeResult(CardType.C4, first));
                    }
                }
                //判断2连对
                else if (len == 4)
                {
                    CardCount  ci   = getCardCount(list);
                    List <int> arr1 = ci.a[1];
                    // 连对
                    if (arr1.Count * 2 == len && isSequenceArr(arr1))
                    {
                        return(new CardTypeResult(CardType.C1122, last));
                    }
                }
            }
            else
            {
                CardCount  ci   = getCardCount(list);
                List <int> arr0 = ci.a[0];
                List <int> arr1 = ci.a[1];
                List <int> arr2 = ci.a[2];
                List <int> arr3 = ci.a[3];

                // 链子
                if (arr0.Count == len && isSequenceArr(arr0))
                {
                    return(new CardTypeResult(CardType.C123, last));
                }

                // 连对
                if (arr1.Count * 2 == len && isSequenceArr(arr1))
                {
                    return(new CardTypeResult(CardType.C1122, last));
                }

                // 3带一对
                if (len == 5 && (arr1.Count * 2 + arr0.Count) == arr2.Count * 2)
                {
                    return(new CardTypeResult(CardType.C32, arr2[0]));
                }

                // 分析飞机
                int count = arr2.Count;
                if (count > 0)
                {
                    /*                    //如果是三顺 存在类似 333,444,555,777 这样的飞机带单排的情况和 333,555,666,777,888,带1张单牌的 两种特殊情况
                     *                  if (!isSequenceArr(arr2) && (count==4 ||count==5))
                     *                  {
                     *                      var listTemp = new List<int>();
                     *                      //去头
                     *                      for (int i = 1; i < count; i++)
                     *                      {
                     *                          listTemp.Add(arr2[i]);
                     *                      }
                     *
                     *                      //去尾
                     *                      listTemp.Clear();
                     *                      for (int i = 0; i < count - 1; i++)
                     *                      {
                     *                          listTemp.Add(arr2[i]);
                     *                      }
                     *
                     *                  }
                     *                  else */
                    if (isSequenceArr(arr2))
                    {
                        if (arr0.Count + arr1.Count * 2 + arr3.Count * 4 == count * 2)
                        {
                            return(new CardTypeResult(CardType.C1112223434, arr2[count - 1], ci));
                        }
                    }
                }

                //如果上面没分析出飞机,则进一步吧炸弹拆成3张的,分析飞机
                if (arr3.Count > 0)
                {
                    var threeCdsList = new List <int>();
                    threeCdsList.AddRange(arr2);
                    threeCdsList.AddRange(arr3);

                    var threeGpList = AnalyAllPartOfShun(threeCdsList.ToArray(), 2);
                    if (threeGpList.Select(cds => cds.Length).Any(cdsLen => cdsLen * 2 == orgCdsLen - cdsLen * 3))
                    {
                        var maxcd = arr2[count - 1];
                        if (arr3[count - 1] > maxcd)
                        {
                            maxcd = arr3[count - 1];
                        }
                        return(new CardTypeResult(CardType.C1112223434, maxcd, ci));
                    }
                }
            }
            return(null);
        }
Exemple #3
0
 public void setCi(CardCount ci)
 {
     this.ci = ci;
 }
Exemple #4
0
        private CardCount ci; //当前只有飞机牌型此值有效

        public CardTypeResult(CardType type, int value, CardCount ci = null)
        {
            this.type  = type;
            this.value = value;
            this.ci    = ci;
        }