/// <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); } }
private int DrawSmallJack2(Graphics g, CurrentPoker currentPoker, int j, int start) { if (currentPoker.SmallJack == 1) { j = DrawMyOneOrTwoCards2(g, j, 52, start + j * 13, 355, 71, 96) + 1; } else if (currentPoker.SmallJack == 2) { j = DrawMyOneOrTwoCards2(g, j, 52, start + j * 13, 355, 71, 96) + 1; j = DrawMyOneOrTwoCards2(g, j, 52, start + j * 13, 355, 71, 96) + 1; } return j; }
private static void SendThisSuit(ArrayList sendedCards, int count, int suit, int firstSuit, CurrentPoker myCP, ArrayList myPokerList, bool protectPairs) { if (suit == firstSuit) { SendMasterSuit(sendedCards, count, suit, myCP, myPokerList,protectPairs); return; } int[] cards = myCP.GetSuitAllCards(firstSuit); for (int m = 0; m < 13; m++) { if (cards[m] > 0) { if (sendedCards.Count < count) { if (protectPairs) //保护对 { if (cards[m] == 1) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, m + (firstSuit - 1) * 13); } } else { CommonMethods.SendCards(sendedCards, myCP, myPokerList, m + (firstSuit - 1) * 13); if (sendedCards.Count < count) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, m + (firstSuit - 1) * 13); } } } if (sendedCards.Count >= count) { return; } } } }
//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; } }
/// <summary> /// 出牌的通用做法,从CurrentPoker中删除此牌,从pokerList中删除此牌,将此牌放入出牌列表中 /// </summary> /// <param name="sends">出牌数组列表</param> /// <param name="cp">CurrentPoker对象</param> /// <param name="pokerList">pokerList对象</param> /// <param name="number">出牌数字</param> internal static void SendCards(ArrayList sends,CurrentPoker cp,ArrayList pokerList,int number) { sends.Add(number); cp.RemoveCard(number); pokerList.Remove(number); }
//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; }
/// <summary> /// 从一堆牌中找出最大的牌,考虑主 /// </summary> /// <param name="sendCards">一堆主</param> /// <param name="suit">花色</param> /// <param name="rank">主</param> /// <returns>最大的牌</returns> internal static int GetMaxCard(ArrayList sendCards,int suit,int rank) { CurrentPoker cp = new CurrentPoker(); cp.Suit = suit; cp.Rank = rank; cp = parse(sendCards, suit, rank); int thisSuit = CommonMethods.GetSuit((int)sendCards[0]); if (cp.IsMixed()) { return -1; } bool hasTractor = cp.HasTractors(); int pairTotal = cp.GetPairs().Count; int count = cp.Count; //如果拖拉机 if (hasTractor) { return cp.GetTractor(); } else if (count == 1) //单张牌 { return (int)sendCards[0]; } else if (count == pairTotal * 2 && (count > 1)) //都是对 { return (int)cp.GetPairs()[pairTotal - 1]; } else //有对和有单张牌,得到对的最大值 { if (pairTotal>0) { return (int)cp.GetPairs()[pairTotal - 1]; } else { return cp.GetMaxCard(thisSuit); } } }
//画自己排序好的牌,一般在摸完牌后调用,和出一次牌后调用 /// <summary> /// 在程序底部绘制已经排序好的牌. /// 两种情况下会使用这个方法: /// 1.收完底准备出牌时 /// 2.出完一次牌,需要重画底部 /// </summary> /// <param name="currentPoker"></param> internal void DrawMySortedCards(CurrentPoker currentPoker, int index) { //将临时变量清空 //这三个临时变量记录我手中的牌的位置、大小和是否被点出 mainForm.myCardsLocation = new ArrayList(); mainForm.myCardsNumber = new ArrayList(); mainForm.myCardIsReady = new ArrayList(); Graphics g = Graphics.FromImage(mainForm.bmp); //清下面的屏幕 Rectangle rect = new Rectangle(30, 355, 600, 116); g.DrawImage(mainForm.image, rect, rect, GraphicsUnit.Pixel); //计算初始位置 int start = (int)((2780 - index * 75) / 10); //记录每张牌的X值 int j = 0; //临时变量,用来辅助判断是否某花色缺失 int k = 0; if (mainForm.currentState.Suit == 1)//红桃 { j = DrawMyPeachs(g, currentPoker, j, start) + 1; IsSuitLost(ref j, ref k); j = DrawMyDiamonds(g, currentPoker, j, start) + 1; IsSuitLost(ref j, ref k); j = DrawMyClubs(g, currentPoker, j, start) + 1; IsSuitLost(ref j, ref k); j = DrawMyHearts(g, currentPoker, j, start); j = DrawPeachsRank(g, currentPoker, j, start); j = DrawDiamondsRank(g, currentPoker, j, start); j = DrawClubsRank(g, currentPoker, j, start); j = DrawHeartsRank(g, currentPoker, j, start); } else if (mainForm.currentState.Suit == 2) //黑桃 { j = DrawMyDiamonds(g, currentPoker, j, start) + 1; IsSuitLost(ref j, ref k); j = DrawMyClubs(g, currentPoker, j, start) + 1; IsSuitLost(ref j, ref k); j = DrawMyHearts(g, currentPoker, j, start) + 1; IsSuitLost(ref j, ref k); j = DrawMyPeachs(g, currentPoker, j, start); j = DrawDiamondsRank(g, currentPoker, j, start); j = DrawClubsRank(g, currentPoker, j, start); j = DrawHeartsRank(g, currentPoker, j, start); j = DrawPeachsRank(g, currentPoker, j, start); } else if (mainForm.currentState.Suit == 3) //方片 { j = DrawMyClubs(g, currentPoker, j, start) + 1; IsSuitLost(ref j, ref k); j = DrawMyHearts(g, currentPoker, j, start) + 1; IsSuitLost(ref j, ref k); j = DrawMyPeachs(g, currentPoker, j, start) + 1; IsSuitLost(ref j, ref k); j = DrawMyDiamonds(g, currentPoker, j, start); j = DrawClubsRank(g, currentPoker, j, start); j = DrawHeartsRank(g, currentPoker, j, start); j = DrawPeachsRank(g, currentPoker, j, start); j = DrawDiamondsRank(g, currentPoker, j, start);//方块 } else if (mainForm.currentState.Suit == 4) { j = DrawMyHearts(g, currentPoker, j, start) + 1; IsSuitLost(ref j, ref k); j = DrawMyPeachs(g, currentPoker, j, start) + 1; IsSuitLost(ref j, ref k); j = DrawMyDiamonds(g, currentPoker, j, start) + 1; IsSuitLost(ref j, ref k); j = DrawMyClubs(g, currentPoker, j, start); j = DrawHeartsRank(g, currentPoker, j, start); j = DrawPeachsRank(g, currentPoker, j, start); j = DrawDiamondsRank(g, currentPoker, j, start); j = DrawClubsRank(g, currentPoker, j, start);//梅花 } else if (mainForm.currentState.Suit == 5) { j = DrawMyHearts(g, currentPoker, j, start) + 1; IsSuitLost(ref j, ref k); j = DrawMyPeachs(g, currentPoker, j, start) + 1; IsSuitLost(ref j, ref k); j = DrawMyDiamonds(g, currentPoker, j, start) + 1; IsSuitLost(ref j, ref k); j = DrawMyClubs(g, currentPoker, j, start) + 1; IsSuitLost(ref j, ref k); j = DrawHeartsRank(g, currentPoker, j, start); j = DrawPeachsRank(g, currentPoker, j, start); j = DrawDiamondsRank(g, currentPoker, j, start); j = DrawClubsRank(g, currentPoker, j, start); } //小王 j = DrawSmallJack(g, currentPoker, j, start); //大王 j = DrawBigJack(g, currentPoker, j, start); g.Dispose(); }
//判断我出的牌是否合法 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; }
//判断我是否亮主 private void MyRankOrNot(CurrentPoker currentPoker) { //如果打无主,无需再判断 if (currentPoker.Rank == 53) return; bool[] suits = Algorithm.CanSetRank(mainForm, currentPoker); ReDrawToolbar(suits); }
/// <summary> /// 发牌期间进行绘制我的区域. /// 按照花色和主牌进行区分。 /// </summary> /// <param name="g">缓冲区图片的Graphics</param> /// <param name="currentPoker">我当前得到的牌</param> /// <param name="index">手中牌的数量</param> internal void DrawMyCards(Graphics g, CurrentPoker currentPoker, int index) { int j = 0; //清下面的屏幕 Rectangle rect = new Rectangle(30, 360, 560, 96); g.DrawImage(mainForm.image, rect, rect, GraphicsUnit.Pixel); //确定绘画起始位置 int start = (int)((2780 - index * 75) / 10); //红桃 j = DrawMyHearts(g, currentPoker, j, start); //花色之间加空隙 j++; //黑桃 j = DrawMyPeachs(g, currentPoker, j, start); //花色之间加空隙 j++; //方块 j = DrawMyDiamonds(g, currentPoker, j, start); //花色之间加空隙 j++; //梅花 j = DrawMyClubs(g, currentPoker, j, start); //花色之间加空隙 j++; //Rank(暂不分主、副Rank) j = DrawHeartsRank(g, currentPoker, j, start); j = DrawPeachsRank(g, currentPoker, j, start); j = DrawClubsRank(g, currentPoker, j, start); j = DrawDiamondsRank(g, currentPoker, j, start); //小王 j = DrawSmallJack(g, currentPoker, j, start); //大王 j = DrawBigJack(g, currentPoker, j, start); }
//是否应该亮主,调用算法 private void DoRankOrNot(CurrentPoker currentPoker, int user) { //如果打无主,无需再判断 if (currentPoker.Rank == 53) return; //如果还未设主,则设主 if (mainForm.currentState.Suit == 0) { int suit = Algorithm.ShouldSetRank(mainForm, user); if (suit > 0) { mainForm.showSuits = 1; mainForm.whoShowRank = user; mainForm.currentState.Suit = suit; if ((mainForm.currentRank == 0) && mainForm.isNew) { mainForm.currentState.Master = user; // } //既然已经确定了谁亮的,谁是主,打几,那么就画吧 Graphics g = Graphics.FromImage(mainForm.bmp); //亮主的时候同时画花色,亮色显示在庄家下面 if ((mainForm.currentState.Master == 1) || (mainForm.currentState.Master == 2)) { DrawSuit(g, suit, true, true); DrawRank(g, mainForm.currentState.OurCurrentRank, true, true); } else { DrawSuit(g, suit, false, true); DrawRank(g, mainForm.currentState.OpposedCurrentRank, false, true); } //画谁亮的主,绿色显示 //DrawMaster(g, user, 1); //画庄家,画红色 DrawMaster(g, mainForm.currentState.Master, 1); DrawOtherMaster(g, mainForm.currentState.Master, 1); g.Dispose(); } } else //是否可以反 { int suit = Algorithm.ShouldSetRankAgain(mainForm, currentPoker); if (suit > 0) { //是否可以加固 if ((suit == mainForm.currentState.Suit) && (mainForm.whoShowRank == user) && (!mainForm.gameConfig.CanMyStrengthen)) //如果不允许加固 { return; } //非加固时,考虑自反 if ((suit != mainForm.currentState.Suit) && (mainForm.whoShowRank == user) && (!mainForm.gameConfig.CanMyRankAgain)) //如果不允许自反 { return; } int oldWhoShowRank = mainForm.whoShowRank; int oldMaster = mainForm.currentState.Master; mainForm.showSuits = 2; mainForm.whoShowRank = user; mainForm.currentState.Suit = suit; if ((mainForm.currentRank == 0) && mainForm.isNew) { mainForm.currentState.Master = user; } Graphics g = Graphics.FromImage(mainForm.bmp); //亮主的时候同时画花色,亮色显示在庄家下面 if ((mainForm.currentState.Master == 1) || (mainForm.currentState.Master == 2)) { DrawSuit(g, suit, true, true); DrawRank(g, mainForm.currentState.OurCurrentRank, true, true); } else { DrawSuit(g, suit, false, true); DrawRank(g, mainForm.currentState.OpposedCurrentRank, false, true); } //清理原来亮的牌 DrawOtherMaster(g, mainForm.currentState.Master, 1); //画谁亮的主,绿色显示 //DrawMaster(g, user, 1); //画庄家,画红色 DrawMaster(g, mainForm.currentState.Master, 1); g.Dispose(); } } }
private int DrawMyHearts2(Graphics g, CurrentPoker currentPoker, int j, int start) { for (int i = 0; i < 13; i++) { if (currentPoker.HeartsNoRank[i] == 1) { j = DrawMyOneOrTwoCards2(g, j, i, start + j * 13, 355, 71, 96) + 1; } else if (currentPoker.HeartsNoRank[i] == 2) { j = DrawMyOneOrTwoCards2(g, j, i, start + j * 13, 355, 71, 96) + 1; j = DrawMyOneOrTwoCards2(g, j, i, start + j * 13, 355, 71, 96) + 1; } } return j; }
private int DrawHeartsRank2(Graphics g, CurrentPoker currentPoker, int j, int start) { if (currentPoker.HeartsRankTotal == 1) { j = DrawMyOneOrTwoCards2(g, j, mainForm.currentRank, start + j * 13, 355, 71, 96) + 1; } else if (currentPoker.HeartsRankTotal == 2) { j = DrawMyOneOrTwoCards2(g, j, mainForm.currentRank, start + j * 13, 355, 71, 96) + 1; j = DrawMyOneOrTwoCards2(g, j, mainForm.currentRank, start + j * 13, 355, 71, 96) + 1; } return j; }
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); } }
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; } } } }
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); } }
//确定下一次该谁出牌 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; }
/// <summary> /// 对一个随机产生的序列进行解析 /// </summary> /// <param name="list">要排序的列表</param> /// <param name="suit">当前花色</param> /// <param name="rank">当前牌局</param> /// <returns>返回CurrentPoker对象</returns> internal static CurrentPoker parse(ArrayList list, int suit, int rank) { //红桃0-12 //黑桃13-25 //方块26-38 //梅花39-51 //小王52 //大王53 CurrentPoker poker = new CurrentPoker(); poker.Rank = rank; poker.Suit = suit; //解析用户的牌局 foreach (int i in list) { //大王 if (i == 53) { poker.BigJack++; continue; } else if (i == 52) { poker.SmallJack++; continue; } else if (i < 52) { if (i >= 0 && i < 13) { poker.Hearts[i]++; if (i != rank) { poker.HeartsNoRank[i]++; poker.HeartsNoRankTotal++; } else { poker.HeartsRankTotal++; } } else if (i >= 13 && i < 26) { poker.Peachs[i - 13]++; if ((i - 13) != rank) { poker.PeachsNoRank[i - 13]++; poker.PeachsNoRankTotal++; } else { poker.PeachsRankTotal++; } } else if (i >= 26 && i < 39) { poker.Diamonds[i - 26]++; if ((i - 26) != rank) { poker.DiamondsNoRank[i - 26]++; poker.DiamondsNoRankTotal++; } else { poker.DiamondsRankTotal++; } } else if (i >= 39 && i < 52) { poker.Clubs[i - 39]++; if ((i - 39) != rank) { poker.ClubsNoRank[i - 39]++; poker.ClubsNoRankTotal++; } else { poker.ClubsRankTotal++; } } if (suit > 0) { if (i == ((suit - 1) * 13 + rank)) { poker.MasterRank++; } } } } return poker; }
//玩家甩牌时的检查,如果所有的牌都是最大的,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; }
/// <summary> /// 得到某种花色牌的数量 /// </summary> /// <param name="cp">牌</param> /// <param name="suit">主花色</param> /// <param name="rank">主Rank</param> /// <param name="mysuit">查找的花色</param> /// <returns>牌的数量</returns> internal static int GetSuitCount(CurrentPoker cp,int suit,int rank,int mysuit) { if (suit == mysuit) { int count = cp.MasterRank + cp.SubRank + cp.BigJack + cp.SmallJack; if (mysuit == 1) { count += cp.HeartsNoRankTotal; } else if (mysuit == 2) { count += cp.PeachsNoRankTotal; } else if (mysuit == 3) { count += cp.DiamondsNoRankTotal; } else if (mysuit == 4) { count += cp.ClubsNoRankTotal; } return count; } else { if (mysuit == 1) { return cp.HeartsNoRankTotal; } if (mysuit == 2) { return cp.PeachsNoRankTotal; } if (mysuit == 3) { return cp.DiamondsNoRankTotal; } if (mysuit == 4) { return cp.ClubsNoRankTotal; } if (mysuit == 5) { return cp.SmallJack + cp.BigJack; } } return 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 // 全剩主牌和分副牌 }
//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; } }
//我是否可以亮主 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; }
//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; } }
//别人已出,自己应该出的牌 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]; }
private static void SendOtherSuit(ArrayList sendedCards, int count, int firstSuit, CurrentPoker myCP, ArrayList myPokerList, bool protectPairs) { for (int asuit = 1; asuit < 5; asuit++) { if (asuit == firstSuit) { continue; } if (asuit == myCP.Suit) { continue; } int[] cards = myCP.GetSuitAllCards(asuit); for (int m = 0; m < 13; m++) { if (cards[m] > 0) { if (sendedCards.Count < count) { if (protectPairs) //保护对 { if (cards[m] == 1) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, m + (asuit - 1) * 13); } } else { CommonMethods.SendCards(sendedCards, myCP, myPokerList, m + (asuit - 1) * 13); if (sendedCards.Count < count) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, m + (asuit - 1) * 13); } } } if (sendedCards.Count >= count) { return; } } } } }
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; }
private static void SendMasterSuitOrScores(ArrayList sendedCards, int count, int suit, CurrentPoker myCP, ArrayList myPokerList, bool protectPairs) { if (sendedCards.Count >= count) { return; } for (int asuit = 1; asuit < 5; asuit++) { if (asuit != suit) { continue; } int[] cardsCount = myCP.GetSuitAllCards(asuit); int n = 8; if (myCP.Rank == 8) { n = 11; //打10时,先出K } if (cardsCount[n] > 0) { if (sendedCards.Count < count) { if (protectPairs) //保护对 { if (cardsCount[n] == 1) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, n + (suit - 1) * 13); } } else { CommonMethods.SendCards(sendedCards, myCP, myPokerList, n + (asuit - 1) * 13); if (sendedCards.Count < count) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, n + (asuit - 1) * 13); } } } if (sendedCards.Count >= count) { return; } } else { continue; } n = 11; if (myCP.Rank == 8) { n = 8; //打10时,后出10 } if (cardsCount[n] > 0) { if (sendedCards.Count < count) { if (protectPairs) //保护对 { if (cardsCount[n] == 1) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, n + (suit - 1) * 13); } } else { CommonMethods.SendCards(sendedCards, myCP, myPokerList, n + (asuit - 1) * 13); if (sendedCards.Count < count) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, n + (asuit - 1) * 13); } } } if (sendedCards.Count >= count) { return; } } else { continue; } n = 3; if (cardsCount[n] > 0) { if (sendedCards.Count < count) { if (protectPairs) //保护对 { if (cardsCount[n] == 1) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, n + (suit - 1) * 13); } } else { CommonMethods.SendCards(sendedCards, myCP, myPokerList, n + (asuit - 1) * 13); if (sendedCards.Count < count) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, n + (asuit - 1) * 13); } } } if (sendedCards.Count >= count) { return; } } else { continue; } } //非分 for (int asuit = 1; asuit < 5; asuit++) { if (asuit != suit) { continue; } int[] cardsCount = myCP.GetSuitAllCards(asuit); for (int m = 0; m < 13; m++) { if (cardsCount[m] > 0) { if (sendedCards.Count < count) { if (protectPairs) //保护对 { if (cardsCount[m] == 1) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, m + (suit - 1) * 13); } } else { CommonMethods.SendCards(sendedCards, myCP, myPokerList, m + (asuit - 1) * 13); if (sendedCards.Count < count) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, m + (asuit - 1) * 13); } } } if (sendedCards.Count >= count) { return; } } else { continue; } } } //Rank if (protectPairs) //保护对 { if (sendedCards.Count < count) { if (myCP.HeartsRankTotal == 1) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, myCP.Rank); } } if (sendedCards.Count < count) { if (myCP.PeachsRankTotal == 1) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, myCP.Rank + 13); } } if (sendedCards.Count < count) { if (myCP.DiamondsRankTotal == 1) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, myCP.Rank + 26); } } if (sendedCards.Count < count) { if (myCP.ClubsRankTotal == 1) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, myCP.Rank + 39); } } } else { if (sendedCards.Count < count) { if (myCP.HeartsRankTotal > 0) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, myCP.Rank); } } if (sendedCards.Count < count) { if (myCP.HeartsRankTotal > 0) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, myCP.Rank); } } if (sendedCards.Count < count) { if (myCP.PeachsRankTotal > 0) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, myCP.Rank + 13); } } if (sendedCards.Count < count) { if (myCP.PeachsRankTotal > 0) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, myCP.Rank + 13); } } if (sendedCards.Count < count) { if (myCP.DiamondsRankTotal > 0) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, myCP.Rank + 26); } } if (sendedCards.Count < count) { if (myCP.DiamondsRankTotal > 0) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, myCP.Rank + 26); } } if (sendedCards.Count < count) { if (myCP.ClubsRankTotal > 0) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, myCP.Rank + 39); } } if (sendedCards.Count < count) { if (myCP.ClubsRankTotal > 0) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, myCP.Rank + 39); } } } // if (myCP.SmallJack > 0) { if (sendedCards.Count < count) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, 52); } } if (myCP.SmallJack > 0) { if (sendedCards.Count < count) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, 52); } } if (myCP.BigJack > 0) { if (sendedCards.Count < count) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, 53); } } if (myCP.BigJack > 0) { if (sendedCards.Count < count) { CommonMethods.SendCards(sendedCards, myCP, myPokerList, 53); } } }
private int DrawMyHearts(Graphics g, CurrentPoker currentPoker, int j, int start) { for (int i = 0; i < 13; i++) { j = DrawMyOneOrTwoCards(g, currentPoker.HeartsNoRank[i], i, j, start); } return j; }