Exemplo n.º 1
0
        /// <summary>
        /// 跟牌基本算法
        /// </summary>
        /// <param name="mainForm">主窗体</param>
        /// <param name="currentPokers">当前各家手中的扑克</param>
        /// <param name="whoseOrder">该谁出牌</param>
        /// <param name="sendedCards">whoseOrder应该出的牌</param>
        /// <param name="count">出牌数量</param>
        internal static void MustSendCards(MainForm mainForm, CurrentPoker[] currentPokers, int whoseOrder, ArrayList sendedCards, int count)
        {
            //当前的花色和Rank
            int suit = mainForm.currentState.Suit;
            int rank = mainForm.currentRank;

            //本次花色
            int firstSuit = CommonMethods.GetSuit((int)mainForm.currentSendCards[mainForm.firstSend-1][0],suit,rank);

            int sendTotal = mainForm.currentSendCards[0].Count + mainForm.currentSendCards[1].Count + mainForm.currentSendCards[2].Count + mainForm.currentSendCards[3].Count;

            if (sendTotal == count) //whoseOrder是第二个出牌
            {
                WhoseOrderIs2(mainForm, currentPokers, whoseOrder, sendedCards, count, suit, rank, firstSuit);
                
            }
            else if (sendTotal == count*2) //whoseOrder是第三个出牌
            {
                WhoseOrderIs3(mainForm, currentPokers, whoseOrder, sendedCards, count, suit, rank, firstSuit);
                
            }
            else if (sendTotal == count * 3) //whoseOrder是第四个出牌
            {
                WhoseOrderIs4(mainForm, currentPokers, whoseOrder, sendedCards, count, suit, rank, firstSuit);
               
            }
        }
Exemplo n.º 2
0
        internal SelectCardbackImage(MainForm form)
        {
            InitializeComponent();

            InitComboBox();

            this.form = form;
        }
Exemplo n.º 3
0
        internal TotalScores(MainForm form)
        {
            InitializeComponent();

            this.form = form;

            label2.Text = "第" + (form.currentState.OurTotalRound + 1) + "轮第" + (form.currentState.OurCurrentRank + 1) + "局";
            label3.Text = "第" + (form.currentState.OpposedTotalRound + 1) + "轮第" + (form.currentState.OpposedCurrentRank + 1) + "局";

            label2.Select();
        }
Exemplo n.º 4
0
        //别人已出,自己应该出的牌
        internal static ArrayList MustSendedCards(MainForm mainForm, int whoseOrder, CurrentPoker[] currentPokers, ArrayList[] currentSendCard, int suit, int rank, int count)
        {
            if (mainForm.UserAlgorithms[whoseOrder - 1] != null)
            {
                //组装牌
                string pokers = currentPokers[whoseOrder - 1].getAllCards();
                string[] allSendCards = { "", "", "", "" };
                allSendCards[0] = mainForm.currentAllSendPokers[0].getAllCards();
                allSendCards[1] = mainForm.currentAllSendPokers[1].getAllCards();
                allSendCards[2] = mainForm.currentAllSendPokers[2].getAllCards();
                allSendCards[3] = mainForm.currentAllSendPokers[3].getAllCards();
                //
                IUserAlgorithm ua = (IUserAlgorithm)mainForm.UserAlgorithms[whoseOrder - 1];
                ArrayList result = ua.MustSendCards(whoseOrder, suit, rank, mainForm.currentState.Master, mainForm.firstSend, allSendCards, currentSendCard, pokers);

                //判断合法性
                bool b1 = TractorRules.IsInvalid(mainForm, currentSendCard, result, whoseOrder);
                bool b2 = TractorRules.CheckSendCards(mainForm, result, new ArrayList(), whoseOrder);

                if (b1 && b2)
                {
                    
                    int k = result.Count;
                    for (int i = 0; i < k; i++)
                    {
                        CommonMethods.SendCards(currentSendCard[whoseOrder - 1], currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], (int)result[i]);
                    }
                }
                else
                {
                    mainForm.UserAlgorithms[whoseOrder - 1] = null;
                    MustSendCardsAlgorithm.MustSendCards(mainForm, currentPokers, whoseOrder, currentSendCard[whoseOrder - 1], count);
                }
            }
            else
            {
                MustSendCardsAlgorithm.MustSendCards(mainForm, currentPokers, whoseOrder, currentSendCard[whoseOrder - 1], count);
            }



            for (int i = 0; i < currentSendCard[whoseOrder - 1].Count; i++)
            {
                mainForm.currentAllSendPokers[whoseOrder - 1].AddCard((int)currentSendCard[whoseOrder - 1][i]);
            }

            return currentSendCard[whoseOrder - 1];
            
        }
Exemplo n.º 5
0
        internal static void Send8Cards(MainForm form, int user)
        {
           

            int suit = form.currentState.Suit;
            int rank = form.currentRank;

            int[] cardsTotal = new int[4];

            CurrentPoker cp = new CurrentPoker();
            cp.Suit = suit;
            cp.Rank = rank;
            cp = CommonMethods.parse(form.pokerList[user - 1],suit,rank);

            for (int i = 0; i < 13;i++)
            {
                
                    cardsTotal[0] += cp.HeartsNoRank[i];
               
                    cardsTotal[1] += cp.PeachsNoRank[i];
                
                    cardsTotal[2] += cp.DiamondsNoRank[i];
                
                    cardsTotal[3] += cp.ClubsNoRank[i];
                
            }
            if (rank == 12) //打A时K最大
            {
                
                    cardsTotal[0] -= cp.HeartsNoRank[11];
               
                    cardsTotal[1] -= cp.PeachsNoRank[11];
               
                    cardsTotal[2] -= cp.DiamondsNoRank[11];
                
                    cardsTotal[3] -= cp.ClubsNoRank[11];
                
            }
            else if (rank < 12)
            {
                
                    cardsTotal[0] -= cp.HeartsNoRank[12];
                
                    cardsTotal[1] -= cp.PeachsNoRank[12];
                
                    cardsTotal[2] -= cp.DiamondsNoRank[12];
               
                    cardsTotal[3] -= cp.ClubsNoRank[12];
               
            }


            if (form.gameConfig.BottomAlgorithm == 1)
            {
                //算法1:扣绝一门
                Send8Cards1(form,form.pokerList[user - 1], form.send8Cards, cp, GetOrder(cardsTotal,suit),rank,suit);
            }
            else if (form.gameConfig.BottomAlgorithm == 2) //中庸
            {
                //算法2:扣绝副牌最小者
                Send8Cards2(form, form.pokerList[user - 1], form.send8Cards, cp, GetOrder(cardsTotal, suit), rank, suit);
            }
            else if (form.gameConfig.BottomAlgorithm == 3) //保守
            {
                //算法2:扣绝副牌最小者
                Send8Cards3(form, form.pokerList[user - 1], form.send8Cards, cp, GetOrder(cardsTotal, suit), rank, suit);
            }
            else
            {
                Send8Cards1(form, form.pokerList[user - 1], form.send8Cards, cp, GetOrder(cardsTotal, suit), rank, suit);
            }

            form.initSendedCards();
            form.currentState.CurrentCardCommands = CardCommands.DrawMySortedCards;
        }
Exemplo n.º 6
0
        //最后一把是否护住了底
        internal static bool IsMasterOK(MainForm mainForm, int who)
        {
            bool success = false;

            if (mainForm.currentState.Master == 1)
            {
                if ((who == 1) || (who == 2))
                {
                    success = true;
                }
            }
            else if (mainForm.currentState.Master == 2)
            {
                if ((who == 1) || (who == 2))
                {
                    success = true;
                    
                }
               
            }
            else if (mainForm.currentState.Master == 3)
            {
                if ((who == 3) || (who == 4))
                {
                    success = true;
                }
                
            }
            else if (mainForm.currentState.Master == 4)
            {
                if ((who == 3) || (who == 4))
                {
                    success = true;
                }
            }

            return success;
        }
Exemplo n.º 7
0
 internal DrawingFormHelper(MainForm mainForm)
 {
     this.mainForm = mainForm;
 }
Exemplo n.º 8
0
        internal SetSpeedDialog(MainForm form)
        {
            mainForm = form;
            InitializeComponent();

            int a1 =  (int)(25 * Math.Log10(mainForm.gameConfig.FinishedOncePauseTime / 150.0));
            int a2 = (int)(25 * Math.Log10(mainForm.gameConfig.NoRankPauseTime / 500.0));
            int a3 = (int)(25 * Math.Log10(mainForm.gameConfig.Get8CardsTime / 100.0));
            int a4 = (int)(25 * Math.Log10(mainForm.gameConfig.SortCardsTime / 100.0));
            int a5 = (int)(25 * Math.Log10(mainForm.gameConfig.FinishedThisTime / 250.0));
            int a6 = (int)(25 * Math.Log10(mainForm.gameConfig.TimerDiDa / 10.0));

            if (a1 > 50)
            {
                a1 = 50;
            }
            if (a2 > 50)
            {
                a2 = 50;
            }
            if (a3 > 50)
            {
                a3 = 50;
            }
            if (a4 > 50)
            {
                a4 = 50;
            }
            if (a5 > 50)
            {
                a5 = 50;
            }
            if (a6 > 50)
            {
                a6 = 50;
            }


            if (a1 < 0)
            {
                a1 = 0;
            }
            if (a2 < 0)
            {
                a2 = 0;
            }
            if (a3 < 0)
            {
                a3 = 0;
            }
            if (a4 < 0)
            {
                a4 = 0;
            }
            if (a5 < 0)
            {
                a5 = 0;
            }
            if (a6 < 0)
            {
                a6 = 0;
            }

            trackBar1.Value = a1;
            trackBar2.Value = a2;
            trackBar3.Value = a3;
            trackBar4.Value = a4;
            trackBar5.Value = a5;
            trackBar6.Value = a6;
        }
Exemplo n.º 9
0
        internal SelectUserAlgorithm(MainForm mainForm)
        {
            InitializeComponent();
            this.mainForm = mainForm;
            //初始化算法
            ht = new Hashtable();
            InitUserAlgorithm();

            comboBox1.Items.Add("内置的算法");
            comboBox2.Items.Add("内置的算法");
            comboBox3.Items.Add("内置的算法");
            comboBox4.Items.Add("内置的算法");

            comboBox1.SelectedIndex = 0;
            comboBox2.SelectedIndex = 0;
            comboBox3.SelectedIndex = 0;
            comboBox4.SelectedIndex = 0;

            foreach (DictionaryEntry en in ht)
            {
                int i = comboBox1.Items.Add(en.Key);
                if (mainForm.UserAlgorithms[0] != null)
                {
                    IUserAlgorithm ua = (IUserAlgorithm)mainForm.UserAlgorithms[0];
                    if (ua.Name == en.Key.ToString())
                    {
                        comboBox1.SelectedIndex = i;
                    }
                }
                i = comboBox2.Items.Add(en.Key);
                if (mainForm.UserAlgorithms[1] != null)
                {
                    IUserAlgorithm ua = (IUserAlgorithm)mainForm.UserAlgorithms[1];
                    if (ua.Name == en.Key.ToString())
                    {
                        comboBox2.SelectedIndex = i;
                    }
                }
                i = comboBox3.Items.Add(en.Key);
                if (mainForm.UserAlgorithms[2] != null)
                {
                    IUserAlgorithm ua = (IUserAlgorithm)mainForm.UserAlgorithms[2];
                    if (ua.Name == en.Key.ToString())
                    {
                        comboBox3.SelectedIndex = i;
                    }
                }
                i = comboBox4.Items.Add(en.Key);
                if (mainForm.UserAlgorithms[3] != null)
                {
                    IUserAlgorithm ua = (IUserAlgorithm)mainForm.UserAlgorithms[3];
                    if (ua.Name == en.Key.ToString())
                    {
                        comboBox4.SelectedIndex = i;
                    }
                }
            }



        }
Exemplo n.º 10
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;
        }
Exemplo n.º 11
0
        //Again
        internal static int ShouldSetRankAgain(MainForm mainForm, CurrentPoker currentPoker)
        {
            if (!(mainForm.showSuits == 1))
            {
                return 0;
            }


            int rank = currentPoker.Rank;

            if (rank == 0)
            {
                if (currentPoker.Clubs[rank] > 1)
                {
                    return 4;
                }
                else if (currentPoker.Diamonds[rank] > 1)
                {
                    return 3;
                }
                else if (currentPoker.Peachs[rank] > 1)
                {
                    return 2;
                }
                else if (currentPoker.Hearts[rank] > 1)
                {
                    return 1;
                }
            }

            int count = (currentPoker.ClubsNoRankTotal + currentPoker.DiamondsNoRankTotal + currentPoker.PeachsNoRankTotal + currentPoker.HeartsNoRankTotal) / 4;
            if (currentPoker.Clubs[rank] > 1 && (currentPoker.Clubs[rank] > count))
            {
                return 4;
            }
            else if (currentPoker.Diamonds[rank] > 1 && (currentPoker.Diamonds[rank] > count))
            {
                return 3;
            }
            else if (currentPoker.Peachs[rank] > 1 && (currentPoker.Peachs[rank] > count))
            {
                return 2;
            }
            else if (currentPoker.Hearts[rank] > 1 && (currentPoker.Hearts[rank] > count))
            {
                return 1;
            }

            //如果大家的牌都没能力反,则允许其他人继续反
            return 0;
        }
Exemplo n.º 12
0
        //计算每次的得分
        internal static void CalculateScore(MainForm mainForm)
        {
            int score = 0;

            score += GetScores(mainForm.currentSendCards[0]);
            score += GetScores(mainForm.currentSendCards[1]);
            score += GetScores(mainForm.currentSendCards[2]);
            score += GetScores(mainForm.currentSendCards[3]);

            mainForm.Scores += score;

            //mainForm.Text = mainForm.Scores + "";
        }
