Example #1
0
    //获得出牌规则
    //返回的是出牌的规则
    public Dictionary<OUTTYPE, List<List<int>>> getTip(OUTCARDRULE outCardRule, Dictionary<int, Card> data)
    {
        //出牌顺序
        Dictionary<OUTTYPE, int> outRule = AllRule[outCardRule];

        List<OUTTYPE> outType = new List<OUTTYPE>();

        Dictionary<OUTTYPE, List<List<int>>> dicList = new Dictionary<OUTTYPE, List<List<int>>>();
        //单必有
        foreach (var key in outRule.Keys)
        {
            OUTTYPE type =  (OUTTYPE)key;
            //必须有单
            if (  OUTTYPE.Single == type )
            {
                outType.Add(type);
                List<List<int>> temp = new List<List<int>>();
                List<int> l = new List<int>();
                foreach (var item in data)
                {
                    l.Add(item.Key);
                }
                l.Sort();
                for (int i = 0; i < l.Count; ++i)
                {
                    List<int> lis = new List<int>();
                    lis.Add(l[i]);
                    temp.Add(lis);
                }
                dicList.Add(type, temp);
            }
            //对子
            else if (OUTTYPE.Sub == type)
            {
                List<List<int>> temp = this.subNumber(data);
                if (temp.Count > 0)
                {
                    outType.Add(type);
                    dicList.Add(type, temp);
                }
            }
            //金花
            else if (OUTTYPE.three == type)
            {
                List<List<int>> threeList = this.threeFn(data);
                if (data.Count >= 4 && threeList.Count > 0)
                {
                    outType.Add(type);
                    if (data.Count == 4)
                    {
                        List<List<int>> temp = new List<List<int>>();
                        List<int> l = new List<int>();
                        foreach (var item in data)
                        {
                            l.Add(item.Key);
                        }
                        temp.Add(l);
                        dicList.Add(type, temp);
                    }
                    else if (data.Count == 5)
                    {
                        List<List<int>> temp = new List<List<int>>();
                        List<int> AllPosList = new List<int>();
                        AllPosList.Add(1);
                        AllPosList.Add(2);
                        AllPosList.Add(3);
                        AllPosList.Add(4);
                        AllPosList.Add(5);
                        foreach (var items in threeList)
                        {
                            int v = items[0];
                            AllPosList.Remove(v);
                        }

                        List<int> temp1 = threeList[0];
                        temp1.Add(AllPosList[0]);
                        List<int> temp2 = threeList[0];
                        temp2.Add(AllPosList[1]);
                        temp.Add(temp1);
                        temp.Add(temp2);
                        dicList.Add(type, temp);
                    }
                }
            }
            //两对
            else if (OUTTYPE.twoSub == type)
            {
                List<List<int>> l = subNumber(data);
                if ( l.Count == 2 )
                {
                    int num1 = l[0][0];
                    int num2 = l[1][0];
                    if (Mathf.Abs(num1 - num2) == 1)
                    {
                        outType.Add(type);
                        List<int> temp = new List<int>();
                        temp.Add(l[0][0]);
                        temp.Add(l[0][1]);
                        temp.Add(l[1][0]);
                        temp.Add(l[1][1]);
                        List<List<int>> s = new List<List<int>>();
                        s.Add(temp);
                        dicList.Add(type, s);
                    }
                }
            }
            //连子
            else if (OUTTYPE.straight == type)
            {
                List<List<int>> l = straightFn(data);
                if (l.Count>0)
                {
                    outType.Add(type);
                    dicList.Add(type,l);
                }
            }
            //炸弹
            else if (OUTTYPE.bomb == type)
            {
                List<List<int>> l = bombFn(data);
                if (l.Count>0)
                {
                    outType.Add(type);
                    dicList.Add(type,l);
                }
            }
            //王炸
            else if (OUTTYPE.kingBomb == type)
            {
                List<List<int>> l = kingBombFn(data);
                if (l.Count>0)
                {
                    outType.Add(type);
                    dicList.Add(type,l);
                }
            }
        }
        return dicList;
    }
