• Unity 网络斗地主 判断牌的类型


                                                       Unity 网络斗地主  牌的类型

       

         web版本演示地址:   http://www.dreamhome666.com/Desktop.html

         在上个版本中,下面的角色在牌的后面,可以将角色做为一个Panel的子物体,然后调整Panel的depth,即可调整顺序!

       进入正题,定义牌的类型!

       用c#的enum来实现枚举判断,斗地主的牌的类型有,

       /// <summary>
    /// 牌类型
    /// </summary>
    public enum cardtype
    {
        //未知类型
        none,
        //王炸
        wangzha,
        //炸弹
        zhadan,
        //四张带两张
        sidaier,
        //三个不带
        sangebudai,
        //三个带一
        sandaiyi,
        //三个带二
        sandaier,
        //两个三个
        lianggesange,
        //两个三个带二个
        lianggesangedaier,
        //两个三个带四个
        lianggesangedaisige,
        //三个三个
        sangesange,
        //三个三个带三个
        sangesangedaisange,
        //三个三个带六个
        sangesangedailiuge,
        //四个三个
        sigesange,
        //四个三个带四个
        sigesangedaisange,
        //四个三个带八个
        sigesangedailiuge,
        //五个三个
        wugesange,
        //五个三个带五个
        wugesangedaiwuge,
        //六个三个
        liugesange,
        //顺子
        danshun,
        //双顺
        shangshun,
        //对子
        duizi,
        //单个
        dan
    }

        判断牌的类型及大小!

       

    using UnityEngine;
    using System.Collections;
    using System.Collections.Generic;
    /*
     * 判断牌的类型
    */
    public class CardPop : MonoBehaviour
    {
        /// <summary>
        /// 判断是否包含大小王
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool ishavewang(int[] data)
        {
            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] == 52 || data[i] == 53)
                {
                    return true;
                }
            }
            return false;
        }
        /// <summary>
        /// 是否带2
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool isdai2(int[] data)
        {
            for (int i = 0; i < data.Length; i++)
            {
                if (data[i]%13==1)
                {
                    return true;
                }
            }
            return false;
        }
        /// <summary>
        /// 判断对子 53和52是大王和小王
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool isduizi(int[] data,out int max)
        {
            max = -1;
            if (ishavewang(data))
            {
                return false;
            }
           int temp1 = data[0] % 13;
           int temp2 = data[1] % 13;
           if (temp1 == temp2)
           {
               max = temp1;
               if (temp1 == 0)
               {
                   max = 13;
               }
               if (temp1 == 1)
               {
                   max = 14;
               }
               return true;
           }
           return false;
        }
        /// <summary>
        /// 双顺
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool isshuangshun(int[] data,out int max)
        {
            max = -1;
            if (ishavewang(data)||isdai2(data))
            {
                return false;
            }
            for (int i = 0; i < data.Length; i += 2)
            {
                if (i == data.Length - 2)
                {
                    int temp1 = data[i] % 13;
                    int temp2 = data[i + 1] % 13;
                    if (temp1 != temp2)
                    {
                        return false;
                    }
                }
                else
                {
                    int temp1 = data[i] % 13;
                    int temp2 = data[i + 1] % 13;
                    if (temp1 == 0)
                    {
                        temp1 = 13;
                    }
                    if (temp2 == 0)
                    {
                        temp2 = 13;
                    }
                    int temp3 = data[i + 2] % 13;
                    if (temp1 != temp2 || temp2 - temp3 != 1)
                    {
                        return false;
                    }
                }
            }
            max = data[0] % 13;
            return true;
        }
        /// <summary>
        /// 单顺
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool isdanshun(int[] data,out int max)
        {
            max = -1;
            if (ishavewang(data)||isdai2(data))
            {
                return false;
            }
            for (int i = 0; i < data.Length-1; i++)
            {
                 int temp1 = data[i] % 13;
                 int temp2 = data[i+1] % 13;
                 if (temp1 == 0)
                 {
                     temp1 = 13;
                 }
                 if (temp2 == 0)
                 {
                     temp2 = 13;
                 }
                 if (temp1 - temp2 != 1)
                 {
                     return false;
                 }
            }
            max = data[0] % 13;
            return true;
        }
        /// <summary>
        /// 六个三个
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool isliugesange(int[] data,out int max)
        {
            max = -1;
            List<int> data1 = new List<int>();
            int count1 = 0;
            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] == 52 || data[i] == 53)
                {
                    continue;
                }
                int data2 = data[i] % 13;
                if (data1.Contains(data2))
                {
                    continue;
                }
                int count = 0;
                for (int j = 0; j < data.Length; j++)
                {
                    if (data[j] == 52 || data[j] == 53)
                    {
                        continue;
                    }
                    int data3 = data[j] % 13;
                    if (data2 == data3)
                    {
                        count++;
                    }
                }
                if (count == 3)
                {
                    data1.Add(data2);
                    count1++;
                }
            }
            if (count1 == 6)
            {
                for (int i = 0; i < data1.Count; i++)
                {
                    if (i != data1.Count - 1)
                    {
                        int m1 = data1[i];
                        int m2 = data1[i + 1];
                        if (m1 == 0)
                        {
                            m1 = 13;
                        }
                        if (m2 == 0)
                        {
                            m2 = 13;
                        }
                        if (m1 - m2 != 1)
                        {
                            return false;
                        }
                    }
                }
                max = data1[0];
                return true;
            }
            return false;
        }
        /// <summary>
        /// 五个三个带五个
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool iswugesangedaiwuge(int[] data,out int max)
        {
            max = -1;
            List<int> data1 = new List<int>();
            int count1 = 0;
            for (int i = 0; i < data.Length; i++)
            {
                if(data[i]==52||data[i]==53)
                {
                    continue;
                }
                int data2 = data[i]%13;
                if (data1.Contains(data2))
                {
                    continue;
                }
                int count = 0;
                for (int j = 0; j < data.Length; j++)
                {
                    if (data[j] == 52 || data[j] == 53)
                    {
                        continue;
                    }
                    int data3 = data[j] % 13;
                    if (data2 == data3)
                    {
                        count++;
                    }
                }
                if (count == 3)
                {
                    data1.Add(data2);
                    count1++;
                }
            }
            if (count1 == 5)
            {
                for (int i = 0; i < data1.Count; i++)
                {
                    if (i != data1.Count - 1)
                    {
                        int m1 = data1[i];
                        int m2 = data1[i + 1];
                        if (m1 == 0)
                        {
                            m1 = 13;
                        }
                        if (m2 == 0)
                        {
                            m2 = 13;
                        }
                        if (m1 - m2 != 1)
                        {
                            return false;
                        }
                    }
                }
                max = data1[0];
                return true;
            }
            return false;
        }
        /// <summary>
        /// 五个三个
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool iswugesange(int[] data,out int max)
        {
            max = -1;
            if(ishavewang(data))
            {
                return false;
            }
            List<int> data1 = new List<int>();
            int count1 = 0;
            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] == 52 || data[i] == 53)
                {
                    continue;
                }
                int data2 = data[i] % 13;
                if (data1.Contains(data2))
                {
                    continue;
                }
                int count = 0;
                for (int j = 0; j < data.Length; j++)
                {
                    if (data[j] == 52 || data[j] == 53)
                    {
                        continue;
                    }
                    int data3 = data[j] % 13;
                    if (data2 == data3)
                    {
                        count++;
                    }
                }
                if (count == 3)
                {
                    data1.Add(data2);
                    count1++;
                }
            }
            if (count1 == 5)
            {
                for (int i = 0; i < data1.Count; i++)
                {
                    if (i != data1.Count - 1)
                    {
                        int m1 = data1[i];
                        int m2 = data1[i + 1];
                        if (m1 == 0)
                        {
                            m1 = 13;
                        }
                        if (m2 == 0)
                        {
                            m2 = 13;
                        }
                        if (m1 - m2 != 1)
                        {
                            return false;
                        }
                    }
                }
                max = data1[0];
                return true;
            }
            return false;
        }
        /// <summary>
        /// 四个三个带八个
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool issigesangedailiuge(int[] data,out int max)
        {
            max = -1;
            if (ishavewang(data))
            {
                return false;
            }
            List<int> data1 = new List<int>();
            int count1 = 0;
            for (int i = 0; i < data.Length; i++)
            {
                int data2 = data[i] % 13;
                if (data1.Contains(data2))
                {
                    continue;
                }
                int count = 0;
                for (int j = 0; j < data.Length; j++)
                {
                    int data3 = data[j] % 13;
                    if (data2 == data3)
                    {
                        count++;
                    }
                }
                if (count == 3)
                {
                    data1.Add(data2);
                    count1++;
                }
            }
            List<int> datat = new List<int>();
            int count2 = 0;
            for (int i = 0; i < data.Length; i++)
            {
                int temp1 = data[i] % 13;
                if (data1.Contains(temp1)||datat.Contains(temp1))
                {
                    continue;
                }
                int count22=0;
                for (int j = 0; j < data.Length; j++)
                {
                    int temp2 = data[j] % 13;
                    if (temp1 == temp2)
                    {
                        count22++;
                    }
                }
                if (count22 == 2)
                {
                    count2++;
                    datat.Add(temp1);
                }
            }
            if (count1==4&&count2 == 4)
            {
                for (int i = 0; i < data1.Count; i++)
                {
                    if (i != data1.Count - 1)
                    {
                        int m1 = data1[i];
                        int m2 = data1[i + 1];
                        if (m1 == 0)
                        {
                            m1 = 13;
                        }
                        if (m2 == 0)
                        {
                            m2 = 13;
                        }
                        if (m1 - m2 != 1)
                        {
                            return false;
                        }
                    }
                }
                max = data1[0];
                return true;
            }
            return false;
        }
        /// <summary>
        /// 四个三个带四个
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool issigesangedaisige(int[] data,out int max)
        {
            max = -1;
            List<int> data1 = new List<int>();
            int count1 = 0;
            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] == 52 || data[i] == 53)
                {
                    continue;
                }
                int data2 = data[i] % 13;
                if (data1.Contains(data2))
                {
                    continue;
                }
                int count = 0;
                for (int j = 0; j < data.Length; j++)
                {
                    if (data[j] == 52 || data[j] == 53)
                    {
                        continue;
                    }
                    int data3 = data[j] % 13;
                    if (data2 == data3)
                    {
                        count++;
                    }
                }
                if (count == 3)
                {
                    data1.Add(data2);
                    count1++;
                }
            }
            if (count1 == 4)
            {
                for (int i = 0; i < data1.Count; i++)
                {
                    if (i != data1.Count - 1)
                    {
                        int m1 = data1[i];
                        int m2 = data1[i + 1];
                        if (m1 == 0)
                        {
                            m1 = 13;
                        }
                        if (m2 == 0)
                        {
                            m2 = 13;
                        }
                        if (m1 - m2 != 1)
                        {
                            return false;
                        }
                    }
                }
                max = data1[0];
                return true;
            }
            return false;
        }
        /// <summary>
        /// 四个三个
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool issigesange(int[] data,out int max)
        {
            max = -1;
            List<int> data1 = new List<int>();
            int count1 = 0;
            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] == 52 || data[i] == 53)
                {
                    continue;
                }
                int data2 = data[i] % 13;
                if (data1.Contains(data2))
                {
                    continue;
                }
                int count = 0;
                for (int j = 0; j < data.Length; j++)
                {
                    if (data[j] == 52 || data[j] == 53)
                    {
                        continue;
                    }
                    int data3 = data[j] % 13;
                    if (data2 == data3)
                    {
                        count++;
                    }
                }
                if (count == 3)
                {
                    data1.Add(data2);
                    count1++;
                }
            }
            if (count1 == 4)
            {
                for (int i = 0; i < data1.Count; i++)
                {
                    if (i != data1.Count - 1)
                    {
                        int m1 = data1[i];
                        int m2 = data1[i + 1];
                        if (m1 == 0)
                        {
                            m1 = 13;
                        }
                        if (m2 == 0)
                        {
                            m2 = 13;
                        }
                        if (m1 - m2 != 1)
                        {
                            return false;
                        }
                    }
                }
                max = data1[0];
                return true;
            }
            return false;
        }
        /// <summary>
        /// 三个三个带六个
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool issangesangedailiuge(int[] data,out int max)
        {
            max = -1;
            if (ishavewang(data))
            {
                return false;
            }
            List<int> data1 = new List<int>();
            int count1 = 0;
            for (int i = 0; i < data.Length; i++)
            {
                int data2 = data[i] % 13;
                if (data1.Contains(data2))
                {
                    continue;
                }
                int count = 0;
                for (int j = 0; j < data.Length; j++)
                {
                    int data3 = data[j] % 13;
                    if (data2 == data3)
                    {
                        count++;
                    }
                }
                if (count == 3)
                {
                    data1.Add(data2);
                    count1++;
                }
            }
            List<int> datat = new List<int>();
            int count2 = 0;
            for (int i = 0; i < data.Length; i++)
            {
                int temp1 = data[i] % 13;
                if (data1.Contains(temp1) || datat.Contains(temp1))
                {
                    continue;
                }
                int count22 = 0;
                for (int j = 0; j < data.Length; j++)
                {
                    int temp2 = data[j] % 13;
                    if (temp1 == temp2)
                    {
                        count22++;
                    }
                }
                if (count22 == 2)
                {
                    count2++;
                    datat.Add(temp1);
                }
            }
            if (count1 == 3 && count2 == 3)
            {
                for (int i = 0; i < data1.Count; i++)
                {
                    if (i != data1.Count - 1)
                    {
                        int m1 = data1[i];
                        int m2 = data1[i + 1];
                        if (m1 == 0)
                        {
                            m1 = 13;
                        }
                        if (m2 == 0)
                        {
                            m2 = 13;
                        }
                        if (m1 - m2 != 1)
                        {
                            return false;
                        }
                    }
                }
                max = data1[0];
                return true;
            }
            return false;
        }
        /// <summary>
        /// 三个三个带三个
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool issangesangedaisange(int[] data,out int max)
        {
            max = -1;
            List<int> data1 = new List<int>();
            int count1 = 0;
            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] == 52 || data[i] == 53)
                {
                    continue;
                }
                int data2 = data[i] % 13;
                if (data1.Contains(data2))
                {
                    continue;
                }
                int count = 0;
                for (int j = 0; j < data.Length; j++)
                {
                    if (data[j] == 52 || data[j] == 53)
                    {
                        continue;
                    }
                    int data3 = data[j] % 13;
                    if (data2 == data3)
                    {
                        count++;
                    }
                }
                if (count == 3)
                {
                    data1.Add(data2);
                    count1++;
                }
            }
            if (count1 == 3)
            {
                for (int i = 0; i < data1.Count; i++)
                {
                    if (i != data1.Count - 1)
                    {
                        int m1 = data1[i];
                        int m2 = data1[i + 1];
                        if (m1 == 0)
                        {
                            m1 = 13;
                        }
                        if (m2 == 0)
                        {
                            m2 = 13;
                        }
                        if (m1 - m2 != 1)
                        {
                            return false;
                        }
                    }
                }
                max = data1[0];
                return true;
            }
            return false;
        }
        /// <summary>
        /// 三个三个
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool issangesange(int[] data,out int max)
        {
            max = -1;
            List<int> data1 = new List<int>();
            int count1 = 0;
            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] == 52 || data[i] == 53)
                {
                    continue;
                }
                int data2 = data[i] % 13;
                if (data1.Contains(data2))
                {
                    continue;
                }
                int count = 0;
                for (int j = 0; j < data.Length; j++)
                {
                    if (data[j] == 52 || data[j] == 53)
                    {
                        continue;
                    }
                    int data3 = data[j] % 13;
                    if (data2 == data3)
                    {
                        count++;
                    }
                }
                if (count == 3)
                {
                    data1.Add(data2);
                    count1++;
                }
            }
            if (count1 == 3)
            {
                for (int i = 0; i < data1.Count; i++)
                {
                    if (i != data1.Count - 1)
                    {
                        int m1 = data1[i];
                        int m2 = data1[i + 1];
                        if (m1 == 0)
                        {
                            m1 = 13;
                        }
                        if (m2 == 0)
                        {
                            m2 = 13;
                        }
                        if (m1 - m2 != 1)
                        {
                            return false;
                        }
                    }
                }
                max = data1[0];
                return true;
            }
            return false;
        }
        /// <summary>
        /// 两个三个带四个
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool islianggesangedaisige(int[] data,out int max)
        {
            max = -1;
            if (ishavewang(data))
            {
                return false;
            }
            List<int> data1 = new List<int>();
            int count1 = 0;
            for (int i = 0; i < data.Length; i++)
            {
                int data2 = data[i] % 13;
                if (data1.Contains(data2))
                {
                    continue;
                }
                int count = 0;
                for (int j = 0; j < data.Length; j++)
                {
                    int data3 = data[j] % 13;
                    if (data2 == data3)
                    {
                        count++;
                    }
                }
                if (count == 3)
                {
                    data1.Add(data2);
                    count1++;
                }
            }
            List<int> datat = new List<int>();
            int count2 = 0;
            for (int i = 0; i < data.Length; i++)
            {
                int temp1 = data[i] % 13;
                if (data1.Contains(temp1) || datat.Contains(temp1))
                {
                    continue;
                }
                int count22 = 0;
                for (int j = 0; j < data.Length; j++)
                {
                    int temp2 = data[j] % 13;
                    if (temp1 == temp2)
                    {
                        count22++;
                    }
                }
                if (count22 == 2)
                {
                    count2++;
                    datat.Add(temp1);
                }
            }
            if (count1 == 2 && count2 == 2)
            {
                for (int i = 0; i < data1.Count; i++)
                {
                    if (i != data1.Count - 1)
                    {
                        int m1 = data1[i];
                        int m2 = data1[i + 1];
                        if (m1 == 0)
                        {
                            m1 = 13;
                        }
                        if (m2 == 0)
                        {
                            m2 = 13;
                        }
                        if (m1 - m2 != 1)
                        {
                            return false;
                        }
                    }
                }
                max = data1[0];
                return true;
            }
            return false;
        }
        /// <summary>
        /// 两个三个带两个
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool islianggesangedailiangge(int[] data,out int max)
        {
            max = -1;
            List<int> data1 = new List<int>();
            int count1 = 0;
            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] == 52 || data[i] == 53)
                {
                    continue;
                }
                int data2 = data[i] % 13;
                if (data1.Contains(data2))
                {
                    continue;
                }
                int count = 0;
                for (int j = 0; j < data.Length; j++)
                {
                    if (data[j] == 52 || data[j] == 53)
                    {
                        continue;
                    }
                    int data3 = data[j] % 13;
                    if (data2 == data3)
                    {
                        count++;
                    }
                }
                if (count == 3)
                {
                    data1.Add(data2);
                    count1++;
                }
            }
            if (count1 == 2)
            {
                for (int i = 0; i < data1.Count; i++)
                {
                    if (i != data1.Count - 1)
                    {
                        int m1 = data1[i];
                        int m2 = data1[i + 1];
                        if (m1 == 0)
                        {
                            m1 = 13;
                        }
                        if (m2 == 0)
                        {
                            m2 = 13;
                        }
                        if (m1 - m2 != 1)
                        {
                            return false;
                        }
                    }
                }
                max = data1[0];
                return true;
            }
            return false;
        }
        /// <summary>
        /// 两个三个
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool islianggesange(int[] data,out int max)
        {
            max = -1;
            List<int> data1 = new List<int>();
            int count1 = 0;
            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] == 52 || data[i] == 53)
                {
                    continue;
                }
                int data2 = data[i] % 13;
                if (data1.Contains(data2))
                {
                    continue;
                }
                int count = 0;
                for (int j = 0; j < data.Length; j++)
                {
                    if (data[j] == 52 || data[j] == 53)
                    {
                        continue;
                    }
                    int data3 = data[j] % 13;
                    if (data2 == data3)
                    {
                        count++;
                    }
                }
                if (count == 3)
                {
                    data1.Add(data2);
                    count1++;
                }
            }
            if (count1 == 2)
            {
                for (int i = 0; i < data1.Count; i++)
                {
                    if (i != data1.Count - 1)
                    {
                        int m1 = data1[i];
                        int m2 = data1[i + 1];
                        if (m1 == 0)
                        {
                            m1 = 13;
                        }
                        if (m2 == 0)
                        {
                            m2 = 13;
                        }
                        if (m1 - m2 != 1)
                        {
                            return false;
                        }
                    }
                }
                max = data1[0];
                return true;
            }
            return false;
        }
        /// <summary>
        /// 三带二
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool issandaier(int[] data,out int max)
        {
            max = -1;
            if (ishavewang(data))
            {
                return false;
            }
            List<int> data1 = new List<int>();
            int count1 = 0;
            for (int i = 0; i < data.Length; i++)
            {
                int data2 = data[i] % 13;
                if (data1.Contains(data2))
                {
                    continue;
                }
                int count = 0;
                for (int j = 0; j < data.Length; j++)
                {
                    int data3 = data[j] % 13;
                    if (data2 == data3)
                    {
                        count++;
                    }
                }
                if (count == 3)
                {
                    data1.Add(data2);
                    count1++;
                }
            }
            List<int> datat = new List<int>();
            int count2 = 0;
            for (int i = 0; i < data.Length; i++)
            {
                int temp1 = data[i] % 13;
                if (data1.Contains(temp1) || datat.Contains(temp1))
                {
                    continue;
                }
                int count22 = 0;
                for (int j = 0; j < data.Length; j++)
                {
                    int temp2 = data[j] % 13;
                    if (temp1 == temp2)
                    {
                        count22++;
                    }
                }
                if (count22 == 2)
                {
                    count2++;
                    datat.Add(temp1);
                }
            }
            if (count1 == 1 && count2 == 1)
            {
                max = data1[0];
                if (data1[0] == 0)
                {
                    max = 13;
                }
                if (data1[0] == 1)
                {
                    max = 14;
                }
                return true;
            }
            return false;
        }
        /// <summary>
        /// 三带一
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool issandaiyi(int[] data,out int max)
        {
            max = -1;
            List<int> data1 = new List<int>();
            int count1 = 0;
            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] == 52 || data[i] == 53)
                {
                    continue;
                }
                int data2 = data[i] % 13;
                if (data1.Contains(data2))
                {
                    continue;
                }
                int count = 0;
                for (int j = 0; j < data.Length; j++)
                {
                    if (data[j] == 52 || data[j] == 53)
                    {
                        continue;
                    }
                    int data3 = data[j] % 13;
                    if (data2 == data3)
                    {
                        count++;
                    }
                }
                if (count == 3)
                {
                    data1.Add(data2);
                    count1++;
                }
            }
            if (count1 == 1)
            {
                max = data[0];
                if (data1[0] == 0)
                {
                    max = 13;
                }
                if (data1[0] == 1)
                {
                    max = 14;
                }
                return true;
            }
            return false;
        }
        /// <summary>
        /// 三个不带
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool issange(int[] data,out int max)
        {
            max = -1;
            List<int> data1 = new List<int>();
            int count1 = 0;
            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] == 52 || data[i] == 53)
                {
                    continue;
                }
                int data2 = data[i] % 13;
                if (data1.Contains(data2))
                {
                    continue;
                }
                int count = 0;
                for (int j = 0; j < data.Length; j++)
                {
                    if (data[j] == 52 || data[j] == 53)
                    {
                        continue;
                    }
                    int data3 = data[j] % 13;
                    if (data2 == data3)
                    {
                        count++;
                    }
                }
                if (count == 3)
                {
                    data1.Add(data2);
                    count1++;
                }
            }
            if (count1 == 1)
            {
                max = data1[0];
                if (data1[0] == 0)
                {
                    max = 13;
                }
                if (data1[0] == 1)
                {
                    max = 14;
                }
                return true;
            }
            return false;
        }
        /// <summary>
        /// 四带二
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool issidaier(int[] data,out int max)
        {
            max = -1;
            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] == 52 || data[i] == 53)
                {
                    continue;
                }
                int data1 = data[i] % 13;
                int count1=0;
                for (int j = 0; j < data.Length; j++)
                {
                    if (data[j] == 52 || data[j] == 53)
                    {
                        continue;
                    }
                    int data2 = data[j] % 13;
                    if (data1 == data2)
                    {
                        count1++;
                    }
                }
                if (count1 == 4)
                {
                    max = data1;
                    if (data1 == 0)
                    {
                        max = 13;
                    }
                    if (data1 == 1)
                    {
                        max = 14;
                    }
                    return true;
                }
            }
            return false;
        }
        /// <summary>
        /// 炸弹
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool iszhadan(int[] data,out int max)
        {
            max = -1;
            if (ishavewang(data))
            {
                return false;
            }
            int data1 = data[0] % 13;
            int data2 = data[1] % 13;
            int data3 = data[2] % 13;
            int data4 = data[3] % 13;
            if (data1 == data2 && data1 == data3 && data1 == data4)
            {
                max = data1;
                if (data1 == 0)
                {
                    max = 13;
                }
                if (data1 == 1)
                {
                    max = 14;
                }
                return true;
            }
            return false;
        }
        public bool iswangzha(int[] data,out int max)
        {
            max = 16;
            if (data[0] == 53 && data[1] == 52)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public bool isok(int[] data,out int max)
        {
            max = -1;
            int temp=-1;
            switch (data.Length)
            {
                case 1:
                    if (data[0]%13 == 0)
                    {
                        max = 13;
                    }
                    if (data[0]%13 == 1)
                    {
                        max = 14;
                    }
                    if (data[0] == 52)
                    {
                        max = 15;
                    }
                    if (data[0] == 53)
                    {
                        max = 16;
                    }
                    max = data[0] % 13;
                    return true;
                    break;
                case 2:
                    if (isduizi(data,out temp)||iswangzha(data,out temp))
                    {
                        max = temp;
                        return true;
                    }
                    break;
                case 3:
                    if (issange(data,out temp))
                    {
                        max = temp;
                        return true;
                    }
                    break;
                case 4:
                    if (issandaiyi(data,out temp)||iszhadan(data,out temp))
                    {
                        max = temp;
                        return true;
                    }
                    break;
                case 5:
                    if (issandaier(data,out temp) || isdanshun(data,out temp))
                    {
                        max = temp;
                        return true;
                    }
                    break;
                case 6:
                    if (isdanshun(data,out temp) || isshuangshun(data,out temp) || islianggesange(data,out temp) || issidaier(data,out temp))
                    {
                        max = temp;
                        return true;
                    }
                    break;
                case 7:
                    if (isdanshun(data,out temp))
                    {
                        max = temp;
                        return true;
                    }
                    break;
                case 8:
                    if (isdanshun(data, out temp) || isshuangshun(data, out temp) || islianggesangedailiangge(data, out temp))
                    {
                        max = temp;
                        return true;
                    }
                    break;
                case 9:
                    if (isdanshun(data, out temp) || issangesange(data, out temp))
                    {
                        max = temp;
                        return true;
                    }
                    break;
                case 10:
                    if (isdanshun(data, out temp) || isshuangshun(data, out temp))
                    {
                        max = temp;
                        return true;
                    }
                    break;
                case 11:
                    if (isdanshun(data, out temp))
                    {
                        max = temp;
                        return true;
                    }
                    break;
                case 12:
                    if (isdanshun(data, out temp) || isshuangshun(data, out temp) || issigesange(data, out temp) || issangesangedaisange(data, out temp))
                    {
                        max = temp;
                        return true;
                    }
                    break;
                case 13:
                    if (isdanshun(data, out temp))
                    {
                        max = temp;
                        return true;
                    }
                    break;
                case 14:
                    if (isdanshun(data, out temp) || isshuangshun(data, out temp))
                    {
                        max = temp;
                        return true;
                    }
                    break;
                case 15:
                    if (isdanshun(data, out temp) || iswugesange(data, out temp))
                    {
                        max = temp;
                        return true;
                    }
                    break;
                case 16:
                    if (isshuangshun(data, out temp) || issigesangedaisige(data, out temp))
                    {
                        max = temp;
                        return true;
                    }
                    break;
                case 18:
                    if (isshuangshun(data, out temp) || isliugesange(data, out temp))
                    {
                        max = temp;
                        return true;
                    }
                    break;
                case 20:
                    if (isshuangshun(data, out temp))
                    {
                        max = temp;
                        return true;
                    }
                    break;
                default:
                    return false;
            }
            return false;
        }
    }
    
  • 相关阅读:
    springboot p6spy 打印完整sql
    mybatis报Invalid bound statement (not found) 分析
    springboot Actuator健康检查
    springboot idea 配置热加载
    面试加笔试大全
    面试题(二)
    面试题(一)
    AJAX技术简介及入门实例
    Google的AJAX翻译程序,使你快速全球化
    ASP.NET调用javascript脚本的方法总结
  • 原文地址:https://www.cnblogs.com/alongu3d/p/3458680.html
Copyright © 2020-2023  润新知