Exemplo n.º 13
0
        //得到底牌的分数
        internal static void Calculate8CardsScore(MainForm mainForm,int howmany)
        {
            int score = GetScores(mainForm.send8Cards);

            score = score * howmany;
            mainForm.Scores += score;
   
        }
Exemplo n.º 14
0
        //确定下一次该谁出牌
        internal static int GetNextOrder(MainForm mainForm)
        {
            CurrentPoker[] cp = new CurrentPoker[4];
            int suit = mainForm.currentState.Suit;
            int rank = mainForm.currentRank;
            cp[0] = CommonMethods.parse(mainForm.currentSendCards[0], suit, rank);
            cp[1] = CommonMethods.parse(mainForm.currentSendCards[1], suit, rank);
            cp[2] = CommonMethods.parse(mainForm.currentSendCards[2], suit, rank);
            cp[3] = CommonMethods.parse(mainForm.currentSendCards[3], suit, rank);
            cp[0].Sort();
            cp[1].Sort();
            cp[2].Sort();
            cp[3].Sort();



            int count = mainForm.currentSendCards[0].Count;
            

            int order = mainForm.firstSend;

            int firstSuit = CommonMethods.GetSuit((int)mainForm.currentSendCards[order-1][0],suit,rank);



            int[] users = CommonMethods.OtherUsers(order);

            //如果是混合牌(甩牌或者多个对),返回首家order
            if ((cp[order - 1].HasTractors()) && (cp[order - 1].Count > 4)) //有对有单张牌
            {
                int orderMax = cp[order - 1].GetTractor();
                if (cp[users[0] - 1].HasTractors() && (!cp[users[0] - 1].IsMixed()))
                {
                    int tmpMax = cp[users[0] - 1].GetTractor();
                    if (!CommonMethods.CompareTo(orderMax, tmpMax, suit, rank, firstSuit))
                    {
                        order = users[0];
                        orderMax = tmpMax;
                    }
                }
                if (cp[users[1] - 1].HasTractors() && (!cp[users[1] - 1].IsMixed()))
                {
                    int tmpMax = cp[users[1] - 1].GetTractor();
                    if (!CommonMethods.CompareTo(orderMax, tmpMax, suit, rank, firstSuit))
                    {
                        order = users[1];
                        orderMax = tmpMax;
                    }
                }
                if (cp[users[2] - 1].HasTractors() && (!cp[users[2] - 1].IsMixed()))
                {
                    int tmpMax = cp[users[2] - 1].GetTractor();
                    if (!CommonMethods.CompareTo(orderMax, tmpMax, suit, rank, firstSuit))
                    {
                        order = users[2];
                        orderMax = tmpMax;
                    }
                }
            }
            if ((cp[order -1].GetPairs().Count*2 < count) && (cp[order -1].GetPairs().Count>0)) //有对有单张牌
            {
                //如果有单个对
                int orderMax = (int)cp[order - 1].GetPairs()[0];
                if (cp[users[0] - 1].GetPairs().Count > 0 && (!cp[users[0] - 1].IsMixed()))
                {
                    int tmpMax = (int)cp[users[0] - 1].GetPairs()[0];
                    if (!CommonMethods.CompareTo(orderMax, tmpMax, suit, rank, firstSuit))
                    {
                        order = users[0];
                        orderMax = tmpMax;
                    }
                }
                if (cp[users[1] - 1].GetPairs().Count > 0 && (!cp[users[1] - 1].IsMixed()))
                {
                    int tmpMax = (int)cp[users[1] - 1].GetPairs()[0];
                    if (!CommonMethods.CompareTo(orderMax, tmpMax, suit, rank, firstSuit))
                    {
                        order = users[1];
                        orderMax = tmpMax;
                    }
                }
                if (cp[users[2] - 1].GetPairs().Count > 0 && (!cp[users[2] - 1].IsMixed()))
                {
                    int tmpMax = (int)cp[users[2] - 1].GetPairs()[0];
                    if (!CommonMethods.CompareTo(orderMax, tmpMax, suit, rank, firstSuit))
                    {
                        order = users[2];
                        orderMax = tmpMax;
                    }
                }

            }
            else if ((count> 1) && (cp[order -1].GetPairs().Count == 0)) //甩多个单张牌
            {
                int orderMax = (int)mainForm.currentSendCards[order - 1][0];
                int tmpMax = (int)mainForm.currentSendCards[users[0] - 1][0]; 
                if (!CommonMethods.CompareTo(orderMax, tmpMax, suit, rank, firstSuit))
                {
                    order = users[0];
                    orderMax = tmpMax;
                }

                tmpMax = (int)mainForm.currentSendCards[users[1] - 1][0]; 
                if (!CommonMethods.CompareTo(orderMax, tmpMax, suit, rank, firstSuit))
                {
                    order = users[1];
                    orderMax = tmpMax;
                }
                tmpMax = (int)mainForm.currentSendCards[users[2] - 1][0]; 
                if (!CommonMethods.CompareTo(orderMax, tmpMax, suit, rank, firstSuit))
                {
                    order = users[2];
                    orderMax = tmpMax;
                }
            }
            
            else if (cp[order - 1].HasTractors())
            {
                //如果有拖拉机
                int orderMax = cp[order - 1].GetTractor();
                if (cp[users[0] - 1].HasTractors())
                {
                    int tmpMax = cp[users[0] - 1].GetTractor();
                    if (!CommonMethods.CompareTo(orderMax, tmpMax, suit, rank, firstSuit))
                    {
                        order = users[0];
                        orderMax = tmpMax;
                    }
                }
                if (cp[users[1] - 1].HasTractors())
                {
                    int tmpMax = cp[users[1] - 1].GetTractor();
                    if (!CommonMethods.CompareTo(orderMax, tmpMax, suit, rank, firstSuit))
                    {
                        order = users[1];
                        orderMax = tmpMax;
                    }
                }
                if (cp[users[2] - 1].HasTractors())
                {
                    int tmpMax = cp[users[2] - 1].GetTractor();
                    if (!CommonMethods.CompareTo(orderMax, tmpMax, suit, rank, firstSuit))
                    {
                        order = users[2];
                        orderMax = tmpMax;
                    }
                }

                return order;
            }
            else if (cp[order - 1].GetPairs().Count == 1 && (count ==2))
            {
                //如果有单个对
                int orderMax = (int)cp[order - 1].GetPairs()[0];
                if (cp[users[0] - 1].GetPairs().Count>0)
                {
                    int tmpMax = (int)cp[users[0] - 1].GetPairs()[0];
                    if (!CommonMethods.CompareTo(orderMax, tmpMax, suit, rank, firstSuit))
                    {
                        order = users[0];
                        orderMax = tmpMax;
                    }
                }
                if (cp[users[1] - 1].GetPairs().Count>0)
                {
                    int tmpMax = (int)cp[users[1] - 1].GetPairs()[0];
                    if (!CommonMethods.CompareTo(orderMax, tmpMax, suit, rank, firstSuit))
                    {
                        order = users[1];
                        orderMax = tmpMax;
                    }
                }
                if (cp[users[2] - 1].GetPairs().Count>0)
                {
                    int tmpMax = (int)cp[users[2] - 1].GetPairs()[0];
                    if (!CommonMethods.CompareTo(orderMax, tmpMax, suit, rank, firstSuit))
                    {
                        order = users[2];
                        orderMax = tmpMax;
                    }
                }

                return order;
            }
            else if (count == 1)
            {
                //如果是单张牌
                int orderMax = (int)mainForm.currentSendCards[order - 1][0];
                int tmpMax = (int)mainForm.currentSendCards[users[0] - 1][0]; 
                if (!CommonMethods.CompareTo(orderMax, tmpMax, suit, rank, firstSuit))
                {
                    order = users[0];
                    orderMax = tmpMax;
                }

                tmpMax = (int)mainForm.currentSendCards[users[1] - 1][0]; 
                if (!CommonMethods.CompareTo(orderMax, tmpMax, suit, rank, firstSuit))
                {
                    order = users[1];
                    orderMax = tmpMax;
                }
                tmpMax = (int)mainForm.currentSendCards[users[2] - 1][0]; 
                if (!CommonMethods.CompareTo(orderMax, tmpMax, suit, rank, firstSuit))
                {
                    order = users[2];
                    orderMax = tmpMax;
                }

                return order;
            }

            return order;
        }
Exemplo n.º 15
0
        internal static void GetNextMasterUser(MainForm mainForm)
        {
            

            //最后一把谁赢得
            int who = GetNextOrder(mainForm);
            //确定是否护住底
            bool lastMasterOk = IsMasterOK(mainForm,who);

            CurrentPoker CP = new CurrentPoker();
            CP.Suit = mainForm.currentState.Suit;
            CP.Rank = mainForm.currentRank;
            CP = CommonMethods.parse(mainForm.currentSendCards[who - 1],CP.Suit,CP.Rank);

           
            if (!lastMasterOk)
            {
                CalculateScore(mainForm);
                int howmany = 2;

                if (CP.HasTractors()) //TODO:可能是长拖拉机
                {
                    howmany = 8;
                }
                else if (CP.GetPairs().Count > 0)
                {
                    howmany = 4;
                }
                else
                {
                    howmany = 2;
                }

                //计算总得分
                Calculate8CardsScore(mainForm, howmany);
            }


            //已经计算本次的总得分

            //是否成功晋级,小于80分,成功晋级
            bool success = mainForm.Scores < 80;
            int oldMaster = mainForm.currentState.Master;

            int master = CalculateNextMaster(mainForm, success);

            mainForm.currentState.Master = master;

            GetNextRank(mainForm, success);

            //J到底,Q到半
            if (mainForm.gameConfig.JToBottom && (CP.Rank == 9) && (!success))
            {
                if (mainForm.currentSendCards[who - 1].Contains(9) || mainForm.currentSendCards[who - 1].Contains(22) || mainForm.currentSendCards[who - 1].Contains(35) || mainForm.currentSendCards[who - 1].Contains(48))
                {
                    if ((oldMaster == 1) || (oldMaster == 2))
                    {
                        mainForm.currentState.OurCurrentRank = 0;
                    }
                    if ((oldMaster == 3) || (oldMaster == 4))
                    {
                        mainForm.currentState.OpposedCurrentRank = 0;
                    }
                }
            }
            if (mainForm.gameConfig.QToHalf && (CP.Rank == 10) && (!success))
            {
                if (mainForm.currentSendCards[who - 1].Contains(10) || mainForm.currentSendCards[who - 1].Contains(23) || mainForm.currentSendCards[who - 1].Contains(36) || mainForm.currentSendCards[who - 1].Contains(49))
                {
                    if ((oldMaster == 1) || (oldMaster == 2))
                    {
                        mainForm.currentState.OurCurrentRank = 4;
                    }
                    if ((oldMaster == 3) || (oldMaster == 4))
                    {
                        mainForm.currentState.OpposedCurrentRank = 4;
                    }
                }
            }

            if (mainForm.gameConfig.AToJ && (CP.Rank == 12) && (!success))
            {
                if (mainForm.currentSendCards[who - 1].Contains(12) || mainForm.currentSendCards[who - 1].Contains(25) || mainForm.currentSendCards[who - 1].Contains(38) || mainForm.currentSendCards[who - 1].Contains(51))
                {
                    if ((oldMaster == 1) || (oldMaster == 2))
                    {
                        mainForm.currentState.OurCurrentRank = 9;
                    }
                    if ((oldMaster == 3) || (oldMaster == 4))
                    {
                        mainForm.currentState.OpposedCurrentRank = 9;
                    }
                }
            }
        }
Exemplo n.º 16
0
        //是否成功
        internal static int CalculateNextMaster(MainForm mainForm,bool success)
        {
            int master = mainForm.currentState.Master;

            if (mainForm.currentState.Master == 1)
            {
                if (success)
                {
                    master = 2;
                }
                else
                {
                    master = 4;
                }
            }
            else if (mainForm.currentState.Master == 2)
            {
                if (success)
                {
                    master = 1;
                }
                else
                {
                    master = 3;
                }
            }
            else if (mainForm.currentState.Master == 3)
            {
                if (success)
                {
                    master = 4;
                }
                else
                {
                    master = 1;
                }
            }
            else if (mainForm.currentState.Master == 4)
            {
                if (success)
                {
                    master = 3;
                }
                else
                {
                    master = 2;
                }
            }

            return master;
        }
Exemplo n.º 17
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);
            }
        }
