Exemple #1
0
        internal static void Send8Cards3(MainForm form, ArrayList list, ArrayList sendCards, CurrentPoker cp, int[] suits, int rank, int suit)
        {
            int previous = 0, next = 0;

            int[][] suitCards = new int[4][];

            suitCards[0] = cp.GetSuitAllCards(suits[0]);
            suitCards[1] = cp.GetSuitAllCards(suits[1]);
            suitCards[2] = cp.GetSuitAllCards(suits[2]);
            suitCards[3] = cp.GetSuitAllCards(suits[3]);

            for (int i = 0; i < 13; i++)
            {
                //
                if (i == 0)
                {
                    previous = 0;
                }
                else if (rank == (i - 1))
                {
                    if (i == 1)
                    {
                        previous = 0;
                    }
                    else
                    {
                        previous = suitCards[0][i - 2];
                    }
                }
                else
                {
                    previous = suitCards[0][i - 1];
                }
                //
                if (i == 12)
                {
                    next = 0;
                }
                else if (rank == (i + 1))
                {
                    if (i == 11)
                    {
                        next = 0;
                    }
                    else
                    {
                        next = suitCards[0][i + 2];
                    }
                }
                else
                {
                    next = suitCards[0][i + 1];

                }


                if (IsCanSend(i, suitCards[0][i], previous, next, suit))
                {
                   
                    
                    list.Remove((suits[0] - 1) * 13 + i);
                    sendCards.Add((suits[0] - 1) * 13 + i);
                    cp.RemoveCard((suits[0] - 1) * 13 + i);
                }

                if (sendCards.Count >= 8)
                {
                    return;
                }
                //2
                if (i == 0)
                {
                    previous = 0;
                }
                else if (rank == (i - 1))
                {
                    if (i == 1)
                    {
                        previous = 0;
                    }
                    else
                    {
                        previous = suitCards[2][i - 2];
                    }
                }
                else
                {
                    previous = suitCards[2][i - 1];
                }
                //
                if (i == 12)
                {
                    next = 0;
                }
                else if (rank == (i + 1))
                {
                    if (i == 11)
                    {
                        next = 0;
                    }
                    else
                    {
                        next = suitCards[2][i + 2];
                    }
                }
                else
                {
                    next = suitCards[2][i + 1];

                }

                if (IsCanSend(i, suitCards[1][i], previous, next, suit))
                {
                    
                    list.Remove((suits[1] - 1) * 13 + i);
                    sendCards.Add((suits[1] - 1) * 13 + i);
                    cp.RemoveCard((suits[1] - 1) * 13 + i);
                }

                if (sendCards.Count >= 8)
                {
                    return;
                }
                //3.
                if (i == 0)
                {
                    previous = 0;
                }
                else if (rank == (i - 1))
                {
                    if (i == 1)
                    {
                        previous = 0;
                    }
                    else
                    {
                        previous = suitCards[2][i - 2];
                    }
                }
                else
                {
                    previous = suitCards[2][i - 1];
                }
                //
                if (i == 12)
                {
                    next = 0;
                }
                else if (rank == (i + 1))
                {
                    if (i == 11)
                    {
                        next = 0;
                    }
                    else
                    {
                        next = suitCards[2][i + 2];
                    }
                }
                else
                {
                    next = suitCards[2][i + 1];

                }

                if (IsCanSend(i, suitCards[2][i], previous, next, suit))
                {
                   
                    list.Remove((suits[2] - 1) * 13 + i);
                    sendCards.Add((suits[2] - 1) * 13 + i);
                    cp.RemoveCard((suits[2] - 1) * 13 + i);
                }

                if (sendCards.Count >= 8)
                {
                    return;
                }

                //4.
                if (sendCards.Count >= 8)
                {
                    return;
                }
                if (suit == 5)
                {
                    if (i == 0)
                    {
                        previous = 0;
                    }
                    else if (rank == (i - 1))
                    {
                        if (i == 1)
                        {
                            previous = 0;
                        }
                        else
                        {
                            previous = suitCards[3][i - 2];
                        }
                    }
                    else
                    {
                        previous = suitCards[3][i - 1];
                    }
                    //
                    if (i == 12)
                    {
                        next = 0;
                    }
                    else if (rank == (i + 1))
                    {
                        if (i == 11)
                        {
                            next = 0;
                        }
                        else
                        {
                            next = suitCards[3][i + 2];
                        }
                    }
                    else
                    {
                        next = suitCards[3][i + 1];

                    }

                    if (IsCanSend(i, suitCards[3][i], previous, next, suit))
                    {
                        list.Remove((suits[3] - 1) * 13 + i);
                        sendCards.Add((suits[3] - 1) * 13 + i);
                        cp.RemoveCard((suits[3] - 1) * 13 + i);
                    }

                    if (sendCards.Count >= 8)
                    {
                        return;
                    }
                }
                
            }
           
            //last
            if (suit < 5)
            {
                for (int i = 0; i < 13; i++)
                {
                    if (sendCards.Count >= 8)
                    {
                        return;
                    }

                    //
                    if (i == 0)
                    {
                        previous = 0;
                    }
                    else if (rank == (i - 1))
                    {
                        if (i == 1)
                        {
                            previous = 0;
                        }
                        else
                        {
                            previous = suitCards[3][i - 2];
                        }
                    }
                    else
                    {
                        previous = suitCards[3][i - 1];
                    }
                    //
                    if (i == 12)
                    {
                        next = 0;
                    }
                    else if (rank == (i + 1))
                    {
                        if (i == 11)
                        {
                            next = 0;
                        }
                        else
                        {
                            next = suitCards[3][i + 2];
                        }
                    }
                    else
                    {
                        next = suitCards[3][i + 1];

                    }


                    if (IsCanSend(i, suitCards[3][i], previous, next, suit))
                    {
                       
                        list.Remove((suits[3] - 1) * 13 + i);
                        sendCards.Add((suits[3] - 1) * 13 + i);
                        cp.RemoveCard((suits[3] - 1) * 13 + i);
                    }

                    if (sendCards.Count >= 8)
                    {

                        return;
                    }
                }
            }

            if (sendCards.Count >= 8)
            {
                return;
            }
            else
            {
                Send8Cards3(form, list, sendCards,cp, suits, rank, suit);
            }
        }
Exemple #2
0
 /// <summary>
 /// 出牌的通用做法,从CurrentPoker中删除此牌,从pokerList中删除此牌,将此牌放入出牌列表中
 /// </summary>
 /// <param name="sends">出牌数组列表</param>
 /// <param name="cp">CurrentPoker对象</param>
 /// <param name="pokerList">pokerList对象</param>
 /// <param name="number">出牌数字</param>
 internal static void SendCards(ArrayList sends,CurrentPoker cp,ArrayList pokerList,int number)
 {
     sends.Add(number);
     cp.RemoveCard(number);
     pokerList.Remove(number);
 }
Exemple #3
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;
        }