Example #2
0
    //获得出牌规则
    //返回的是出牌的规则
    public Dictionary <OUTTYPE, List <List <int> > > getTip(OUTCARDRULE outCardRule, Dictionary <int, Card> data)
    {
        //出牌顺序
        Dictionary <OUTTYPE, int> outRule = AllRule[outCardRule];

        List <OUTTYPE> outType = new List <OUTTYPE>();

        Dictionary <OUTTYPE, List <List <int> > > dicList = new Dictionary <OUTTYPE, List <List <int> > >();

        //单必有
        foreach (var key in outRule.Keys)
        {
            OUTTYPE type = (OUTTYPE)key;
            //必须有单
            if (OUTTYPE.Single == type)
            {
                outType.Add(type);
                List <List <int> > temp = new List <List <int> >();
                List <int>         l    = new List <int>();
                foreach (var item in data)
                {
                    l.Add(item.Key);
                }
                l.Sort();
                for (int i = 0; i < l.Count; ++i)
                {
                    List <int> lis = new List <int>();
                    lis.Add(l[i]);
                    temp.Add(lis);
                }
                dicList.Add(type, temp);
            }
            //对子
            else if (OUTTYPE.Sub == type)
            {
                List <List <int> > temp = this.subNumber(data);
                if (temp.Count > 0)
                {
                    outType.Add(type);
                    dicList.Add(type, temp);
                }
            }
            //金花
            else if (OUTTYPE.three == type)
            {
                List <List <int> > threeList = this.threeFn(data);
                if (data.Count >= 4 && threeList.Count > 0)
                {
                    outType.Add(type);
                    if (data.Count == 4)
                    {
                        List <List <int> > temp = new List <List <int> >();
                        List <int>         l    = new List <int>();
                        foreach (var item in data)
                        {
                            l.Add(item.Key);
                        }
                        temp.Add(l);
                        dicList.Add(type, temp);
                    }
                    else if (data.Count == 5)
                    {
                        List <List <int> > temp       = new List <List <int> >();
                        List <int>         AllPosList = new List <int>();
                        AllPosList.Add(1);
                        AllPosList.Add(2);
                        AllPosList.Add(3);
                        AllPosList.Add(4);
                        AllPosList.Add(5);
                        foreach (var items in threeList)
                        {
                            int v = items[0];
                            AllPosList.Remove(v);
                        }

                        List <int> temp1 = threeList[0];
                        temp1.Add(AllPosList[0]);
                        List <int> temp2 = threeList[0];
                        temp2.Add(AllPosList[1]);
                        temp.Add(temp1);
                        temp.Add(temp2);
                        dicList.Add(type, temp);
                    }
                }
            }
            //两对
            else if (OUTTYPE.twoSub == type)
            {
                List <List <int> > l = subNumber(data);
                if (l.Count == 2)
                {
                    int num1 = l[0][0];
                    int num2 = l[1][0];
                    if (Mathf.Abs(num1 - num2) == 1)
                    {
                        outType.Add(type);
                        List <int> temp = new List <int>();
                        temp.Add(l[0][0]);
                        temp.Add(l[0][1]);
                        temp.Add(l[1][0]);
                        temp.Add(l[1][1]);
                        List <List <int> > s = new List <List <int> >();
                        s.Add(temp);
                        dicList.Add(type, s);
                    }
                }
            }
            //连子
            else if (OUTTYPE.straight == type)
            {
                List <List <int> > l = straightFn(data);
                if (l.Count > 0)
                {
                    outType.Add(type);
                    dicList.Add(type, l);
                }
            }
            //炸弹
            else if (OUTTYPE.bomb == type)
            {
                List <List <int> > l = bombFn(data);
                if (l.Count > 0)
                {
                    outType.Add(type);
                    dicList.Add(type, l);
                }
            }
            //王炸
            else if (OUTTYPE.kingBomb == type)
            {
                List <List <int> > l = kingBombFn(data);
                if (l.Count > 0)
                {
                    outType.Add(type);
                    dicList.Add(type, l);
                }
            }
        }
        return(dicList);
    }