Exemplo n.º 18
0
        internal static void ShouldSendCards(MainForm mainForm, CurrentPoker[] currentPokers, int whoseOrder, ArrayList sendedCards)
        {
            currentPokers[0].Sort();
            currentPokers[1].Sort();
            currentPokers[2].Sort();
            currentPokers[3].Sort();

            mainForm.whoIsBigger = whoseOrder;

            //1.挑出最大的副牌出
            CurrentPoker cp = currentPokers[whoseOrder - 1];

           

            #region 如果副牌有拖拉机
            int t = cp.GetNoRankNoSuitTractor(); //副牌拖拉机
            if (t > -1)
            {
                int[] othercards = cp.GetTractorOtherCards(t);

                CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], t);
                CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], t);
                CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], othercards[1]);
                CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], othercards[1]);


                return;
            }
            #endregion // 如果副牌有拖拉机

           


            #region 如果有副牌最大的对
            if (cp.GetNoRankNoSuitPairs().Count > 0 )
            {
                

                ArrayList al = cp.GetNoRankNoSuitPairs();
                int[] max = { (int)al[al.Count - 1], (int)al[al.Count - 1] };

                bool b3 = cp.Count < 25;
                bool b1 = cp.Rank != 12 && (((int)al[al.Count - 1] % 13) == 12) ;
                bool b2 = cp.Rank == 12 && (((int)al[al.Count - 1] % 13) == 11) ;

                if (b3 || b1 || b2) //不打A时
                {

                    if (whoseOrder == 2)
                    {
                        if ((!currentPokers[2].CompareTo(max)) && (!currentPokers[3].CompareTo(max)))
                        {
                          
                            CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], max[0]);
                            CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], max[0]);


                            if ((mainForm.currentRank != 12) && (mainForm.currentRank != 11)) //同时甩A
                            {
                                if ((max[0] % 13) == 11)
                                {
                                    if (cp.GetCardCount((CommonMethods.GetSuit(max[0]) - 1) * 13 + 12) == 1)
                                    {
                                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], (CommonMethods.GetSuit(max[0]) - 1) * 13 + 12);
                                    }
                                }
                                else if ((max[0] % 13) == 12)
                                {
                                    if (cp.GetCardCount((CommonMethods.GetSuit(max[0]) - 1) * 13 + 11) == 1)
                                    {
                                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], (CommonMethods.GetSuit(max[0]) - 1) * 13 + 11);
                                    }
                                }
                            }
                            else if ((mainForm.currentRank != 12) && (mainForm.currentRank == 11)) //同时甩A
                            {
                                if ((max[0] % 13) == 10)
                                {
                                    if (cp.GetCardCount((CommonMethods.GetSuit(max[0]) - 1) * 13 + 12) == 1)
                                    {
                                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], (CommonMethods.GetSuit(max[0]) - 1) * 13 + 12);
                                    }
                                }
                                else if ((max[0] % 13) == 12)
                                {
                                    if (cp.GetCardCount((CommonMethods.GetSuit(max[0]) - 1) * 13 + 10) == 1)
                                    {
                                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], (CommonMethods.GetSuit(max[0]) - 1) * 13 + 10);
                                    }
                                }
                            }
                            else if (mainForm.currentRank == 12) //同时甩A
                            {
                                if ((max[0] % 13) == 10)
                                {
                                    if (cp.GetCardCount((CommonMethods.GetSuit(max[0]) - 1) * 13 + 11) == 1)
                                    {
                                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], (CommonMethods.GetSuit(max[0]) - 1) * 13 + 11);
                                    }
                                }
                                else if ((max[0] % 13) == 11)
                                {
                                    if (cp.GetCardCount((CommonMethods.GetSuit(max[0]) - 1) * 13 + 10) == 1)
                                    {
                                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], (CommonMethods.GetSuit(max[0]) - 1) * 13 + 10);
                                    }
                                }
                            }

                           

                            return;
                        }

                    }
                    else if (whoseOrder == 3)
                    {
                        if ((!currentPokers[0].CompareTo(max)) && (!currentPokers[1].CompareTo(max)))
                        {
                           

                            CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], max[0]);
                            CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], max[0]);

                            if ((mainForm.currentRank != 12) && (mainForm.currentRank != 11)) //同时甩A
                            {
                                if ((max[0] % 13) == 11)
                                {
                                    if (cp.GetCardCount((CommonMethods.GetSuit(max[0]) - 1) * 13 + 12) == 1)
                                    {
                                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], (CommonMethods.GetSuit(max[0]) - 1) * 13 + 12);
                                    }
                                }
                                else if ((max[0] % 13) == 12)
                                {
                                    if (cp.GetCardCount((CommonMethods.GetSuit(max[0]) - 1) * 13 + 11) == 1)
                                    {
                                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], (CommonMethods.GetSuit(max[0]) - 1) * 13 + 11);
                                    }
                                }
                            }
                            else if ((mainForm.currentRank != 12) && (mainForm.currentRank == 11)) //同时甩A
                            {
                                if ((max[0] % 13) == 10)
                                {
                                    if (cp.GetCardCount((CommonMethods.GetSuit(max[0]) - 1) * 13 + 12) == 1)
                                    {
                                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], (CommonMethods.GetSuit(max[0]) - 1) * 13 + 12);
                                    }
                                }
                                else if ((max[0] % 13) == 12)
                                {
                                    if (cp.GetCardCount((CommonMethods.GetSuit(max[0]) - 1) * 13 + 10) == 1)
                                    {
                                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], (CommonMethods.GetSuit(max[0]) - 1) * 13 + 10);
                                    }
                                }
                            }
                            else if (mainForm.currentRank == 12) //同时甩A
                            {
                                if ((max[0] % 13) == 10)
                                {
                                    if (cp.GetCardCount((CommonMethods.GetSuit(max[0]) - 1) * 13 + 11) == 1)
                                    {
                                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], (CommonMethods.GetSuit(max[0]) - 1) * 13 + 11);
                                    }
                                }
                                else if ((max[0] % 13) == 11)
                                {
                                    if (cp.GetCardCount((CommonMethods.GetSuit(max[0]) - 1) * 13 + 10) == 1)
                                    {
                                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], (CommonMethods.GetSuit(max[0]) - 1) * 13 + 10);
                                    }
                                }
                            }

                           
                            return;
                        }
                    }
                    else if (whoseOrder == 4)
                    {
                        if ((!currentPokers[0].CompareTo(max)) && (!currentPokers[1].CompareTo(max)))
                        {
                           

                            CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], max[0]);
                            CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], max[0]);

                            if ((mainForm.currentRank != 12) && (mainForm.currentRank != 11)) //同时甩A
                            {
                                if ((max[0] % 13) == 11)
                                {
                                    if (cp.GetCardCount((CommonMethods.GetSuit(max[0]) - 1) * 13 + 12) == 1)
                                    {
                                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], (CommonMethods.GetSuit(max[0]) - 1) * 13 + 12);
                                    }
                                }
                                else if ((max[0] % 13) == 12)
                                {
                                    if (cp.GetCardCount((CommonMethods.GetSuit(max[0]) - 1) * 13 + 11) == 1)
                                    {
                                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], (CommonMethods.GetSuit(max[0]) - 1) * 13 + 11);
                                    }
                                }
                            }
                            else if ((mainForm.currentRank != 12) && (mainForm.currentRank == 11)) //同时甩A
                            {
                                if ((max[0] % 13) == 10)
                                {
                                    if (cp.GetCardCount((CommonMethods.GetSuit(max[0]) - 1) * 13 + 12) == 1)
                                    {
                                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], (CommonMethods.GetSuit(max[0]) - 1) * 13 + 12);
                                    }
                                }
                                else if ((max[0] % 13) == 12)
                                {
                                    if (cp.GetCardCount((CommonMethods.GetSuit(max[0]) - 1) * 13 + 10) == 1)
                                    {
                                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], (CommonMethods.GetSuit(max[0]) - 1) * 13 + 10);
                                    }
                                }
                            }
                            else if (mainForm.currentRank == 12) //同时甩A
                            {
                                if ((max[0] % 13) == 10)
                                {
                                    if (cp.GetCardCount((CommonMethods.GetSuit(max[0]) - 1) * 13 + 11) == 1)
                                    {
                                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], (CommonMethods.GetSuit(max[0]) - 1) * 13 + 11);
                                    }
                                }
                                else if ((max[0] % 13) == 11)
                                {
                                    if (cp.GetCardCount((CommonMethods.GetSuit(max[0]) - 1) * 13 + 10) == 1)
                                    {
                                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], (CommonMethods.GetSuit(max[0]) - 1) * 13 + 10);
                                    }
                                }
                            }

                           

                            return;
                        }
                    }
                }
            }
            #endregion // 如果有副牌最大的对

           

            #region 如果有单张最大的牌
            //判断单张牌
            int maxCards = -1;
            for (int i = 1; i < 5; i++)
            {
                if (i == cp.Suit)
                {
                    continue;
                }

                maxCards = cp.GetMaxCards(i);
                if (maxCards == -1)
                {
                    continue;
                }

                if (whoseOrder == 2)
                {
                    if ((!currentPokers[2].CompareTo(maxCards)) && (!currentPokers[3].CompareTo(maxCards)))
                    {
                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], maxCards);

                       
                        return;
                    }

                }
                else if (whoseOrder == 3)
                {
                    if ((!currentPokers[0].CompareTo(maxCards)) && (!currentPokers[1].CompareTo(maxCards)))
                    {
                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], maxCards);

                      
                        return;
                    }
                }
                else if (whoseOrder == 4)
                {
                    if ((!currentPokers[0].CompareTo(maxCards)) && (!currentPokers[1].CompareTo(maxCards)))
                    {
                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], maxCards);

                        return;
                    }
                }
            }
            #endregion // 如果有单张最大的牌

          


            #region 虽然没有最大副牌,检查对家是否有最大的副牌
            for (int i = 1; i < 5; i++)
            {
                if (i == cp.Suit)
                {
                    continue;
                }

                if (whoseOrder == 2)
                {
                    maxCards = currentPokers[0].GetMaxCards(i);
                    if (maxCards == -1)
                    {
                        continue;
                    }

                    if ((!currentPokers[2].CompareTo(maxCards)) && (!currentPokers[3].CompareTo(maxCards)))
                    {
                        int max2 = currentPokers[2].GetMaxCard(i);
                        int max3 = currentPokers[2].GetMaxCard(i);

                        if (CommonMethods.CompareTo(max2, max3, cp.Suit, cp.Rank, i))
                        {
                            int rt = currentPokers[whoseOrder - 1].GetMinCardsOrScores(i);
                            if (rt > -1)
                            {
                                CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], rt);
                                return;
                            }
                        }
                    }

                }
                else if (whoseOrder == 3)
                {
                    maxCards = currentPokers[3].GetMaxCards(i);
                    if (maxCards == -1)
                    {
                        continue;
                    }
                    if ((!currentPokers[0].CompareTo(maxCards)) && (!currentPokers[1].CompareTo(maxCards)))
                    {
                        int max2 = currentPokers[2].GetMaxCard(i);
                        int max3 = currentPokers[2].GetMaxCard(i);

                        if (CommonMethods.CompareTo(max2, max3, cp.Suit, cp.Rank, i))
                        {
                            int rt = currentPokers[whoseOrder - 1].GetMinCardsOrScores(i);
                            if (rt > -1)
                            {
                                CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], rt);
                                return;
                            }
                        }
                    }
                }
                else if (whoseOrder == 4)
                {
                    maxCards = currentPokers[2].GetMaxCards(i);
                    if (maxCards == -1)
                    {
                        continue;
                    }

                    if ((!currentPokers[0].CompareTo(maxCards)) && (!currentPokers[1].CompareTo(maxCards)))
                    {
                         int max2 = currentPokers[2].GetMaxCard(i);
                        int max3 = currentPokers[2].GetMaxCard(i);

                        if (CommonMethods.CompareTo(max2, max3, cp.Suit, cp.Rank, i))
                        {
                            int rt = currentPokers[whoseOrder - 1].GetMinCardsOrScores(i);
                            if (rt > -1)
                            {
                                CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], rt);
                                return;
                            }
                        }
                    }
                }
            }
            #endregion // 虽然没有最大副牌,检查对家是否有最大的副牌

           

            //3.是否能清主

            #region 如果没有副牌可出,调主
            if (currentPokers[whoseOrder - 1].GetMasterCardsTotal() > 0)
            {
                t = currentPokers[whoseOrder - 1].GetMasterTractor();
                if (t > -1 && t != 53)
                {
                    int[] ttt = currentPokers[whoseOrder - 1].GetTractorOtherCards(t);
                    CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], t);
                    CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], t);
                    CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], ttt[1]);
                    CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], ttt[1]);

                  
                    return;
                }

                //对
                ArrayList al = currentPokers[whoseOrder - 1].GetMasterPairs();

                int[] users = CommonMethods.OtherUsers(whoseOrder);

                if (currentPokers[whoseOrder - 1].Count<= 12 && al.Count>0)
                {
                    int t1 = currentPokers[whoseOrder - 1].GetMasterCardsTotal();
                    int t2 = currentPokers[users[0] - 1].GetMasterCardsTotal();
                    int t3 = currentPokers[users[2] - 1].GetMasterCardsTotal();

                    if (t1 > t2 && t1 > t3 )
                    {
                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], (int)al[al.Count - 1]);
                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], (int)al[al.Count - 1]);
                        return;
                    }
                   
                    
                }

                int rt = currentPokers[whoseOrder - 1].GetMinCardsNoScores(cp.Suit);
                if (rt > -1 && currentPokers[whoseOrder - 1].GetCardCount(rt) == 1)
                {
                    CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], rt);
                    
                    return;
                }
                //
                if (cp.Suit != 1)
                {
                    if (cp.HeartsRankTotal == 1)
                    {
                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], cp.Rank);
                      
                        return;
                    }
                }
                if (cp.Suit != 2)
                {
                    if (cp.PeachsRankTotal == 1)
                    {
                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], cp.Rank + 13);
                   
                        return;
                    }
                }
                if (cp.Suit != 3)
                {
                    if (cp.DiamondsRankTotal == 1)
                    {
                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], cp.Rank + 26);
                     
                        return;
                    }
                }
                if (cp.Suit != 4)
                {
                    if (cp.ClubsRankTotal == 1)
                    {
                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], cp.Rank + 39);
                    
                        return;
                    }
                }

            }
            
            //调主的对

            #endregion // 如果没有副牌可出,调主

           
            //5.随便出小的副牌
            #region 不能继续调主的话,随便出一张不是分的副牌
            for (int i = 0; i < 5; i++)
            {
                if (i == cp.Suit)
                {
                    continue;
                }
                int rt = currentPokers[whoseOrder - 1].GetMinCardsNoScores(i);
                if (rt != 3 && rt != 8 && rt != 11)
                {

                    if (rt > -1)
                    {
                        CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], rt);

                        return;
                    }
                }
            }
            #endregion // 不能继续调主的话,随便出一张不是分的副牌


            

            //6.全剩主牌和分副牌,出主
            #region 全剩主牌和分副牌
            ArrayList mPairs = currentPokers[whoseOrder - 1].GetMasterPairs();
            if (mPairs.Count > 0) //先出主对
            {
                int rt = (int)mPairs[mPairs.Count - 1];
                CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], rt);
                CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], rt);
               
                return;
            }
            int maserMin = currentPokers[whoseOrder - 1].GetMinMasterCards(cp.Suit);
            //if ((maserMin > -1) && (maserMin % 13 = 3) && (maserMin % 13 = 8) && (maserMin % 13 = 11))
            if (maserMin > -1)
            {
                CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], maserMin);
               
                return;
            }

            for (int i = 1; i < 5; i++)
            {
                int rt = currentPokers[whoseOrder - 1].GetMinCards(i);
                if (rt > -1)
                {
                    CommonMethods.SendCards(sendedCards, currentPokers[whoseOrder - 1], mainForm.pokerList[whoseOrder - 1], rt);
                   
                    return;
                }
            }
            #endregion // 全剩主牌和分副牌

           
        }
