示例#1
0
        //检查单牌是否可加到顺子中,返回剩余牌
        public List <int> CheckSingleAsShun(List <int> handCard, ref CardVector vec)
        {
            CardVector      shunVec = vec;
            List <CardSize> keys    = shunVec.GetKeys();

            if (0 == keys.Count)
            {
                return(handCard);
            }

            List <int> lastCards = new List <int>();

            foreach (int card in handCard)
            {
                bool suc = false;
                foreach (CardSize key in keys)
                {
                    List <int> items = shunVec.Get(key);
                    if (0 == items.Count)
                    {
                        continue;
                    }

                    CardSize min = GetCardSize(items[0]);
                    CardSize max = GetCardSize(items[items.Count - 1]);
                    CardSize val = GetCardSize(card);
                    if (val == min - 1)
                    {
                        items.Insert(0, (int)val);
                        suc = true;
                        break;
                    }
                    else if (val == max + 1)
                    {
                        items.Add((int)val);
                        suc = true;
                        break;
                    }
                }
                if (!suc)
                {
                    lastCards.Add(card);
                }
            }
            return(lastCards);
        }
示例#2
0
        //去除对子至Vector对象,返回剩余牌
        public List <int> GetTwoCard(List <int> handCard, ref CardVector vec, bool matchThree = false)
        {
            List <int> lastCards = GetSameCard(handCard, 2, ref vec);

            if (matchThree)
            {
                CardVector threeVec = new CardVector(DeckType.Three);
                lastCards = GetSameCard(handCard, 3, ref threeVec);
                if (0 < threeVec.GetCount())
                {
                    List <CardSize> keys = threeVec.GetKeys();
                    foreach (CardSize key in keys)
                    {
                        List <int> val = threeVec.Get(key);
                        List <int> arr = new List <int>();
                        CopyList(val, ref arr, 0, 2);
                        vec.Add(key, arr);
                    }
                }
            }

            return(lastCards);
        }