Exemplo n.º 1
0
        /// <summary>
        /// 小于0,倒水
        /// </summary>
        /// <param name="list1"></param>
        /// <param name="line1"></param>
        /// <param name="list2"></param>
        /// <param name="line2"></param>
        /// <returns></returns>
        int MatchListType(List <int> list1, int line1, List <int> list2, int line2)
        {
            if (list1 == null || list1.Count < 1 || list2 == null || list2.Count < 1)
            {
                return(0);
            }
            var      vnList1 = new VnList(list1);
            var      vnList2 = new VnList(list2);
            CardType type1   = CheckCardType(list1, line1);
            CardType type2   = CheckCardType(list2, line2);

            YxDebug.Log(string.Format(" === 第{0}行牌型为{1} , 第{2}行牌型为{3} === ", line1, type1, line2, type2));

            int result = type1 - type2;
            int dif    = line1 - line2;

            if (result == 0)
            {
                for (int i = 0; i < vnList2.Count; i++)
                {
                    if (vnList1[i].Val != vnList2[i].Val)
                    {
                        return(vnList1[i].Val.CompareTo(vnList2[i].Val) * dif);
                    }
                }
            }
            return(result * dif);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取按钮状态位,同时初始化字典
        /// </summary>
        /// <param name="pokerList"></param>
        /// <returns></returns>
        private int GetBtnState(List <int> pokerList)
        {
            if (pokerList.Count < 3)
            {
                return(0);
            }

            int btnState = 0;


            CnList cnList = new CnList(pokerList);
            VnList vnList = new VnList(pokerList);

            CnList cn5 = cnList.GetMoreThan(5, true, true);     //同花色5个以上
            VnList vn2 = vnList.GetMoreThan(2, true);           //同数值的2个以上

            _cardTypeDic.Clear();

            //同花顺,128
            if (cn5.Count > 0)
            {
                foreach (var cnItem in cn5)
                {
                    if (HaveAndAdd(cnItem.Cards, CardType.tonghuashun, CardType.tonghuashun))
                    {
                        btnState |= GetStateVal(CardType.tonghuashun);
                    }
                }
            }

            //铁支
            VnList vn4 = vnList.GetEqual(4, true);

            if (vn4.Count > 0)
            {
                foreach (var item in vn4)
                {
                    SssDun dun = new SssDun
                    {
                        CardType = CardType.tiezhi,
                        Cards    = item.Cards
                    };
                    AddToDic(_cardTypeDic, CardType.tiezhi, dun);
                }
                btnState |= GetStateVal(CardType.tiezhi);
            }

            VnList vn3 = vnList.GetMoreThan(3, true);

            //葫芦
            if (vn3.Count > 0 && vn2.Count > 0)
            {
                foreach (var item3 in vn3)
                {
                    foreach (var item2 in vn2)
                    {
                        if (item3.Val == item2.Val)
                        {
                            continue;
                        }

                        AddListToDic(CardType.hulu, _cardTypeDic, item3.Cards.GetRange(0, 3), item2.Cards.GetRange(0, 2));

                        btnState |= GetStateVal(CardType.hulu);
                    }
                }
            }

            //同花
            if (cn5.Count > 0)
            {
                btnState = cn5.Where(item => HaveAndAdd(item.Cards, CardType.tonghua))
                           .Aggregate(btnState, (current, item) => current | GetStateVal(CardType.tonghua));
            }

            //顺子
            {
                List <SssDun> dunList = new List <SssDun>();
                HelpLz        help    = new HelpLz();
                if (help.CheckShunZi(pokerList, dunList, 5, false))
                {
                    foreach (var dun in dunList)
                    {
                        AddToDic(_cardTypeDic, CardType.shunzi, dun);
                    }
                    btnState |= GetStateVal(CardType.shunzi);
                }
            }

            //三条
            if (vn3.Count > 0)
            {
                int count = vn3.Count;
                for (int i = 0; i < count; i++)
                {
                    AddListToDic(CardType.santiao, _cardTypeDic, vn3[i].Cards.GetRange(0, 3));
                }
                btnState |= GetStateVal(CardType.santiao);
            }

            //两对
            if (vn2.Count > 1)
            {
                int count = vn2.Count;
                for (int i = 0; i < count; i++)
                {
                    int vn2Vi = vn2[i].Val;
                    for (int j = i; j < count; j++)
                    {
                        int vn2Vj = vn2[j].Val;
                        if (vn2Vi == vn2Vj)
                        {
                            continue;
                        }
                        AddListToDic(CardType.liangdui, _cardTypeDic, vn2[i].Cards.GetRange(0, 2),
                                     vn2[j].Cards.GetRange(0, 2));
                        btnState |= GetStateVal(CardType.liangdui);
                    }
                }
            }

            //对子
            if (vn2.Count > 0)
            {
                int count = vn2.Count;
                for (int i = 0; i < count; i++)
                {
                    AddListToDic(CardType.yidui, _cardTypeDic, vn2[i].Cards.GetRange(0, 2));
                }
                btnState |= GetStateVal(CardType.yidui);
            }

            return(btnState);
        }