Exemplo n.º 19
0
        internal static void Send8Cards2(MainForm form, ArrayList list, ArrayList sendCards, CurrentPoker cp, int[] suits, int rank, int suit)
        {
            int previous = 0, next = 0;

            int[] suitCards = cp.GetSuitAllCards(suits[0]);

            GetShouldSend8CardsNoScores(list, sendCards, suits[0], rank, suit, previous, next, suitCards);

            if (sendCards.Count < 8)
            {
                suitCards = cp.GetSuitAllCards(suits[1]);
                GetShouldSend8CardsNoScores(list, sendCards, suits[1], rank, suit, previous, next, suitCards);
            }
            if (sendCards.Count < 8)
            {
                suitCards = cp.GetSuitAllCards(suits[2]);
                GetShouldSend8CardsNoScores(list, sendCards, suits[2], rank, suit, previous, next, suitCards);
            }
            if (sendCards.Count < 8)
            {
                suitCards = cp.GetSuitAllCards(suits[3]);
                GetShouldSend8CardsNoScores(list, sendCards, suits[3], rank, suit, previous, next, suitCards);
            }

            if (sendCards.Count < 8)
            {
                suitCards = cp.GetSuitAllCards(suits[0]);
                GetShouldSend8Cards(list, sendCards, suits[0], rank, suit, previous, next, suitCards);
            }
            if (sendCards.Count < 8)
            {
                suitCards = cp.GetSuitAllCards(suits[1]);
                GetShouldSend8Cards(list, sendCards, suits[1], rank, suit, previous, next, suitCards);
            }
            if (sendCards.Count < 8)
            {
                suitCards = cp.GetSuitAllCards(suits[2]);
                GetShouldSend8Cards(list, sendCards, suits[2], rank, suit, previous, next, suitCards);
            }
            if (sendCards.Count < 8)
            {
                suitCards = cp.GetSuitAllCards(suits[3]);
                GetShouldSend8Cards(list, sendCards, suits[3], rank, suit, previous, next, suitCards);
            }

            //牌还不够
            if (sendCards.Count < 8)
            {
               Send8Cards3(form, list, sendCards, cp, suits, rank, suit);
            }
        }
Exemplo n.º 20
0
        //我是否可以亮主
        internal static bool[] CanSetRank(MainForm mainForm, CurrentPoker currentPoker)
        {
            //如果目前无人亮主
            int rank = mainForm.currentRank;
            bool[] suits = new bool[5] { false, false, false, false, false };

            //

            if (mainForm.showSuits == 0) //
            {
                if (rank != 53)
                {
                    if (currentPoker.Clubs[rank] > 0)
                    {
                        suits[3] = true;
                    }
                    else if (currentPoker.Diamonds[rank] > 0)
                    {
                        suits[2] = true;
                    }
                    else if (currentPoker.Peachs[rank] > 0)
                    {
                        suits[1] = true;
                    }
                    else if (currentPoker.Hearts[rank] > 0)
                    {
                        suits[0] = true;
                    }
                }
            }
            //可以反主
            if ((mainForm.showSuits == 1))
            {

                if (rank != 53)
                {
                    if (currentPoker.Clubs[rank] > 1)
                    {
                        //是否加固,是否允许自反
                        //
                        suits[3] = IsInvalidRank(mainForm,4);
                    }
                    else if (currentPoker.Diamonds[rank] > 1)
                    {
                        //是否加固,是否允许自反
                        suits[2] = IsInvalidRank(mainForm,3);
                    }
                    else if (currentPoker.Peachs[rank] > 1)
                    {
                        //是否加固,是否允许自反
                        suits[1] = IsInvalidRank(mainForm,2);
                    }
                    else if (currentPoker.Hearts[rank] > 1)
                    {
                        //是否加固,是否允许自反
                        suits[0] = IsInvalidRank(mainForm,1);
                    }
                }
            }

            if (mainForm.currentRank != 53)
            {
                if ((currentPoker.SmallJack == 2 || currentPoker.BigJack == 2) && (mainForm.showSuits < 3))
                {
                    //是否允许自反
                    //是否允许反无主
                    suits[4] = IsInvalidRank(mainForm, 5);
                }
            }
            return suits;
        }
Exemplo n.º 21
0
 internal CalculateRegionHelper(MainForm mainForm)
 {
     this.mainForm = mainForm;
 }
