Ejemplo n.º 1
0
        //玩家甩牌时的检查,如果所有的牌都是最大的,true
        internal static bool CheckSendCards(MainForm mainForm, ArrayList minCards,int who)
        {
            //ArrayList minCards = new ArrayList();
            int[] users = CommonMethods.OtherUsers(who);

            ArrayList list = new ArrayList();
            CurrentPoker cp = new CurrentPoker();
            int suit = mainForm.currentState.Suit;
            int rank = mainForm.currentRank;
            cp.Suit = suit;
            cp.Rank = rank;

            
            for (int i = 0; i < mainForm.myCardIsReady.Count; i++)
            {
                if ((bool)mainForm.myCardIsReady[i])
                {
                    list.Add(mainForm.myCardsNumber[i]);
                }
            }

            int firstSuit = CommonMethods.GetSuit((int)list[0],cp.Suit,cp.Rank);

            cp = CommonMethods.parse(list, cp.Suit, cp.Rank);
            cp.Sort();

           

            if (list.Count == 1) //如果是单张牌
            {
                return true;
            }
            else if (list.Count == 2 && (cp.GetPairs().Count == 1)) //如果是一对
            {
                return true;
            }
            else if (list.Count == 4 && (cp.HasTractors())) //如果是拖拉机
            {
                return true;
            }
            else //我甩混合牌时
            {
                if (cp.HasTractors())
                {
                    int myMax = cp.GetTractor();
                    int[] ttt = cp.GetTractorOtherCards(myMax);
                    cp.RemoveCard(myMax);
                    cp.RemoveCard(myMax);
                    cp.RemoveCard(ttt[1]);
                    cp.RemoveCard(ttt[1]);

                    int[] myMaxs = cp.GetTractorOtherCards(myMax);
                    int max4 = mainForm.currentPokers[users[0]].GetTractor(firstSuit);
                    int max2 = mainForm.currentPokers[users[1]].GetTractor(firstSuit);
                    int max3 = mainForm.currentPokers[users[2]].GetTractor(firstSuit);
                    if (!CommonMethods.CompareTo(myMax, max2, suit, rank, firstSuit))
                    {
                        minCards.Add(myMax);
                        minCards.Add(myMax);
                        minCards.Add(ttt[1]);
                        minCards.Add(ttt[1]);
                        return false;
                    }
                    else if (!CommonMethods.CompareTo(myMax, max3, suit, rank, firstSuit))
                    {
                        minCards.Add(myMax);
                        minCards.Add(myMax);
                        minCards.Add(ttt[1]);
                        minCards.Add(ttt[1]);
                        return false;
                    }
                    else if (!CommonMethods.CompareTo(myMax, max4, suit, rank, firstSuit))
                    {
                        minCards.Add(myMax);
                        minCards.Add(myMax);
                        minCards.Add(ttt[1]);
                        minCards.Add(ttt[1]);
                        return false;
                    }
                }

                if (cp.GetPairs().Count>0)
                {
                    ArrayList list0 = cp.GetPairs();

                    ArrayList list4 = mainForm.currentPokers[users[0]].GetPairs(firstSuit);
                    ArrayList list2 = mainForm.currentPokers[users[1]].GetPairs(firstSuit);
                    ArrayList list3 = mainForm.currentPokers[users[2]].GetPairs(firstSuit);

                    
                    int max4 = -1;
                    int max2 = -1;
                    int max3 = -1;
                    if (list4.Count > 0)
                    {
                        max4 = (int)list4[list4.Count - 1];
                    }
                    if (list3.Count > 0)
                    {
                        max3 = (int)list3[list3.Count - 1];
                    }

                    if (list2.Count > 0)
                    {
                        max2 = (int)list2[list2.Count - 1];
                    }

                    

                    for (int i = 0; i < list0.Count; i++)
                    {
                        int myMax = (int)list0[i];
                        cp.RemoveCard(myMax);
                        cp.RemoveCard(myMax);

                        if (!CommonMethods.CompareTo(myMax, max2, suit, rank, firstSuit) && max2 > -1)
                        {
                            minCards.Add(myMax);
                            minCards.Add(myMax);
                            return false;
                        }
                        else if (!CommonMethods.CompareTo(myMax, max3, suit, rank, firstSuit) && max3 > -1)
                        {
                            minCards.Add(myMax);
                            minCards.Add(myMax);
                            return false;
                        }
                        else if (!CommonMethods.CompareTo(myMax, max4, suit, rank, firstSuit) && max4 > -1)
                        {
                            minCards.Add(myMax);
                            minCards.Add(myMax);
                            return false;
                        }
                    }

                }

                //依次检查每张牌是否是最大。
                int[] cards = cp.GetCards();
                int mmax4 = mainForm.currentPokers[users[0]].GetMaxCard(firstSuit);
                int mmax2 = mainForm.currentPokers[users[1]].GetMaxCard(firstSuit);
                int mmax3 = mainForm.currentPokers[users[2]].GetMaxCard(firstSuit);
                for (int i = 0; i < 54; i++)
                {
                    if (cards[i] == 1)
                    {
                        if (!CommonMethods.CompareTo(i, mmax2, suit, rank, firstSuit))
                        {
                            minCards.Add(i);
                            return false;
                        }
                        else if (!CommonMethods.CompareTo(i, mmax3, suit, rank, firstSuit))
                        {
                            minCards.Add(i);
                            return false;
                        }
                        else if (!CommonMethods.CompareTo(i, mmax4, suit, rank, firstSuit))
                        {
                            minCards.Add(i);
                            return false;
                        }
                    }
                }
            }

            return true;
        }