Exemplo n.º 22
0
        //whoseOrder是第三个出牌
        internal static void WhoseOrderIs3(MainForm mainForm, CurrentPoker[] currentPokers, int whoseOrder, ArrayList sendedCards, int count, int suit, int rank, int firstSuit)
        {
            ArrayList firstSendCards = mainForm.currentSendCards[mainForm.firstSend - 1]; //首家出的牌
            CurrentPoker firstCP = new CurrentPoker();
            firstCP.Suit = suit;
            firstCP.Rank = rank;
            firstCP = CommonMethods.parse(firstSendCards, suit, rank);

            int firstMax = CommonMethods.GetMaxCard(firstSendCards, suit, rank); //首家出的最大的牌
            int pairTotal = firstCP.GetPairs().Count; //首家出的对的数目

            CurrentPoker myCP = currentPokers[whoseOrder - 1]; //我手中的牌
            ArrayList myPokerList = mainForm.pokerList[whoseOrder - 1];


            //whose的此花色的牌数
            int myTotal = CommonMethods.GetSuitCount(currentPokers[whoseOrder - 1], suit, rank, firstSuit);
            //此花色的牌
            int[] cards = myCP.GetSuitCards(firstSuit);

           
            
            ArrayList myList = new ArrayList(cards);
            CurrentPoker mySuitCP = new CurrentPoker(); //我此花色的牌
            mySuitCP.Suit = suit;
            mySuitCP.Rank = rank;
            mySuitCP = CommonMethods.parse(myList, suit, rank);
            mySuitCP.Sort();

            firstCP.Sort();
            myCP.Sort();

            int[] users = CommonMethods.OtherUsers(mainForm.firstSend);

            CurrentPoker secondCP = new CurrentPoker(); //第二家出的牌
            secondCP.Suit = suit;
            secondCP.Rank = rank;
            secondCP = CommonMethods.parse(mainForm.currentSendCards[users[0]-1],suit,rank);

            //
            
            //考虑是否毕
            //将来考虑首家出的牌的大小,目前是能毕则毕
            if (myTotal == 0) 
            {
                if (firstSuit != suit)
                {
                    //如果目前最大的那一家是主 
                    int biggerMax = (int)mainForm.currentSendCards[mainForm.whoIsBigger - 1][0];
                    int[] tmpUsers = CommonMethods.OtherUsers(whoseOrder);

                    if (myCP.GetMasterCardsTotal() >= count &&  (mainForm.whoIsBigger == tmpUsers[1]) && ((biggerMax % 13) > 8))
                    {
                        //不毕,但是有可能贴的副牌也比大的那一家大
                        SendOtherSuitNoScores(sendedCards, count, firstSuit, myCP, myPokerList, true); //其他花色非分牌
                        SendOtherSuit(sendedCards, count, firstSuit, myCP, myPokerList, true); //其他花色分牌
                        SendOtherSuitNoScores(sendedCards, count, firstSuit, myCP, myPokerList, false); //其他花色非分牌
                        SendOtherSuit(sendedCards, count, firstSuit, myCP, myPokerList, false); //其他花色分牌


                        int sendOtherSuitsTotal = sendedCards.Count; //没有副牌可贴,只能出主

                        if (firstCP.HasTractors() && sendOtherSuitsTotal == 0) //单张牌
                        {
                            int minMaster = myCP.GetMasterTractor();
                            int tmpFirstTractor = firstCP.GetTractor();

                            //如果我的牌能大过最大的那家的牌

                            if ((!CommonMethods.CompareTo(tmpFirstTractor, minMaster, suit, rank, firstSuit)) && (minMaster > -1))
                            {
                                mainForm.whoIsBigger = whoseOrder;
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, minMaster);
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, minMaster);
                                int[] ttt = myCP.GetTractorOtherCards(minMaster);
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, ttt[1]);
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, ttt[1]);

                                return;
                            }
                        }
                        else if (myCP.GetMasterCardsTotal() >= count && count == 1 && sendOtherSuitsTotal ==0) //单张牌
                        {
                            int maxMaster = myCP.GetMaxMasterCards();
                            //如果我的牌能大过最大的那家的牌
                            if (!CommonMethods.CompareTo(biggerMax, maxMaster, suit, rank, firstSuit))
                            {
                                mainForm.whoIsBigger = whoseOrder;
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, maxMaster);
                                return;
                            }
                        }
                        else if (myCP.GetMasterCardsTotal() >= count &&  pairTotal == 1 && count == 2 && sendOtherSuitsTotal == 0) //出一个对时
                        {

                            ArrayList masterPairs = myCP.GetMasterPairs();
                            //如果我的牌能大过最大的那家的牌
                            if (masterPairs.Count > 0)
                            {
                                mainForm.whoIsBigger = whoseOrder;
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)masterPairs[0]);
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)masterPairs[0]);
                                return;
                            }
                        }
                        else if (myCP.GetMasterCardsTotal() >= count &&  pairTotal == 0 && count > 1 && sendOtherSuitsTotal == 0) //单张甩牌
                        {

                            int maxMaster = myCP.GetMaxMasterCards();
                            //如果我的牌能大过最大的那家的牌
                            if (!CommonMethods.CompareTo(biggerMax, maxMaster, suit, rank, firstSuit))
                            {
                                mainForm.whoIsBigger = whoseOrder;
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, maxMaster);

                                SendMasterSuitOrScores(sendedCards, count, suit, myCP, myPokerList, true);
                                SendMasterSuit(sendedCards, count, suit, myCP, myPokerList, true);
                                SendMasterSuitOrScores(sendedCards, count, suit, myCP, myPokerList, false);
                                SendMasterSuit(sendedCards, count, suit, myCP, myPokerList, false);

                                return;
                            }

                        }

                        SendMasterSuitNoScores(sendedCards, count, suit, myCP, myPokerList, true); //主牌非分牌
                        SendMasterSuit(sendedCards, count, suit, myCP, myPokerList, true); //主牌分牌
                        SendMasterSuitNoScores(sendedCards, count, suit, myCP, myPokerList, false); //主牌非分牌
                        SendMasterSuit(sendedCards, count, suit, myCP, myPokerList, false); //主牌分牌

                    }
                    else
                    {
                        if (firstCP.HasTractors()) //出一个对时
                        {
                            SendOtherSuitNoScores(sendedCards, count, firstSuit, myCP, myPokerList, true); //其他花色非分牌
                            SendOtherSuit(sendedCards, count, firstSuit, myCP, myPokerList, true); //其他花色分牌
                            SendOtherSuitNoScores(sendedCards, count, firstSuit, myCP, myPokerList, false); //其它花色非分牌
                            SendOtherSuit(sendedCards, count, firstSuit, myCP, myPokerList, false); //其他花色分牌
                        }
                        else if (myCP.GetMasterCardsTotal() >= count && count == 1) //单张牌
                        {
                            
                            int maxMaster = myCP.GetMaxMasterCards();
                            //如果我的牌能大过最大的那家的牌
                            if (!CommonMethods.CompareTo(biggerMax, maxMaster, suit, rank, firstSuit))
                            {
                                mainForm.whoIsBigger = whoseOrder;
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, maxMaster);
                                return;
                            }
                        }
                        else if (myCP.GetMasterCardsTotal() >= count &&  pairTotal == 1 && count == 2) //出一个对时
                        {
                           
                            ArrayList masterPairs = myCP.GetMasterPairs();
                            //如果我的牌能大过最大的那家的牌
                            if (masterPairs.Count > 0)
                            {
                                mainForm.whoIsBigger = whoseOrder;
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)masterPairs[0]);
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)masterPairs[0]);
                                return;
                            }
                        }
                        else if (myCP.GetMasterCardsTotal() >= count &&  pairTotal == 0 && count > 1) //单张甩牌
                        {
                           
                            int maxMaster = myCP.GetMaxMasterCards();
                            //如果我的牌能大过最大的那家的牌
                            if (!CommonMethods.CompareTo(biggerMax, maxMaster, suit, rank, firstSuit))
                            {
                                mainForm.whoIsBigger = whoseOrder;
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, maxMaster);

                                SendMasterSuitOrScores(sendedCards, count, suit, myCP, myPokerList, true);
                                SendMasterSuit(sendedCards, count, suit, myCP, myPokerList, true);
                                SendMasterSuitOrScores(sendedCards, count, suit, myCP, myPokerList, false);
                                SendMasterSuit(sendedCards, count, suit, myCP, myPokerList, false);

                                return;
                            }

                        }
                    }
                }
            }
            if (myTotal < count) //本花色少牌
            {

                for (int i = 0; i < myTotal; i++)
                {
                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, cards[i]);
                }

                SendOtherSuitNoScores(sendedCards, count, firstSuit, myCP, myPokerList,true); //其他花色非分牌
                SendOtherSuit(sendedCards, count, firstSuit, myCP, myPokerList,true); //其他花色分牌
                SendMasterSuitNoScores(sendedCards, count, suit, myCP, myPokerList,true); //主牌非分牌
                SendMasterSuit(sendedCards, count, suit, myCP, myPokerList,true); //主牌分牌


                SendOtherSuitNoScores(sendedCards, count, firstSuit, myCP, myPokerList, false); //其他花色非分牌
                SendOtherSuit(sendedCards, count, firstSuit, myCP, myPokerList, false); //其他花色分牌
                SendMasterSuitNoScores(sendedCards, count, suit, myCP, myPokerList, false); //主牌非分牌
                SendMasterSuit(sendedCards, count, suit, myCP, myPokerList, false); //主牌分牌

              

                return;

            }
            
            else if (firstCP.HasTractors())  //如果首家出了拖拉机
            {
                //如果我有拖拉机,出最大的拖拉机
                if (mySuitCP.HasTractors())
                {
                    int k = mySuitCP.GetTractor();
                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, k);
                    int[] ks = mySuitCP.GetTractorOtherCards(k);
                    for (int i = 0; i < 3; i++)
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, ks[i]);
                    }


                    CurrentPoker tmpCP = CommonMethods.parse(mainForm.currentSendCards[mainForm.whoIsBigger - 1], suit, rank);
                    int tmp = tmpCP.GetTractor();
                    if (!CommonMethods.CompareTo(tmp, k, suit, rank, firstSuit))
                    {
                        mainForm.whoIsBigger = whoseOrder;
                    }
                    
                }
                else if (mySuitCP.GetPairs().Count > 0) //如果我有对,出两个对
                {
                    ArrayList list = mySuitCP.GetPairs();
                    if (list.Count >= 2) //超过两个对
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[1]);
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[1]);
                    }
                    else
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);
                    }


                }

                //否则出最小的牌
                if (mainForm.whoIsBigger == users[1])
                {
                    SendThisSuitOrScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, true);
                    SendThisSuit(sendedCards, count, suit, firstSuit, myCP, myPokerList, true);

                    SendThisSuitOrScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);
                    SendThisSuit(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);
                }
                else
                {
                    SendThisSuitNoScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, true);
                    SendThisSuit(sendedCards, count, suit, firstSuit, myCP, myPokerList, true);

                    SendThisSuitNoScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);
                    SendThisSuit(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);
                }

               
                return;

            }
            else if (count == 1) //首家出了单张牌 
            {
                int myMax = -1;  //我的此花色的最大值
                if (firstSuit == suit)
                {
                    myMax = mySuitCP.GetMaxMasterCards();
                }
                else
                {
                    myMax = mySuitCP.GetMaxCards(firstSuit);
                }

                //第二家最大牌
                int max2 = CommonMethods.GetMaxCard(mainForm.currentSendCards[users[0]-1], suit, rank);

               

                //首家大于第二家
                if (CommonMethods.CompareTo(firstMax, max2, suit, rank,firstSuit))
                {
                    //如果第四家有比首家大的牌,我应该管住
                    int[] fourthCards = mainForm.currentPokers[users[2] - 1].GetSuitCards(firstSuit);
                    if (fourthCards.Length>0)
                    {
                        int fourthMax = fourthCards[fourthCards.Length -1];
                        if (!CommonMethods.CompareTo(firstMax, fourthMax, suit, rank, firstSuit))
                        {
                            
                            //第四家最大,我应该出最大的非分牌
                            //如果我有比第四家大的牌
                            if (CommonMethods.CompareTo(myMax, fourthMax, suit, rank, firstSuit))
                            {
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, myMax);
                            }
                            else //我也管不住
                            {
                                SendThisSuitNoScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, true);
                                SendThisSuit(sendedCards, count, suit, firstSuit, myCP, myPokerList, true);

                                SendThisSuitNoScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);
                                SendThisSuit(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);
                            }

                        }
                        else
                        {
                            SendThisSuitOrScores(sendedCards, count, suit, firstSuit, myCP, myPokerList,true);
                            SendThisSuitOrScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);
                        }
                    }
                    else
                    {
                        SendThisSuitOrScores(sendedCards, count, suit, firstSuit, myCP, myPokerList,true); //出分牌或者最小的牌
                        SendThisSuitOrScores(sendedCards, count, suit, firstSuit, myCP, myPokerList,false); //出分牌或者最小的牌
                    }

                    if ((!CommonMethods.CompareTo(firstMax, (int)sendedCards[0], suit, rank, firstSuit)) && (!CommonMethods.CompareTo(max2, (int)sendedCards[0], suit, rank, firstSuit)))
                    {
                        mainForm.whoIsBigger = whoseOrder;
                    }

                }
                else if (!CommonMethods.CompareTo(max2, myMax, suit, rank, firstSuit)) //首家最小,我的最大
                {
                    //出大牌
                    if (myMax > -1)
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, myMax);
                        mainForm.whoIsBigger = whoseOrder;


                        return;
                    }
                }



                SendThisSuitNoScores(sendedCards, count,suit, firstSuit, myCP, myPokerList,true);
                SendThisSuit(sendedCards, count,suit, firstSuit, myCP, myPokerList,true);

                SendThisSuitNoScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);
                SendThisSuit(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);

                return;

            }
            else if ((pairTotal == 1) && (count == 2)) //首家出了一个对
            {
                ArrayList list = mySuitCP.GetPairs();
                if (list.Count >= 1 && (secondCP.GetPairs().Count < 1)) //我们有对,第二家无对
                {
                    if (!CommonMethods.CompareTo((int)mainForm.currentSendCards[mainForm.firstSend-1][0],(int)list[0],suit,rank,firstSuit))
                    {
                        mainForm.whoIsBigger = whoseOrder;
                    }
                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);
                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);

                   
                    return;
                    
                }
                else if (list.Count >= 1 && (secondCP.GetPairs().Count >= 1)) //我们都有对
                {
                    int myMax = (int)list[list.Count - 1];
                   
                    int max2 = (int)secondCP.GetPairs()[0];

                    //如果我的的牌大于第二家的牌
                    if (!CommonMethods.CompareTo(max2, myMax, suit, rank,firstSuit))
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[list.Count - 1]);
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[list.Count - 1]);
                        if (!CommonMethods.CompareTo((int)mainForm.currentSendCards[mainForm.firstSend - 1][0], (int)list[0], suit, rank, firstSuit))
                        {
                            mainForm.whoIsBigger = whoseOrder;
                        }
                        
                        return;
                    }
                    else //否则
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);

                     
                        return;
                    }
                }
                else if (list.Count < 1 && secondCP.GetPairs().Count >= 1) //如果第二家也出了对,我无对
                {
                    int max2 = (int)secondCP.GetPairs()[0];
                    //首家大
                    if (CommonMethods.CompareTo(firstMax, max2, suit, rank, firstSuit))
                    {
                        SendThisSuitOrScores(sendedCards, count,suit, firstSuit, myCP, myPokerList,true);
                        SendThisSuit(sendedCards, count,suit, firstSuit, myCP, myPokerList,true);
                        SendThisSuitOrScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);
                        SendThisSuit(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);

                        
                        return;
                    }
                    else
                    {
                        SendThisSuitNoScores(sendedCards, count,suit, firstSuit, myCP, myPokerList,true);
                        SendThisSuit(sendedCards, count,suit, firstSuit, myCP, myPokerList,true);
                        SendThisSuitNoScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);
                        SendThisSuit(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);

                       
                        return;
                    }
                }
                else if (list.Count < 1 && secondCP.GetPairs().Count < 1)
                {
                    //目前只有对家出了对
                    ArrayList fourthPairs = mainForm.currentPokers[users[2] - 1].GetPairs(firstSuit);
                    if (fourthPairs.Count > 0)
                    {
                        int fourthMax = (int)fourthPairs[fourthPairs.Count-1];
                        if (!CommonMethods.CompareTo(firstMax, fourthMax, suit, rank, firstSuit))
                        {
                            //第四家最大,我应该出最大的非分牌
                            SendThisSuitNoScores(sendedCards, count, suit, firstSuit, myCP, myPokerList,true);
                            SendThisSuitNoScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);
                        }
                        else
                        {
                            SendThisSuitOrScores(sendedCards, count, suit, firstSuit, myCP, myPokerList,true);
                            SendThisSuitOrScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);
                        }
                    }
                    else
                    {
                        SendThisSuitOrScores(sendedCards, count, suit, firstSuit, myCP, myPokerList,true); //出分牌或者最小的牌
                        SendThisSuitOrScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);
                    }


                    SendThisSuit(sendedCards, count,suit, firstSuit, myCP, myPokerList,true);
                    SendThisSuit(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);

                   
                    return;
                }

            }
            else if (count == pairTotal * 2 && count > 0) //多个对,肯定首家最大
            {
                ArrayList list = mySuitCP.GetPairs();
                for (int i = 0; i < pairTotal && i < list.Count; i++)
                {
                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[i]);
                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[i]);
                }
                SendThisSuitOrScores(sendedCards, count,suit, firstSuit, myCP, myPokerList,true);
                SendThisSuitOrScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);

                return;
            }
            else //如果是甩牌
            {
                ArrayList list = mySuitCP.GetPairs();
                for (int i = 0; i < pairTotal && i < list.Count; i++)
                {
                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[i]);
                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[i]);
                }

                //否则出最小的牌
                SendThisSuitOrScores(sendedCards, count,suit, firstSuit, myCP, myPokerList,true);
                SendThisSuitOrScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);

              
                return;
            }


           

        }
Exemplo n.º 23
0
        //判断我出的牌是否合法
        internal static bool IsInvalid(MainForm mainForm, ArrayList[] currentSendedCards, int who)
        {
            
            CurrentPoker[] cp = new CurrentPoker[4];
            int suit = mainForm.currentState.Suit;
            int first = mainForm.firstSend;

            int rank = mainForm.currentRank;

            cp[who-1] = new CurrentPoker();
            cp[who - 1].Suit = suit;
            cp[who - 1].Rank = rank;

            ArrayList list = new ArrayList();
            CurrentPoker tmpCP = new CurrentPoker();
            tmpCP.Suit = suit;
            tmpCP.Rank = rank;

            for (int i = 0; i < mainForm.myCardIsReady.Count; i++)
            {
                if ((bool)mainForm.myCardIsReady[i])
                {
                    cp[who - 1].AddCard((int)mainForm.myCardsNumber[i]);
                    list.Add((int)mainForm.myCardsNumber[i]);
                }
                else
                {
                    tmpCP.AddCard((int)mainForm.myCardsNumber[i]);
                }
            }
            int[] users = CommonMethods.OtherUsers(who);

            cp[users[0] - 1] = CommonMethods.parse(mainForm.currentSendCards[users[0] - 1], suit, rank);
            cp[users[1] - 1] = CommonMethods.parse(mainForm.currentSendCards[users[1] - 1], suit, rank);
            cp[users[2] - 1] = CommonMethods.parse(mainForm.currentSendCards[users[2] - 1], suit, rank);
            cp[0].Sort();
            cp[1].Sort();
            cp[2].Sort();
            cp[3].Sort();

            

            //如果我出牌
            if (first == who)
            {
                if (cp[who -1].Count ==0)
                {
                    return false;
                }

                if (cp[who-1].IsMixed())
                {
                    return false;
                }

                return true;
            }
            else
            {
                if (list.Count != currentSendedCards[first - 1].Count)
                {
                    return false;
                }


                //得到第一个家伙出的花色
                int previousSuit = CommonMethods.GetSuit((int)currentSendedCards[first - 1][0], suit, rank);
               
                //0.如果我是混合的,则判断我手中是否还剩出的花色,如果剩,false;如果不剩;true
                if (cp[who-1].IsMixed())
                {
                    if (tmpCP.HasSomeCards(previousSuit))
                    {
                        return false;
                    }
                    else
                    {
                        return true;
                    }
                }


                //如果出的花色不一致
                int mysuit = CommonMethods.GetSuit((int)list[0], suit, rank);


                //如果确实花色不一致
                if (mysuit != previousSuit) 
                {
                    //而且确实没有此花色
                    if (tmpCP.HasSomeCards(previousSuit))
                    {
                        return false;
                    }
                    else
                    {
                        return true;
                    }
                }


                //3.别人如果出对,我也应该出对
                int firstPairs = cp[first - 1].GetPairs().Count;
                int mypairs = cp[who - 1].GetPairs().Count;
                int myCurrentPairs = mainForm.currentPokers[who - 1].GetPairs(previousSuit).Count;


                //2.如果别人出拖拉机,我如果有,也应该出拖拉机
                if (cp[first-1].HasTractors())
                {
                    if ((!cp[who - 1].HasTractors()) && (mainForm.currentPokers[who-1].GetTractor(previousSuit) > -1))
                    {
                        return false;
                    }
                    else if ((mypairs == 1) && (myCurrentPairs> 1)) //出了单个对,但是实际多于1个对
                    {
                        return false;
                    }
                    else if ((mypairs == 0) && (myCurrentPairs > 0)) //没出对,但实际有对
                    {
                        return false;
                    }
                    else
                    {
                        return true;
                    }
                }

                

                if (firstPairs > 0)
                {
                    if ((myCurrentPairs >= firstPairs) && (mypairs < firstPairs))
                    {
                        return false;
                    }
                    else
                    {
                        return true;
                    }
                }

            }
            return true;

        }
Exemplo n.º 24
0
        //whoseOrder是第四个出牌
        internal static void WhoseOrderIs4(MainForm mainForm, CurrentPoker[] currentPokers, int whoseOrder, ArrayList sendedCards, int count, int suit, int rank, int firstSuit)
        {
            ArrayList firstSendCards = mainForm.currentSendCards[mainForm.firstSend - 1]; //首家出的牌
            CurrentPoker firstCP = new CurrentPoker();
            firstCP.Suit = suit;
            firstCP.Rank = rank;
            firstCP = CommonMethods.parse(firstSendCards, suit, rank); //首家出的牌

            int firstMax = CommonMethods.GetMaxCard(firstSendCards, suit, rank); //得到首家出的最大的牌
            int pairTotal = firstCP.GetPairs().Count;

            CurrentPoker myCP = currentPokers[whoseOrder - 1];         //我的牌
            ArrayList myPokerList = mainForm.pokerList[whoseOrder - 1]; //我的牌


            //whose的此花色的牌数
            int myTotal = CommonMethods.GetSuitCount(currentPokers[whoseOrder - 1], suit, rank, firstSuit); //此花色牌数
            //此花色的牌
            int[] cards = myCP.GetSuitCards(firstSuit); //此花色的牌
           
           

            ArrayList myList = new ArrayList(cards);
            CurrentPoker mySuitCP = new CurrentPoker();  //我的此花色的牌
            mySuitCP.Suit = suit;
            mySuitCP.Rank = rank;
            mySuitCP = CommonMethods.parse(myList, suit, rank);
            mySuitCP.Sort();

            firstCP.Sort();
            myCP.Sort();

            int[] users = CommonMethods.OtherUsers(mainForm.firstSend); //其他三位用户

            CurrentPoker secondCP = new CurrentPoker();
            secondCP.Suit = suit;
            secondCP.Rank = rank;
            secondCP = CommonMethods.parse(mainForm.currentSendCards[users[0] - 1], suit, rank); //首家后下一家用户

            CurrentPoker thirdCP = new CurrentPoker();
            thirdCP.Suit = suit;
            thirdCP.Rank = rank;
            thirdCP = CommonMethods.parse(mainForm.currentSendCards[users[1] - 1], suit, rank); //首家后第二家用户

            int[] tmpUsers = CommonMethods.OtherUsers(whoseOrder);
            
            //考虑毕
            if (myTotal == 0)
            {
                if (firstSuit != suit)
                {
                    //如果目前最大的那一家是主 
                    int biggerMax = (int)mainForm.currentSendCards[mainForm.whoIsBigger - 1][0];
                    

                    if (mainForm.whoIsBigger == tmpUsers[1])
                    {
                        //不毕,但是有可能贴的副牌也比大的那一家大
                        SendOtherSuitOrScores(sendedCards, count, firstSuit, myCP, myPokerList, true); //其他花色非分牌
                        SendOtherSuit(sendedCards, count, firstSuit, myCP, myPokerList, true); //其他花色分牌
                        SendOtherSuitOrScores(sendedCards, count, firstSuit, myCP, myPokerList, false); //其它花色非分牌
                        SendOtherSuit(sendedCards, count, firstSuit, myCP, myPokerList, false); //其他花色分牌


                        int sendOtherSuitsTotal = sendedCards.Count; //没有副牌可贴,只能出主

                        if (firstCP.HasTractors() && sendOtherSuitsTotal == 0) //单张牌
                        {
                            int minMaster = myCP.GetMasterTractor();
                            int tmpFirstTractor = firstCP.GetTractor();

                            //如果我的牌能大过最大的那家的牌

                            if ((!CommonMethods.CompareTo(tmpFirstTractor, minMaster, suit, rank, firstSuit)) && (minMaster> -1))
                            {
                                mainForm.whoIsBigger = whoseOrder;
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, minMaster);
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, minMaster);
                                int[] ttt = myCP.GetTractorOtherCards(minMaster);
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, ttt[1]);
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, ttt[1]);
                            }
                        }
                        else if (myCP.GetMasterCardsTotal() >= count && count == 1 && sendOtherSuitsTotal== 0) //单张牌
                        {
                            int minMaster = myCP.GetMinMasterCards(suit);
                            //如果我的牌能大过最大的那家的牌
                            if (!CommonMethods.CompareTo(biggerMax, minMaster, suit, rank, firstSuit))
                            {
                                mainForm.whoIsBigger = whoseOrder;
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, minMaster);
                                return;
                            }
                        }
                        else if (myCP.GetMasterCardsTotal() >= count &&  pairTotal == 1 && count == 2 && sendOtherSuitsTotal == 0) //出一个对时
                        {
                            ArrayList masterPairs = myCP.GetMasterPairs();
                            //如果我的牌能大过最大的那家的牌
                            if (masterPairs.Count > 0)
                            {
                                mainForm.whoIsBigger = whoseOrder;
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)masterPairs[0]);
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)masterPairs[0]);
                                return;
                            }
                        }
                        else if (myCP.GetMasterCardsTotal() >= count &&  pairTotal == 0 && count > 1 && sendOtherSuitsTotal == 0) //单张甩牌
                        {
                            int minMaster = myCP.GetMinMasterCards(suit);
                            //如果我的牌能大过最大的那家的牌
                            if (!CommonMethods.CompareTo(biggerMax, minMaster, suit, rank, firstSuit))
                            {
                                mainForm.whoIsBigger = whoseOrder;
                                CommonMethods.SendCards(sendedCards, myCP, myPokerList, minMaster);

                                SendMasterSuitOrScores(sendedCards, count, suit, myCP, myPokerList, true);
                                SendMasterSuit(sendedCards, count, suit, myCP, myPokerList, true);
                                SendMasterSuitOrScores(sendedCards, count, suit, myCP, myPokerList, false);
                                SendMasterSuit(sendedCards, count, suit, myCP, myPokerList, false);

                                return;
                            }

                        }

                        SendMasterSuitOrScores(sendedCards, count, suit, myCP, myPokerList, true); //主非分牌
                        SendMasterSuit(sendedCards, count, suit, myCP, myPokerList, true); //主分牌
                        SendMasterSuitOrScores(sendedCards, count, suit, myCP, myPokerList, false); //主非分牌
                        SendMasterSuit(sendedCards, count, suit, myCP, myPokerList, false); //主分牌

                       
                    }
                    else
                    {
                        if (firstCP.HasTractors()) //出一个对时
                        {
                            SendOtherSuitNoScores(sendedCards, count, firstSuit, myCP, myPokerList, true); //其他花色非分牌
                            SendOtherSuit(sendedCards, count, firstSuit, myCP, myPokerList, true); //其他花色分牌
                            SendOtherSuitNoScores(sendedCards, count, firstSuit, myCP, myPokerList, false); //其它花色非分牌
                            SendOtherSuit(sendedCards, count, firstSuit, myCP, myPokerList, false); //其他花色分牌
                        }
                        else if (myCP.GetMasterCardsTotal() >= count && count == 1) //单张牌
                        {

                            //int maxMaster = myCP.GetMaxMasterCards();
                            int[] masterCards = myCP.GetSuitCards(suit);
                            for (int i = 0; i < masterCards.Length; i++)
                            {
                                //如果我的牌能大过最大的那家的牌
                                if (!CommonMethods.CompareTo(biggerMax, masterCards[i], suit, rank, firstSuit))
                                {
                                    mainForm.whoIsBigger = whoseOrder;
                                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, masterCards[i]);
                                    return;
                                }
                            }

                            SendOtherSuitNoScores(sendedCards, count, firstSuit, myCP, myPokerList, true); //其它花色非分牌
                            SendOtherSuitNoScores(sendedCards, count, firstSuit, myCP, myPokerList, false); //其它花色非分牌
                            SendOtherSuit(sendedCards, count, firstSuit, myCP, myPokerList, true); //其他花色分牌
                            SendOtherSuit(sendedCards, count, firstSuit, myCP, myPokerList, false); //其他花色分牌

                        }
                        else if (myCP.GetMasterCardsTotal() >= count &&  pairTotal == 1 && count == 2) //出一个对时
                        {
                            ArrayList masterPairs = myCP.GetMasterPairs();
                            //如果我的牌能大过最大的那家的牌
                            

                            if (masterPairs.Count > 0)
                            {
                                for (int i = 0; i < masterPairs.Count; i++)
                                {
                 
                                    if (!CommonMethods.CompareTo(biggerMax, (int)masterPairs[i], suit, rank, firstSuit))
                                    {
                                        mainForm.whoIsBigger = whoseOrder;
                                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)masterPairs[0]);
                                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)masterPairs[0]);
                                        return;
                                    }
                                   
                                }
                            }
                        }
                        else if (myCP.GetMasterCardsTotal() >= count &&  pairTotal == 0 && count > 1) //单张甩牌
                        {
                            int maxMaster = myCP.GetMaxMasterCards();
                            //如果我的牌能大过最大的那家的牌
                            int[] masterCards = myCP.GetSuitCards(suit);
                            for (int i = 0; i < masterCards.Length; i++)
                            {
                                if (!CommonMethods.CompareTo(biggerMax, masterCards[i], suit, rank, firstSuit))
                                {
                                    mainForm.whoIsBigger = whoseOrder;
                                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, masterCards[i]);

                                    SendMasterSuitOrScores(sendedCards, count, suit, myCP, myPokerList, true);
                                    SendMasterSuit(sendedCards, count, suit, myCP, myPokerList, true);
                                    SendMasterSuitOrScores(sendedCards, count, suit, myCP, myPokerList, false);
                                    SendMasterSuit(sendedCards, count, suit, myCP, myPokerList, false);

                                    return;
                                }
                            }

                        }
                    }
                }
            }
            
            if (myTotal < count) //本花色根本就不够
            {

                for (int i = 0; i < myTotal; i++) //先将此花色
                {
                    CommonMethods.SendCards(sendedCards, myCP, myPokerList,cards[i]);
                }

                if (mainForm.whoIsBigger == tmpUsers[1])
                {
                    SendOtherSuitOrScores(sendedCards, count, firstSuit, myCP, myPokerList, true); //其它花色非分牌
                    SendOtherSuit(sendedCards, count, firstSuit, myCP, myPokerList, true); //其他花色分牌
                    SendMasterSuitOrScores(sendedCards, count, suit, myCP, myPokerList, true); //主非分牌
                    SendMasterSuit(sendedCards, count, suit, myCP, myPokerList, true); //主分牌

                    SendOtherSuitOrScores(sendedCards, count, firstSuit, myCP, myPokerList, false); //其它花色非分牌
                    SendOtherSuit(sendedCards, count, firstSuit, myCP, myPokerList, false); //其他花色分牌
                    SendMasterSuitOrScores(sendedCards, count, suit, myCP, myPokerList, false); //主非分牌
                    SendMasterSuit(sendedCards, count, suit, myCP, myPokerList, false); //主分牌
                }
                else
                {
                    SendOtherSuitNoScores(sendedCards, count, firstSuit, myCP, myPokerList, true); //其它花色非分牌
                    SendOtherSuit(sendedCards, count, firstSuit, myCP, myPokerList, true); //其他花色分牌
                    SendMasterSuitNoScores(sendedCards, count, suit, myCP, myPokerList, true); //主非分牌
                    SendMasterSuit(sendedCards, count, suit, myCP, myPokerList, true); //主分牌

                    SendOtherSuitNoScores(sendedCards, count, firstSuit, myCP, myPokerList, false); //其它花色非分牌
                    SendOtherSuit(sendedCards, count, firstSuit, myCP, myPokerList, false); //其他花色分牌
                    SendMasterSuitNoScores(sendedCards, count, suit, myCP, myPokerList, false); //主非分牌
                    SendMasterSuit(sendedCards, count, suit, myCP, myPokerList, false); //主分牌
                }

             
                return;
            }
           //以下是此花色的牌比首家出的牌多
            else if (firstCP.HasTractors())  //如果首家出了拖拉机
            {
                //如果我有拖拉机,出最大的拖拉机,剩余的牌在下面出
                if (mySuitCP.HasTractors())
                {
                    int k = mySuitCP.GetTractor();
                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, k);
                    int[] ks = mySuitCP.GetTractorOtherCards(k);
                    for (int i = 0; i < 3; i++)
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, ks[i]);
                    }


                    CurrentPoker tmpCP = CommonMethods.parse(mainForm.currentSendCards[mainForm.whoIsBigger - 1], suit, rank);
                    int tmp = tmpCP.GetTractor();
                    if (!CommonMethods.CompareTo(tmp, k, suit, rank, firstSuit))
                    {
                        mainForm.whoIsBigger = whoseOrder;
                    }
                    
                }
                else if (mySuitCP.GetPairs().Count > 0) //如果有对
                {
                    ArrayList list = mySuitCP.GetPairs();
                    if (list.Count >= 2) //如果我有多个对,那至少出两个对
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[1]);
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[1]);
                       
                    }
                    else //否则只能出一个对,其余出小牌
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);
                    }


                }


                //既然大不过首家,出最小的牌
                //而且,本花色绝对可以满足出牌
                if (mainForm.whoIsBigger == tmpUsers[1])
                {
                    SendThisSuitOrScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, true); //此花色的非分的牌
                    SendThisSuit(sendedCards, count, suit, firstSuit, myCP, myPokerList, true); //此花色的分牌

                    SendThisSuitOrScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false); //此花色的非分的牌
                    SendThisSuit(sendedCards, count, suit, firstSuit, myCP, myPokerList, false); //此花色的分牌
                }
                else
                {
                    SendThisSuitNoScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, true); //此花色的非分的牌
                    SendThisSuit(sendedCards, count, suit, firstSuit, myCP, myPokerList, true); //此花色的分牌

                    SendThisSuitNoScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false); //此花色的非分的牌
                    SendThisSuit(sendedCards, count, suit, firstSuit, myCP, myPokerList, false); //此花色的分牌
                }


                return;
            }
            else if (count == 1) //单张牌,而且其哦确实有此花色的牌
            {
                int myMax = -1; //我的此花色最大牌
                if (firstSuit == suit)
                {
                    myMax = mySuitCP.GetMaxMasterCards();
                }
                else
                {
                    myMax = mySuitCP.GetMaxCards(firstSuit);
                }


                int max2 = CommonMethods.GetMaxCard(mainForm.currentSendCards[users[0] - 1], suit, rank); //第二家
                int max3 = CommonMethods.GetMaxCard(mainForm.currentSendCards[users[1] - 1], suit, rank); //第三家

               
                //对家(第二家)大
                if ((!CommonMethods.CompareTo(firstMax, max2, suit, rank,firstSuit)) && (CommonMethods.CompareTo(max2,max3,suit,rank,firstSuit)))
                {
                    SendThisSuitOrScores(sendedCards, count,suit, firstSuit, myCP, myPokerList,true);
                    SendThisSuitOrScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);

                    if (!CommonMethods.CompareTo(max2,(int)sendedCards[0],suit,rank,firstSuit))
                    {
                        mainForm.whoIsBigger = whoseOrder;
                    }
                   
                    return;
                } //我大
                else if ((!CommonMethods.CompareTo(firstMax, myMax, suit, rank, firstSuit)) && (!CommonMethods.CompareTo(max3, myMax, suit, rank, firstSuit)))
                {
                    if (myMax > -1) //这里应该永远为true
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, myMax);
                        mainForm.whoIsBigger = whoseOrder;

                        return;
                    }
                }

                SendThisSuitNoScores(sendedCards, count, suit,firstSuit, myCP, myPokerList,true); //我们不大,出小非分牌
                SendThisSuit(sendedCards, count,suit, firstSuit, myCP, myPokerList,true); //出分牌

                SendThisSuitNoScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false); //我们不大,出小非分牌
                SendThisSuit(sendedCards, count, suit, firstSuit, myCP, myPokerList, false); //出分牌

                if ((!CommonMethods.CompareTo(firstMax, (int)sendedCards[0], suit, rank, firstSuit)) && (!CommonMethods.CompareTo(max2, (int)sendedCards[0], suit, rank, firstSuit)) && (!CommonMethods.CompareTo(max3, myMax, suit, rank, firstSuit)))
                {
                    mainForm.whoIsBigger = whoseOrder;
                }

                return;
            }
            else if ((pairTotal == 1) && (count == 2)) //如果是一个对
            {
                ArrayList list = mySuitCP.GetPairs(); //我的对
                //如果我对家大
                bool b2 = secondCP.GetPairs().Count > 0; //如果对家有对
                bool b3 = thirdCP.GetPairs().Count > 0; //如果第三家也出了对

                int max2 = -1;
                int max3 = -1;

                if (b2)
                {
                    max2 = (int)secondCP.GetPairs()[0];
                }
                if (b3)
                {
                    max3 = (int)thirdCP.GetPairs()[0];
                }

                //如果我有对
                if (list.Count > 0)
                {
                    int myMax = (int)list[list.Count - 1];
                   
                    if (b2 && b3) //2,3都有对
                    {
                        //对家大
                        if ((!CommonMethods.CompareTo(firstMax, max2, suit, rank, firstSuit)) && (CommonMethods.CompareTo(max2, max3, suit, rank, firstSuit)))
                        {
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);

                            if (!CommonMethods.CompareTo(max2, (int)list[0], suit, rank, firstSuit))
                            {
                                mainForm.whoIsBigger = whoseOrder;
                            }

                         
                            return;
                        }//如果我大
                        else if ((!CommonMethods.CompareTo(firstMax, myMax, suit, rank, firstSuit)) && (!CommonMethods.CompareTo(max3, myMax, suit, rank, firstSuit)))
                        {
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[list.Count - 1]);
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[list.Count - 1]);
                            mainForm.whoIsBigger = whoseOrder;
                            
                            return;
                        }
                        else //对方大
                        {
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);

                            return;
                        }

                       

                    }
                    else if (b2 && (!b3)) //2有对,3无对
                    {
                        //对家大
                        if ((!CommonMethods.CompareTo(firstMax, max2, suit, rank, firstSuit)))
                        {
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);
                            if (!CommonMethods.CompareTo(max2, (int)list[0], suit, rank, firstSuit))
                            {
                                mainForm.whoIsBigger = whoseOrder;
                            }


                        
                            return;
                        } //我大
                        else if ((!CommonMethods.CompareTo(firstMax, myMax, suit, rank, firstSuit)))
                        {
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[list.Count - 1]);
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[list.Count - 1]);

                            mainForm.whoIsBigger = whoseOrder;
                            return;
                        }
                        else
                        {
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);

                            return;
                        }
                    }
                    else if ((!b2) && b3) //2无对,3有对
                    {
                        //如果我大
                        if ((!CommonMethods.CompareTo(firstMax, myMax, suit, rank, firstSuit)) && (!CommonMethods.CompareTo(max3, myMax, suit, rank, firstSuit)))
                        {
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[list.Count - 1]);
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[list.Count - 1]);
                            mainForm.whoIsBigger = whoseOrder;

                            return;
                        }
                        else
                        {
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);
                           
                            return;
                        }
                    }
                    else if ((!b2) && (!b3)) //2,3皆无对
                    {
                        if ((!CommonMethods.CompareTo(firstMax, myMax, suit, rank, firstSuit)))
                        {
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[list.Count - 1]);
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[list.Count - 1]);
                            mainForm.whoIsBigger = whoseOrder;
                            

                            return;
                        }
                        else
                        {
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);
                            if (!CommonMethods.CompareTo(firstMax, (int)list[0], suit, rank, firstSuit))
                            {
                                mainForm.whoIsBigger = whoseOrder;
                            }

                            return;
                        }
                    }
                }
                else //如果我无对
                {
                    if (b2 && b3) //2,3皆有对
                    {
                        //对家大
                        if ((!CommonMethods.CompareTo(firstMax, max2, suit, rank, firstSuit)) && (CommonMethods.CompareTo(max2, max3, suit, rank, firstSuit)))
                        {
                            SendThisSuitOrScores(sendedCards, count,suit, firstSuit, myCP, myPokerList,true);
                            SendThisSuitOrScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);

                            return;
                        }
                        else
                        {
                            SendThisSuitNoScores(sendedCards, count, suit,firstSuit, myCP, myPokerList,true);
                            SendThisSuit(sendedCards, count,suit, firstSuit, myCP, myPokerList,true);
                            SendThisSuitNoScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);
                            SendThisSuit(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);

                            return;
                        }
                        
                    }
                    else if (b2 && (!b3))
                    {
                        //对家大
                        if ((!CommonMethods.CompareTo(firstMax, max2, suit, rank, firstSuit)))
                        {
                            SendThisSuitOrScores(sendedCards, count,suit, firstSuit, myCP, myPokerList,true);
                            SendThisSuitOrScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);
                            return;
                        }
                        else
                        {
                            SendThisSuitNoScores(sendedCards, count, suit,firstSuit, myCP, myPokerList,true);
                            SendThisSuit(sendedCards, count,suit, firstSuit, myCP, myPokerList,true);
                            SendThisSuitNoScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);
                            SendThisSuit(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);

                            return;
                        }
                    }
                    else
                    {
                        SendThisSuitNoScores(sendedCards, count, suit,firstSuit, myCP, myPokerList,true);
                        SendThisSuit(sendedCards, count,suit, firstSuit, myCP, myPokerList,true);
                        SendThisSuitNoScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);
                        SendThisSuit(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);

                        return;
                    }
                    
                }

            }
            else if (count == pairTotal * 2 && (count > 0)) //都是对,肯定其对是最大的
            {
                ArrayList list = mySuitCP.GetPairs();
                for (int i = 0; i < pairTotal && i < list.Count; i++)
                {
                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[i]);
                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[i]);
                }

                //否则出最小的牌
                SendThisSuitNoScores(sendedCards, count, suit,firstSuit, myCP, myPokerList,true);
                SendThisSuit(sendedCards, count,suit, firstSuit, myCP, myPokerList,true);
                SendThisSuitNoScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);
                SendThisSuit(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);
              
                return;
            }
            else //有对和有单张牌,是甩牌
            {
                ArrayList list = mySuitCP.GetPairs();
                for (int i = 0; i < pairTotal && i < list.Count; i++)
                {
                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[i]);
                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[i]);
                }

                //否则出最小的牌,顺序,此花色非分牌,此花色分牌
                SendThisSuitNoScores(sendedCards, count, suit,firstSuit, myCP, myPokerList,true);
                SendThisSuit(sendedCards, count,suit, firstSuit, myCP, myPokerList,true);
                SendThisSuitNoScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);
                SendThisSuit(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);
               
                return;
            }
           
        }
Exemplo n.º 25
0
        //是否可以亮主
        internal static int ShouldSetRank(MainForm mainForm, int user)
        {
            CurrentPoker currentPoker = mainForm.currentPokers[user - 1];

            int rank = currentPoker.Rank;
            if (rank == 0 || rank == 0 || rank == 8 || rank == 11)
            {
                if (currentPoker.Clubs[rank] > 0)
                {
                    return 4;
                }
                else if (currentPoker.Diamonds[rank] > 0)
                {
                    return 3;
                }
                else if (currentPoker.Peachs[rank] > 0)
                {
                    return 2;
                }
                else if (currentPoker.Hearts[rank] > 0)
                {
                    return 1;
                }
            }

            //如果还没亮主,当然不能反牌,只可以亮牌

            int count = 0;
            int user2 = 0;
            if (currentPoker.Count == 23) //如果是摸第23张牌,基于对家的牌型亮
            {

                if (user == 2)
                {
                    user2 = 1;
                }
                else if (user == 3)
                {
                    user2 = 4;
                }
                else if (user == 4)
                {
                    user2 = 3;
                }
                else if (user == 1)
                {
                    user2 = 2;
                }
            }
            else
            {
                user2 = user;
            }

            //
            count = (mainForm.currentPokers[user2 - 1].ClubsNoRankTotal + mainForm.currentPokers[user2 - 1].DiamondsNoRankTotal + mainForm.currentPokers[user2 - 1].PeachsNoRankTotal + mainForm.currentPokers[user2 - 1].HeartsNoRankTotal) / 4;

            if (currentPoker.Clubs[rank] > 0 && (mainForm.currentPokers[user2 - 1].Clubs[rank] > count))
            {
                return 4;
            }
            else if (currentPoker.Diamonds[rank] > 0 && (mainForm.currentPokers[user2 - 1].Diamonds[rank] > count))
            {
                return 3;
            }
            else if (currentPoker.Peachs[rank] > 0 && (mainForm.currentPokers[user2 - 1].Peachs[rank] > count))
            {
                return 2;
            }
            else if (currentPoker.Hearts[rank] > 0 && (mainForm.currentPokers[user2 - 1].Hearts[rank] > count))
            {
                return 1;
            }


            return 0;
        }
Exemplo n.º 26
0
        //根据得分判断应该跳几级
        internal static void GetNextRank(MainForm mainForm, bool success)
        {
            
            int user = mainForm.currentState.Master; //打本次时的主
            int rank = 0;

            int number = 0;
            if (success)
            {
                if (mainForm.Scores == 0)  //大光
                {
                    number += 3;
                }
                else if ((mainForm.Scores >= 0) && (mainForm.Scores < 40)) //小光
                {
                    number += 2;
                }
                else
                {
                    number++;
                }
            }
            else
            {
                number = (mainForm.Scores - 80) / 40;
            }


            
            string mustRank = "," + mainForm.gameConfig.MustRank + ",";

            if ((user == 1) || (user == 2))
            {
                rank = mainForm.currentState.OurCurrentRank;
                int oldRank = rank;

                if (rank == 53)
                {
                    rank = 13;
                }
                rank += number;

                //判断是否必打
                if (oldRank < 3 && rank > 3)
                {
                    if (mustRank.IndexOf(",3,")>=0)
                    {
                        rank = 3;
                    }
                }
                else if (oldRank < 8 && rank > 8)
                {
                    if (mustRank.IndexOf(",8,") >= 0)
                    {
                        rank = 8;
                    }
                }
                else if (oldRank < 9 && rank > 9)
                {
                    if (mustRank.IndexOf(",9,") >= 0)
                    {
                        rank = 9;
                    }
                }
                else if (oldRank < 10 && rank > 10)
                {
                    if (mustRank.IndexOf(",10,") >= 0)
                    {
                        rank = 10;
                    }
                }
                else if (oldRank < 11 && rank > 11)
                {
                    if (mustRank.IndexOf(",11,") >= 0)
                    {
                        rank = 11;
                    }
                }
                else if (oldRank < 12 && rank > 12)
                {
                    if (mustRank.IndexOf(",12,") >= 0)
                    {
                        rank = 12;
                    }
                }
                else if (oldRank < 13 && rank > 13)
                {
                    if (mustRank.IndexOf(",13,") >= 0)
                    {
                        rank = 13;
                    }
                }


                if (rank > 13)
                {
                    if ((user == 1) || (user == 2))
                    {
                        mainForm.currentState.OurTotalRound++;
                    }
                    else
                    {
                        mainForm.currentState.OpposedTotalRound++;
                    }
                    rank -= 14;
                }
                else if (rank == 13)
                {
                    rank = 53;
                }

              
                mainForm.currentState.OurCurrentRank = rank;
                mainForm.currentRank = rank;
            }
            else if ((user == 3) || (user == 4))
            {
                rank = mainForm.currentState.OpposedCurrentRank;
                int oldRank = rank;

                if (rank == 53)
                {
                    rank = 13;
                }
                rank += number;

                //判断是否必打
                if (oldRank < 3 && rank > 3)
                {
                    if (mustRank.IndexOf(",3,") >= 0)
                    {
                        rank = 3;
                    }
                }
                else if (oldRank < 8 && rank > 8)
                {
                    if (mustRank.IndexOf(",8,") >= 0)
                    {
                        rank = 8;
                    }
                }
                else if (oldRank < 9 && rank > 9)
                {
                    if (mustRank.IndexOf(",9,") >= 0)
                    {
                        rank = 9;
                    }
                }
                else if (oldRank < 10 && rank > 10)
                {
                    if (mustRank.IndexOf(",10,") >= 0)
                    {
                        rank = 10;
                    }
                }
                else if (oldRank < 11 && rank > 11)
                {
                    if (mustRank.IndexOf(",11,") >= 0)
                    {
                        rank = 11;
                    }
                }
                else if (oldRank < 12 && rank > 12)
                {
                    if (mustRank.IndexOf(",12,") >= 0)
                    {
                        rank = 12;
                    }
                }
                else if (oldRank < 13 && rank > 13)
                {
                    if (mustRank.IndexOf(",13,") >= 0)
                    {
                        rank = 13;
                    }
                }

                if (rank > 13)
                {
                    rank -= 13;
                }
                else if (rank == 13)
                {
                    rank = 53;
                }

                
                mainForm.currentState.OpposedCurrentRank = rank;
                mainForm.currentRank = rank;
            }

        }
Exemplo n.º 27
0
        private static bool IsInvalidRank2(MainForm form, int suit)
        {
            //非加固时,考虑自反
            if ((suit != form.currentState.Suit) && (form.whoShowRank == 0) && (!form.gameConfig.CanMyRankAgain))  //如果不允许自反
            {
                return false;
            }

            if (!form.gameConfig.CanRankJack)  //如果不允许无主
            {
                return false;
            }

            return true;
        }
Exemplo n.º 28
0
        private static bool IsInvalidRank(MainForm form,int suit)
        {
            //是否可以加固
            if ((suit == form.currentState.Suit) && (form.whoShowRank == 0) && (!form.gameConfig.CanMyStrengthen))  //如果不允许加固
            {
                return false;
            }

            //非加固时,考虑自反
            if ((suit != form.currentState.Suit) && (form.whoShowRank == 0) && (!form.gameConfig.CanMyRankAgain))  //如果不允许自反
            {
                return false;
            }

            return true;
        }
Exemplo n.º 29
0
        //whoseOrder是第二个出牌
        internal static void WhoseOrderIs2(MainForm mainForm, CurrentPoker[] currentPokers, int whoseOrder, ArrayList sendedCards, int count, int suit, int rank, int firstSuit)
        {
            ArrayList firstSendCards = mainForm.currentSendCards[mainForm.firstSend-1]; //首家出牌
            CurrentPoker firstCP = new CurrentPoker();
            firstCP.Suit = suit;
            firstCP.Rank = rank;
            firstCP = CommonMethods.parse(firstSendCards, suit, rank);
            
            int firstMax = CommonMethods.GetMaxCard(firstSendCards, suit, rank); //首家的最大牌
            int pairTotal = firstCP.GetPairs().Count;

            CurrentPoker myCP = currentPokers[whoseOrder - 1];
            ArrayList myPokerList = mainForm.pokerList[whoseOrder - 1];


            //whose的此花色的牌数
            int myTotal = CommonMethods.GetSuitCount(currentPokers[whoseOrder - 1], suit, rank, firstSuit); 
            //此花色的牌
            int[] cards = myCP.GetSuitCards(firstSuit);

            

            ArrayList myList = new ArrayList(cards);
            CurrentPoker mySuitCP = new CurrentPoker(); //我此花色的牌
            mySuitCP.Suit = suit;
            mySuitCP.Rank = rank;
            mySuitCP = CommonMethods.parse(myList,suit,rank);
            mySuitCP.Sort();

            firstCP.Sort();

            myCP.Sort();


           //考虑毕
            if (myTotal == 0)
            {
                if (firstSuit != suit)
                {

                    if (myCP.GetMasterCardsTotal() >= count && count == 1) //单张牌
                    {
                        //如果目前最大的那一家是主 
                        int biggerMax = (int)mainForm.currentSendCards[mainForm.whoIsBigger - 1][0];
                        int maxMaster = myCP.GetMaxMasterCards();
                        //如果我的牌能大过最大的那家的牌
                        if (!CommonMethods.CompareTo(biggerMax, maxMaster, suit, rank, firstSuit))
                        {
                            mainForm.whoIsBigger = whoseOrder;
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, maxMaster);
                            return;
                        }
                    }
                    else if (myCP.GetMasterCardsTotal() >= count && pairTotal == 1 && count == 2) //出一个对时
                    {
                        //如果目前最大的那一家是主 
                        int biggerMax = (int)mainForm.currentSendCards[mainForm.whoIsBigger - 1][0];
                        ArrayList masterPairs  = myCP.GetMasterPairs();
                        //如果我的牌能大过最大的那家的牌
                        if (masterPairs.Count > 0)
                        {
                            mainForm.whoIsBigger = whoseOrder;
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)masterPairs[0]);
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)masterPairs[0]);
                            return;
                        }
                    }
                    else if (myCP.GetMasterCardsTotal() >= count && pairTotal == 0 && count > 1) //单张甩牌
                    {
                        //如果目前最大的那一家是主 
                        int biggerMax = (int)mainForm.currentSendCards[mainForm.whoIsBigger - 1][0];
                        int maxMaster = myCP.GetMaxMasterCards();
                        //如果我的牌能大过最大的那家的牌
                        if (!CommonMethods.CompareTo(biggerMax, maxMaster, suit, rank, firstSuit))
                        {
                            mainForm.whoIsBigger = whoseOrder;
                            CommonMethods.SendCards(sendedCards, myCP, myPokerList, maxMaster);

                            SendMasterSuitOrScores(sendedCards, count, suit, myCP, myPokerList, true);
                            SendMasterSuit(sendedCards, count, suit, myCP, myPokerList, true);
                            SendMasterSuitOrScores(sendedCards, count, suit, myCP, myPokerList, false);
                            SendMasterSuit(sendedCards, count, suit, myCP, myPokerList, false);

                            return;
                        }

                    }
                }
            }

            if (myTotal < count) //本花色少牌
            {
               
                for (int i = 0; i < myTotal; i++)
                {
                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, cards[i]);
                }

                SendOtherSuitNoScores(sendedCards, count, firstSuit, myCP, myPokerList,true);
                SendOtherSuit(sendedCards, count, firstSuit, myCP, myPokerList,true);
                SendMasterSuitNoScores(sendedCards, count, suit, myCP, myPokerList,true);
                SendMasterSuit(sendedCards, count, suit, myCP, myPokerList,true);
                SendOtherSuitNoScores(sendedCards, count, firstSuit, myCP, myPokerList, false);
                SendOtherSuit(sendedCards, count, firstSuit, myCP, myPokerList, false);
                SendMasterSuitNoScores(sendedCards, count, suit, myCP, myPokerList, false);
                SendMasterSuit(sendedCards, count, suit, myCP, myPokerList, false);

               
                return;

            }
          
            //以下确保此花色的牌绝对够用
            else if (firstCP.HasTractors())  //如果首家出了拖拉机
            {
                //如果我有拖拉机,出最大的拖拉机
                if (mySuitCP.HasTractors())
                {
                    int k = mySuitCP.GetTractor();
                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, k);
                    int[] ks = mySuitCP.GetTractorOtherCards(k);
                    for (int i = 0; i < 3; i++)
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, ks[i]);
                    }

                    if (!CommonMethods.CompareTo(firstCP.GetTractor(), k, suit, rank, firstSuit)) //如果我的拖拉机的牌大
                    {
                        mainForm.whoIsBigger = whoseOrder;
                    }
                }
                else if (mySuitCP.GetPairs().Count > 0) //如果有对,出两个对
                {
                    ArrayList list = mySuitCP.GetPairs();
                    if (list.Count >= 2)
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[1]);
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[1]);
                    }
                    else
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);
                    }

                }


                //否则出最小的牌
                SendThisSuitNoScores(sendedCards, count, suit,firstSuit, myCP, myPokerList,true);
                SendThisSuit(sendedCards, count,suit, firstSuit, myCP, myPokerList,true);

                SendThisSuitNoScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);
                SendThisSuit(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);

                
                return;
            }
            else if (count == 1) //首家出单张牌 
            {
                int myMax = -1;
                if (firstSuit == suit)
                {
                    myMax = mySuitCP.GetMaxMasterCards();
                }
                else
                {
                    myMax = mySuitCP.GetMaxCards(firstSuit);
                }

               

                //如果得到的此花色的最大的牌大于首家的牌
                if (!CommonMethods.CompareTo(firstMax,myMax,suit,rank,firstSuit))
                {
                    if (myMax > -1)
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, myMax);

                        mainForm.whoIsBigger = whoseOrder;
                        
                        return;
                    }
                }

                


                SendThisSuitNoScores(sendedCards, count, suit,firstSuit, myCP, myPokerList,true);
                SendThisSuit(sendedCards, count,suit, firstSuit, myCP, myPokerList,true);

                SendThisSuitNoScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);
                SendThisSuit(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);

               
                return;
            }
            else if ((pairTotal == 1) && (count == 2)) //首家出了一个对
            {
                ArrayList list = mySuitCP.GetPairs();
                if (list.Count >= 1)
                {
                    int myMax = (int)list[list.Count - 1];

                    //如果得到的此花色的最大的牌大于首家的牌
                    if (!CommonMethods.CompareTo(firstMax, myMax, suit, rank, firstSuit))
                    {
                        mainForm.whoIsBigger = whoseOrder;
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[list.Count - 1]);
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[list.Count - 1]);
                        
                        return;
                    }
                    else
                    {
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);
                        CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[0]);

                        
                        return;
                    }
                }
                else
                {
                    //否则出最小的牌
                    SendThisSuitNoScores(sendedCards, count,suit, firstSuit, myCP, myPokerList,true);
                    SendThisSuit(sendedCards, count,suit, firstSuit, myCP, myPokerList,true);

                    SendThisSuitNoScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);
                    SendThisSuit(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);

                    
                    return;
                }

            }
            else if (count == pairTotal * 2 && (count>0)) //都是对
            {
                ArrayList list = mySuitCP.GetPairs();
                for (int i = 0; i < pairTotal && i < list.Count;i++ )
                {
                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[i]);
                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[i]);
                }

                //否则出最小的牌
                SendThisSuitNoScores(sendedCards, count,suit, firstSuit, myCP, myPokerList,true);
                SendThisSuit(sendedCards, count,suit, firstSuit, myCP, myPokerList,true);

                SendThisSuitNoScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);
                SendThisSuit(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);

                
                return;

            }
            else //有对和有单张牌,是甩牌
            {
                ArrayList list = mySuitCP.GetPairs();
                for (int i = 0; i < pairTotal && i < list.Count; i++)
                {
                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[i]);
                    CommonMethods.SendCards(sendedCards, myCP, myPokerList, (int)list[i]);
                }

                //否则出最小的牌
                SendThisSuitNoScores(sendedCards, count,suit, firstSuit, myCP, myPokerList,true);
                SendThisSuit(sendedCards, count,suit, firstSuit, myCP, myPokerList,true);

                SendThisSuitNoScores(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);
                SendThisSuit(sendedCards, count, suit, firstSuit, myCP, myPokerList, false);

               
                return;
            }


        }
Exemplo n.º 30
0
         internal SetRules(MainForm form)
        {
            this.form = form;
            InitializeComponent();

            string mustRank = form.gameConfig.MustRank;
            if (mustRank.IndexOf(",3,") >= 0)
            {
                checkBox1.CheckState = CheckState.Checked;
            }
            else
            {
                checkBox1.CheckState = CheckState.Unchecked;
            }
            if (mustRank.IndexOf(",8,") >= 0)
            {
                checkBox2.CheckState = CheckState.Checked;
            }
            else
            {
                checkBox2.CheckState = CheckState.Unchecked;
            }
            if (mustRank.IndexOf(",9,") >= 0)
            {
                checkBox6.CheckState = CheckState.Checked;
            }
            else
            {
                checkBox6.CheckState = CheckState.Unchecked;
            }
            if (mustRank.IndexOf(",10,") >= 0)
            {
                checkBox7.CheckState = CheckState.Checked;
            }
            else
            {
                checkBox7.CheckState = CheckState.Unchecked;
            }
            if (mustRank.IndexOf(",11,") >= 0)
            {
                checkBox3.CheckState = CheckState.Checked;
            }
            else
            {
                checkBox3.CheckState = CheckState.Unchecked;
            }
            if (mustRank.IndexOf(",12,") >= 0)
            {
                checkBox4.CheckState = CheckState.Checked;
            }
            else
            {
                checkBox4.CheckState = CheckState.Unchecked;
            }
            if (mustRank.IndexOf(",13,") >= 0)
            {
                checkBox5.CheckState = CheckState.Checked;
            }
            else
            {
                checkBox5.CheckState = CheckState.Unchecked;
            }

             //
            if (form.gameConfig.JToBottom)
            {
                checkBox8.CheckState = CheckState.Checked;
            }
            else
            {
                checkBox8.CheckState = CheckState.Unchecked;
            }

            if (form.gameConfig.QToHalf)
            {
                checkBox9.CheckState = CheckState.Checked;
            }
            else
            {
                checkBox9.CheckState = CheckState.Unchecked;
            }

            if (form.gameConfig.AToJ)
            {
                checkBox13.CheckState = CheckState.Checked;
            }
            else
            {
                checkBox13.CheckState = CheckState.Unchecked;
            }


            if (form.gameConfig.IsPass)
            {
                radioButton1.Checked = true;
            }
            else
            {
                radioButton2.Checked = true;
            }

            if (form.gameConfig.BottomAlgorithm == 1)
            {
                radioButton3.Checked = true;
            }
            else if (form.gameConfig.BottomAlgorithm == 2)
            {
                radioButton4.Checked = true;
            }
            else if (form.gameConfig.BottomAlgorithm == 3)
            {
                radioButton5.Checked = true;
            }
            

             //
            if (form.gameConfig.CanRankJack)
            {
                checkBox10.CheckState = CheckState.Checked;
            }
            else
            {
                checkBox10.CheckState = CheckState.Unchecked;
            }

            if (form.gameConfig.CanMyRankAgain)
            {
                checkBox11.CheckState = CheckState.Checked;
            }
            else
            {
                checkBox11.CheckState = CheckState.Unchecked;
            }

            if (form.gameConfig.CanMyStrengthen)
            {
                checkBox12.CheckState = CheckState.Checked;
            }
            else
            {
                checkBox12.CheckState = CheckState.Unchecked;
            }

           
        }