/// <summary> /// 清除界面数据 /// </summary> public void ClearDatas() { UnitTool.ToolStopAllCoroutines(); //清除玩家相关数据 for (int i = 0; i < players.Count; i++) { players[i].myCardInfo.Clear(); players[i].myType = new DDZ_POKER_TYPE(); players[i].myTerm = false; } lastType = DDZ_POKER_TYPE.DDZ_PASS; ClearLordDatas(); //清除控制器相关数据 this.tableCards.Clear(); this.lastCards.Clear(); this.lordTimes = 0; //销毁桌面上所有的扑克牌 pokerTable.myUiCard.Clear(); GameObject[] pokers = GameObject.FindGameObjectsWithTag("Poker"); for (int i = 0; i < pokers.Length; i++) { GameObject.Destroy(pokers[i].gameObject); } startIndex = playerIndex % 3; SetLordImg(false); SetStartButton(false, true); //显示界面重置 SetButton(false, false, false); }
/// <summary> /// 所有玩家开始出牌接口 /// </summary> public void PlayerStartPlay() { //显示选项 SetHintText(" ", 0); SetHintText(" ", 1); SetHintText(" ", 2); ShowOption(false, true, players[playerIndex % 3]); if (players[playerIndex % 3].myCardInfo.Count != 20 && (playerIndex % 3) == 0) { SetNotPlayBtn(true); } //我出牌,一轮下来,又到我出牌 if (players[playerIndex % 3].myTerm) { if (players[(playerIndex + 1) % 3].myTerm == false && players[(playerIndex + 2) % 3].myTerm == false) { Debug.Log(players[playerIndex % 3].ToString() + " 开始出牌"); players[playerIndex % 3].myTerm = false; SetNotPlayBtn(false); lastCards.Clear(); lastType = DDZ_POKER_TYPE.DDZ_PASS; for (int i = 0; i < tableCards.Count; i++) { pokerTable.MoveCard(tableCards[i], new Vector3(0, 0, 0), 0.01f); } tableCards.Clear(); } } }
/// <summary> /// 玩家不出牌 /// </summary> public void NotPlayCards() { if (playerIndex % 3 == 0) { //玩家不出牌 if (lastCards.Count != 0) { //上个玩家出牌了 Debug.Log(players[0].ToString() + "不要"); players[playerIndex % 3].myTerm = false; //lastType = players[playerIndex % 3].myType; //不出牌的时候,将选中出列的牌归位 for (int i = 0; i < players[0].myCardInfo.Count; i++) { if (players[0].myCardInfo[i].isSelected) { pokerTable.GetCardObject(players[0].myCardInfo[i]).SetSelectState(); } } UnitTool.ToolStopAllCoroutines(); StartPlay(); } else { //自己的出牌回合,时间结束,默认系统出玩家的第一张牌 lastType = DDZ_POKER_TYPE.SINGLE; players[0].myCardInfo[players[0].myCardInfo.Count - 1].isSelected = true; CanPlayCards(); } } else { //电脑不出牌 Debug.Log(players[playerIndex % 3].ToString() + "不要"); players[playerIndex % 3].myTerm = false; //先关闭所有协程 UnitTool.ToolStopAllCoroutines(); //回到开始出牌主函数 StartPlay(); } }
//比较当前出的牌和上个玩家的牌的大小 public static bool isSelectCardCanPut(List <int> myCards, DDZ_POKER_TYPE myCardType, List <int> lastCards, DDZ_POKER_TYPE lastCardTye) { // 上一首牌的个数 int prevSize = lastCards.Count; int mySize = myCards.Count; // 集中判断是否王炸,免得多次判断王炸 if (lastCardTye == DDZ_POKER_TYPE.KING_BOMB) { Debug.Log("上家王炸,肯定不能出。"); return(false); } else if (myCardType == DDZ_POKER_TYPE.KING_BOMB) { Debug.Log("我王炸,肯定能出。"); return(true); } // 集中判断对方不是炸弹,我出炸弹的情况 if (lastCardTye != DDZ_POKER_TYPE.FOUR_BOMB && myCardType == DDZ_POKER_TYPE.FOUR_BOMB) { return(true); } //王炸判断过了,所以牌数不相同,就不能出 if (myCards.Count != lastCards.Count) { return(false); } //*所有牌提前是必须排序过了 (升序) //我出的牌的权值和上家牌的权值,根据大小来(0-14) int myGrade = myCards[0]; int prevGrade = lastCards[0]; // 比较2家的牌,主要有2种情况,1.我出和上家一种类型的牌,即对子管对子; // 2.我出炸弹,此时,和上家的牌的类型可能不同 // 王炸的情况已经排除 // 单 if (lastCardTye == DDZ_POKER_TYPE.SINGLE && myCardType == DDZ_POKER_TYPE.SINGLE) { // 一张牌可以大过上家的牌 return(compareGrade(myGrade, prevGrade)); } // 对子 else if (lastCardTye == DDZ_POKER_TYPE.TWIN && myCardType == DDZ_POKER_TYPE.TWIN) { // 2张牌可以大过上家的牌 return(compareGrade(myGrade, prevGrade)); } // 3不带 else if (lastCardTye == DDZ_POKER_TYPE.TRIPLE && myCardType == DDZ_POKER_TYPE.TRIPLE) { // 3张牌可以大过上家的牌 return(compareGrade(myGrade, prevGrade)); } // 炸弹 else if (lastCardTye == DDZ_POKER_TYPE.FOUR_BOMB && myCardType == DDZ_POKER_TYPE.FOUR_BOMB) { // 4张牌可以大过上家的牌 return(compareGrade(myGrade, prevGrade)); } // 3带1 else if (lastCardTye == DDZ_POKER_TYPE.TRIPLE_WITH_SINGLE) { // 3带1只需比较第2张牌的大小 myGrade = myCards[1]; prevGrade = lastCards[1]; return(compareGrade(myGrade, prevGrade)); } else if (lastCardTye == DDZ_POKER_TYPE.TRIPLE_WITH_TWIN) { // 3带2只需比较第3张牌的大小 myGrade = myCards[2]; prevGrade = lastCards[2]; return(compareGrade(myGrade, prevGrade)); } // 4带2 else if (lastCardTye == DDZ_POKER_TYPE.FOUR_WITH_SINGLE && myCardType == DDZ_POKER_TYPE.FOUR_WITH_SINGLE) { // 4带2只需比较第3张牌的大小 myGrade = myCards[2]; prevGrade = lastCards[2]; } // 顺子 else if (lastCardTye == DDZ_POKER_TYPE.STRAIGHT_SINGLE && myCardType == DDZ_POKER_TYPE.STRAIGHT_SINGLE) { if (mySize != prevSize) { return(false); } else { // 顺子只需比较最大的1张牌的大小 myGrade = myCards[mySize - 1]; prevGrade = lastCards[prevSize - 1]; return(compareGrade(myGrade, prevGrade)); } } // 连对 else if (lastCardTye == DDZ_POKER_TYPE.STRAIGHT_TWIN && myCardType == DDZ_POKER_TYPE.STRAIGHT_TWIN) { if (mySize != prevSize) { return(false); } else { // 顺子只需比较最大的1张牌的大小 myGrade = myCards[mySize - 1]; prevGrade = lastCards[prevSize - 1]; return(compareGrade(myGrade, prevGrade)); } } // 飞机不带 else if (lastCardTye == DDZ_POKER_TYPE.PLANE_PURE && myCardType == DDZ_POKER_TYPE.PLANE_PURE) { if (mySize != prevSize) { return(false); } else { //333444555666算飞机不带 不算飞机带单 myGrade = myCards[4]; prevGrade = lastCards[4]; return(compareGrade(myGrade, prevGrade)); } } //飞机带单 else if (lastCardTye == DDZ_POKER_TYPE.PLANE_WITH_SINGLE && myCardType == DDZ_POKER_TYPE.PLANE_WITH_SINGLE) { if (mySize != prevSize) { return(false); } else { List <int> tempThreeList = new List <int>(); for (int i = 0; i < myCards.Count; i++) { int tempInt = 0; for (int j = 0; j < myCards.Count; j++) { if (myCards[i] == myCards[j]) { tempInt++; } } if (tempInt == 3) { tempThreeList.Add(myCards[i]); } } myGrade = tempThreeList[4]; prevGrade = lastCards[4]; return(compareGrade(myGrade, prevGrade)); } } //飞机带双 else if (lastCardTye == DDZ_POKER_TYPE.PLANE_WITH_TWIN && myCardType == DDZ_POKER_TYPE.PLANE_WITH_TWIN) { if (mySize != prevSize) { return(false); } else { List <int> tempThreeList = new List <int>(); List <int> tempTwoList = new List <int>(); for (int i = 0; i < myCards.Count; i++) { int tempInt = 0; for (int j = 0; j < myCards.Count; j++) { if (myCards[i] == myCards[j]) { tempInt++; } } if (tempInt == 3) { tempThreeList.Add(myCards[i]); } else if (tempInt == 2) { tempTwoList.Add(myCards[i]); } } myGrade = tempThreeList[4]; prevGrade = lastCards[4]; if (compareGrade(myGrade, prevGrade)) { return(IsAllDouble(tempTwoList)); } } } // 默认不能出牌 return(false); }
/// <summary> /// 判断是否符合出牌规则 /// </summary> /// <param name="cards"></param> /// <param name="type"></param> /// <returns></returns> public static bool PopEnable(List <int> cards, out DDZ_POKER_TYPE type) { //public static bool PopEnable(List<int> cards, out DDZ_POKER_TYPE type) type = DDZ_POKER_TYPE.DDZ_PASS; bool isRule = false; switch (cards.Count) { case 1: isRule = true; type = DDZ_POKER_TYPE.SINGLE; break; case 2: if (IsDouble(cards)) { isRule = true; type = DDZ_POKER_TYPE.TWIN; } else if (IsJokerBoom(cards)) { isRule = true; type = DDZ_POKER_TYPE.KING_BOMB; } break; case 3: if (IsOnlyThree(cards)) { isRule = true; type = DDZ_POKER_TYPE.TRIPLE; } break; case 4: if (IsBoom(cards)) { isRule = true; type = DDZ_POKER_TYPE.FOUR_BOMB; } else if (IsThreeAndOne(cards)) { isRule = true; type = DDZ_POKER_TYPE.TRIPLE_WITH_SINGLE; } break; case 5: if (IsStraight(cards)) { isRule = true; type = DDZ_POKER_TYPE.STRAIGHT_SINGLE; } else if (IsThreeAndTwo(cards)) { isRule = true; type = DDZ_POKER_TYPE.TRIPLE_WITH_TWIN; } break; case 6: if (IsStraight(cards)) { isRule = true; type = DDZ_POKER_TYPE.STRAIGHT_SINGLE; } else if (IsTripleStraight(cards)) { isRule = true; type = DDZ_POKER_TYPE.PLANE_PURE; } else if (IsDoubleStraight(cards)) { isRule = true; type = DDZ_POKER_TYPE.STRAIGHT_TWIN; } else if (isSiDaiEr(cards)) { isRule = true; type = DDZ_POKER_TYPE.FOUR_WITH_SINGLE; //四带二 } break; case 7: if (IsStraight(cards)) { isRule = true; type = DDZ_POKER_TYPE.STRAIGHT_SINGLE; } break; case 8: if (IsStraight(cards)) { isRule = true; type = DDZ_POKER_TYPE.STRAIGHT_SINGLE; } else if (IsDoubleStraight(cards)) { isRule = true; type = DDZ_POKER_TYPE.STRAIGHT_TWIN; } else if (isPlaneWithSingle(cards)) { isRule = true; type = DDZ_POKER_TYPE.PLANE_WITH_SINGLE; //飞机带单 } break; case 9: if (IsStraight(cards)) { isRule = true; type = DDZ_POKER_TYPE.STRAIGHT_SINGLE; } else if (IsTripleStraight(cards)) { isRule = true; type = DDZ_POKER_TYPE.PLANE_PURE; } break; case 10: if (IsStraight(cards)) { isRule = true; type = DDZ_POKER_TYPE.STRAIGHT_SINGLE; } else if (IsDoubleStraight(cards)) { isRule = true; type = DDZ_POKER_TYPE.STRAIGHT_TWIN; } else if (isPlaneWithTwin(cards)) //飞机带对 { isRule = true; type = DDZ_POKER_TYPE.PLANE_WITH_TWIN; } break; case 11: if (IsStraight(cards)) { isRule = true; type = DDZ_POKER_TYPE.STRAIGHT_SINGLE; } break; case 12: if (IsStraight(cards)) { isRule = true; type = DDZ_POKER_TYPE.STRAIGHT_SINGLE; } else if (IsDoubleStraight(cards)) { isRule = true; type = DDZ_POKER_TYPE.STRAIGHT_TWIN; } else if (isPlaneWithSingle(cards)) { isRule = true; type = DDZ_POKER_TYPE.PLANE_WITH_SINGLE; //飞机带单 } else if (IsTripleStraight(cards)) { isRule = true; type = DDZ_POKER_TYPE.PLANE_PURE; } break; case 13: break; case 14: if (IsDoubleStraight(cards)) { isRule = true; type = DDZ_POKER_TYPE.STRAIGHT_TWIN; } break; case 15: if (IsTripleStraight(cards)) { isRule = true; type = DDZ_POKER_TYPE.PLANE_PURE; } else if (isPlaneWithTwin(cards)) //飞机带对 { isRule = true; type = DDZ_POKER_TYPE.PLANE_WITH_TWIN; } break; case 16: if (IsDoubleStraight(cards)) { isRule = true; type = DDZ_POKER_TYPE.STRAIGHT_TWIN; } else if (isPlaneWithSingle(cards)) { isRule = true; type = DDZ_POKER_TYPE.PLANE_WITH_SINGLE; //飞机带单 } break; case 17: break; case 18: if (IsDoubleStraight(cards)) { isRule = true; type = DDZ_POKER_TYPE.STRAIGHT_TWIN; } else if (IsTripleStraight(cards)) { isRule = true; type = DDZ_POKER_TYPE.PLANE_PURE; } break; case 19: break; case 20: if (IsDoubleStraight(cards)) { isRule = true; type = DDZ_POKER_TYPE.STRAIGHT_TWIN; } else if (isPlaneWithSingle(cards)) { isRule = true; type = DDZ_POKER_TYPE.PLANE_WITH_SINGLE; //飞机带单 } else if (isPlaneWithTwin(cards)) //飞机带对 { isRule = true; type = DDZ_POKER_TYPE.PLANE_WITH_TWIN; } break; default: break; } return(isRule); }
/// <summary> /// AI出牌 /// </summary> /// <returns></returns> public bool AIPlayCards() { BasePlayer c = players[playerIndex % 3]; //获取当前手牌的大小 List <int> myList = new List <int>(); for (int i = 0; i < c.myCardInfo.Count; i++) { myList.Add(c.myCardInfo[i].cardIndex); } //获取上个玩家手牌的大小 List <int> last = new List <int>(); if (lastCards.Count != 0) { for (int i = 0; i < lastCards.Count; i++) { last.Add(lastCards[i].cardIndex); } } //要排序 myList.Sort(); last.Sort(); //所有符合该牌型的组合,存到字典中 Dictionary <int, List <int> > result = PokerAI.FindPromptCards(myList, last, lastType); //是否能出牌 if (result == null || result.Count == 0) { //Debug.Log("字典为空"); //没有比上家大的牌,不出 NotPlayCards(); return(false); } //所有的key List <int> keys = new List <int>(); //某一个key的值 List <int> value = new List <int>(); //循环取到所有的key foreach (var item in result.Keys) { keys.Add(item); } //随机选择众多结果中的一个结果出 = = int vauleCount = MyUtil.GetRange(0, keys.Count); value = result[keys[vauleCount]]; //如上家出333, 那么value为444,有三个4,所以在当前手牌中需要取3个4 for (int i = 0; i < value.Count; i++) { for (int j = 0; j < c.myCardInfo.Count; j++) { if (value[i] == c.myCardInfo[j].cardIndex && c.myCardInfo[j].isSelected == false) { c.myCardInfo[j].isSelected = true; break; } } } //能出牌,获取出牌牌型 PokerRules.PopEnable(value, out c.myType); lastType = c.myType; return(true); }
/// <summary> /// 确定能够出牌 /// </summary> public void CanPlayCards() { //清除桌面上的牌 if (tableCards.Count != 0) { for (int i = 0; i < tableCards.Count; i++) { pokerTable.MoveCard(tableCards[i], new Vector3(0, 0, 0), 0.01f); } } tableCards.Clear(); List <int> list = new List <int>(); list.Clear(); //将要出的牌添加到桌面List中并排序 for (int i = 0; i < players[playerIndex % 3].myCardInfo.Count; i++) { if (players[playerIndex % 3].myCardInfo[i].isSelected) { tableCards.Add(players[playerIndex % 3].myCardInfo[i]); list.Add(players[playerIndex % 3].myCardInfo[i].cardIndex); } } //tableCards = SortCards(tableCards); //保存上个玩家出的牌的信息 lastCards.Clear(); PokerRules.PopEnable(list, out players[playerIndex % 3].myType); lastType = players[playerIndex % 3].myType; for (int i = 0; i < tableCards.Count; i++) { lastCards.Add(tableCards[i]); } //移动要出的牌到指定的位置,并清除myCards中出去的牌 GameObject table = pokerTable.table; Vector3 pos = table.transform.position + new Vector3(-tableCards.Count * 0.48f, 0, 0); for (int i = 0; i < tableCards.Count; i++) { tableCards[i].parent = table.transform; pokerTable.SetCardParent(tableCards[i]); pokerTable.InitImage(tableCards[i], false); pokerTable.MoveCard(tableCards[i], pos += new Vector3(0.78f, 0, 0), 0.5f); players[playerIndex % 3].myCardInfo.Remove(tableCards[i]); } //判断是否获胜 if (players[playerIndex % 3].myCardInfo.Count == 0) { UnitTool.ToolStartCoroutine(Win(players[playerIndex % 3])); return; } //是玩家出牌 if (playerIndex % 3 == 0) { //对当前手牌进行重新显示 pokerTable.ShowCards(players[0].myCardInfo); } //当前玩家轮回结束 players[playerIndex % 3].myTerm = true; //开始下一个玩家的出牌 StartPlay(); }
public static Dictionary <int, List <int> > FindPromptCards(List <int> myCards, List <int> lastCards, DDZ_POKER_TYPE lastCardType) { Dictionary <int, List <int> > PromptCards = new Dictionary <int, List <int> >(); Hashtable tempMyCardHash = SortCardUseHash1(myCards); // 上一手牌的个数 int prevSize = lastCards.Count; // 我手牌的个数 int mySize = myCards.Count; int prevGrade = 0; if (prevSize > 0) { prevGrade = lastCards[0]; //Debug.Log("prevGrade" + prevGrade); } // 我先出牌,上家没有牌 if (prevSize == 0 && mySize != 0) { if (MyUtil.GetRange(0, 2) == 0 && mySize > 1) { lastCards.Add(0); lastCards.Add(0); prevSize = 2; int tempCount = 0; List <int> myCardsHashKey = new List <int>(); foreach (int key in tempMyCardHash.Keys) { myCardsHashKey.Add(key); } myCardsHashKey.Sort(); for (int i = 0; i < myCardsHashKey.Count; i++) { if (myCardsHashKey[i] > prevGrade && (int)tempMyCardHash[myCardsHashKey[i]] >= 2) { List <int> tempIntList = new List <int>(); tempIntList.Add(myCardsHashKey[i]); tempIntList.Add(myCardsHashKey[i]); PromptCards.Add(tempCount, tempIntList); tempCount++; } } if (PromptCards.Count == 0) { lastCards.Clear(); prevSize = 0; //把所有牌权重存入返回 Debug.Log("上家没有牌"); //List<int> myCardsHashKey = new List<int>(); foreach (int key in tempMyCardHash.Keys) { myCardsHashKey.Add(key); } myCardsHashKey.Sort(); for (int i = 0; i < myCardsHashKey.Count; i++) { List <int> tempIntList = new List <int>(); tempIntList.Add(myCardsHashKey[i]); PromptCards.Add(i, tempIntList); } } } else { //把所有牌权重存入返回 Debug.Log("上家没有牌"); List <int> myCardsHashKey = new List <int>(); foreach (int key in tempMyCardHash.Keys) { myCardsHashKey.Add(key); } myCardsHashKey.Sort(); for (int i = 0; i < myCardsHashKey.Count; i++) { List <int> tempIntList = new List <int>(); tempIntList.Add(myCardsHashKey[i]); PromptCards.Add(i, tempIntList); } } } // 集中判断是否王炸,免得多次判断王炸 if (lastCardType == DDZ_POKER_TYPE.KING_BOMB) { Debug.Log("上家王炸,肯定不能出。"); } // 比较2家的牌,主要有2种情况,1.我出和上家一种类型的牌,即对子管对子; // 2.我出炸弹,此时,和上家的牌的类型可能不同 // 王炸的情况已经排除 // 上家出单 if (lastCardType == DDZ_POKER_TYPE.SINGLE) { int tempCount = 0; List <int> myCardsHashKey = new List <int>(); foreach (int key in tempMyCardHash.Keys) { myCardsHashKey.Add(key); } myCardsHashKey.Sort(); for (int i = 0; i < myCardsHashKey.Count; i++) { if (myCardsHashKey[i] > prevGrade) { List <int> tempIntList = new List <int>(); tempIntList.Add(myCardsHashKey[i]); PromptCards.Add(tempCount, tempIntList); tempCount++; } } } // 上家出对子 else if (lastCardType == DDZ_POKER_TYPE.TWIN) { int tempCount = 0; List <int> myCardsHashKey = new List <int>(); foreach (int key in tempMyCardHash.Keys) { myCardsHashKey.Add(key); } myCardsHashKey.Sort(); for (int i = 0; i < myCardsHashKey.Count; i++) { if (myCardsHashKey[i] > prevGrade && (int)tempMyCardHash[myCardsHashKey[i]] >= 2) { List <int> tempIntList = new List <int>(); tempIntList.Add(myCardsHashKey[i]); tempIntList.Add(myCardsHashKey[i]); PromptCards.Add(tempCount, tempIntList); tempCount++; } } } // 上家出3不带 else if (lastCardType == DDZ_POKER_TYPE.TRIPLE) { int tempCount = 0; List <int> myCardsHashKey = new List <int>(); foreach (int key in tempMyCardHash.Keys) { myCardsHashKey.Add(key); } myCardsHashKey.Sort(); for (int i = 0; i < myCardsHashKey.Count; i++) { if (myCardsHashKey[i] > prevGrade && (int)tempMyCardHash[myCardsHashKey[i]] >= 3) { List <int> tempIntList = new List <int>(); tempIntList.Add(myCardsHashKey[i]); tempIntList.Add(myCardsHashKey[i]); tempIntList.Add(myCardsHashKey[i]); PromptCards.Add(tempCount, tempIntList); tempCount++; } } } // 上家出3带1 else if (lastCardType == DDZ_POKER_TYPE.TRIPLE_WITH_SINGLE) { // 3带1 3不带 比较只多了一个判断条件 if (mySize < 4) { } int grade3 = 0; foreach (int key in tempMyCardHash.Keys) { if (int.Parse(tempMyCardHash[key].ToString()) == 1) { grade3 = key; break; } } int tempCount = 0; List <int> myCardsHashKey = new List <int>(); foreach (int key in tempMyCardHash.Keys) { myCardsHashKey.Add(key); } myCardsHashKey.Sort(); for (int i = 0; i < myCardsHashKey.Count; i++) { if (myCardsHashKey[i] > prevGrade && (int)tempMyCardHash[myCardsHashKey[i]] >= 3) { List <int> tempIntList = new List <int>(); tempIntList.Add(myCardsHashKey[i]); tempIntList.Add(myCardsHashKey[i]); tempIntList.Add(myCardsHashKey[i]); tempIntList.Add(grade3); PromptCards.Add(tempCount, tempIntList); tempCount++; } } } // 上家出3带2 else if (lastCardType == DDZ_POKER_TYPE.TRIPLE_WITH_TWIN) { // 3带1 3不带 比较只多了一个判断条件 if (mySize < 5) { } int grade3 = 0; int grade4 = 0; foreach (int key in tempMyCardHash.Keys) { if (int.Parse(tempMyCardHash[key].ToString()) == 2) { grade3 = key; grade4 = key; break; } } int tempCount = 0; List <int> myCardsHashKey = new List <int>(); foreach (int key in tempMyCardHash.Keys) { myCardsHashKey.Add(key); } myCardsHashKey.Sort(); for (int i = 0; i < myCardsHashKey.Count; i++) { if (myCardsHashKey[i] > prevGrade && (int)tempMyCardHash[myCardsHashKey[i]] >= 3) { List <int> tempIntList = new List <int>(); tempIntList.Add(myCardsHashKey[i]); tempIntList.Add(myCardsHashKey[i]); tempIntList.Add(myCardsHashKey[i]); tempIntList.Add(grade3); tempIntList.Add(grade4); PromptCards.Add(tempCount, tempIntList); tempCount++; } } } // 上家出炸弹 else if (lastCardType == DDZ_POKER_TYPE.FOUR_BOMB) { int tempCount = 0; // 4张牌可以大过上家的牌 for (int i = mySize - 1; i >= 3; i--) { int grade0 = myCards[i]; int grade1 = myCards[i - 1]; int grade2 = myCards[i - 2]; int grade3 = myCards[i - 3]; if (grade0 == grade1 && grade0 == grade2 && grade0 == grade3) { if (grade0 > prevGrade) { // 把四张牌存进去 List <int> tempIntList = new List <int>(); tempIntList.Add(grade0); tempIntList.Add(grade1); tempIntList.Add(grade2); tempIntList.Add(grade3); PromptCards.Add(tempCount, tempIntList); tempCount++; } } } } // 上家出4带2 else if (lastCardType == DDZ_POKER_TYPE.FOUR_WITH_SINGLE) { // 4张牌可以大过上家的牌 for (int i = mySize - 1; i >= 3; i--) { int grade0 = myCards[i]; int grade1 = myCards[i - 1]; int grade2 = myCards[i - 2]; int grade3 = myCards[i - 3]; if (grade0 == grade1 && grade0 == grade2 && grade0 == grade3) { // 只要有炸弹,则返回true } } } // 上家出4带2 对子 else if (lastCardType == DDZ_POKER_TYPE.FOUR_WITH_SINGLE) { // 4张牌可以大过上家的牌 for (int i = mySize - 1; i >= 3; i--) { int grade0 = myCards[i]; int grade1 = myCards[i - 1]; int grade2 = myCards[i - 2]; int grade3 = myCards[i - 3]; if (grade0 == grade1 && grade0 == grade2 && grade0 == grade3) { // 只要有炸弹,则返回true } } } // 上家出顺子 else if (lastCardType == DDZ_POKER_TYPE.STRAIGHT_SINGLE) { if (mySize < prevSize) { } else { List <int> tempMyCards = new List <int>(); tempMyCards = myCards; Hashtable myCardsHash = SortCardUseHash(tempMyCards); if (myCardsHash.Count < prevSize) { Debug.Log("hash的总数小于顺子的count 肯定fales"); } List <int> myCardsHashKey = new List <int>(); foreach (int key in myCardsHash.Keys) { myCardsHashKey.Add(key); } myCardsHashKey.Sort(); int tempCount = 0; for (int i = myCardsHashKey.Count - 1; i >= prevSize - 1; i--) { List <int> cards = new List <int>(); for (int j = 0; j < prevSize; j++) { cards.Add(myCardsHashKey[myCardsHashKey.Count - 1 - i + j]); } DDZ_POKER_TYPE myCardType = DDZ_POKER_TYPE.DDZ_PASS; bool isRule = PokerRules.PopEnable(cards, out myCardType); if (myCardType == DDZ_POKER_TYPE.STRAIGHT_SINGLE) { int myGrade2 = cards[cards.Count - 1]; // 最大的牌在最后 int prevGrade2 = lastCards[prevSize - 1]; // 最大的牌在最后 if (myGrade2 > prevGrade2) { //存进去PromptCards PromptCards.Add(tempCount, cards); tempCount++; } } } } } // 上家出连对 else if (lastCardType == DDZ_POKER_TYPE.STRAIGHT_TWIN) { if (mySize < prevSize) { } else { List <int> tempMyCards = new List <int>(); tempMyCards = myCards; Hashtable myCardsHash = SortCardUseHash(tempMyCards); if (myCardsHash.Count < prevSize) { Debug.Log("hash的总数小于顺子的count 肯定fales"); } List <int> myCardsHashKey = new List <int>(); foreach (int key in myCardsHash.Keys) { myCardsHashKey.Add(key); } myCardsHashKey.Sort(); int tempCount = 0; for (int i = myCardsHashKey.Count - 1; i >= prevSize - 1; i--) { List <int> cards = new List <int>(); for (int j = 0; j < prevSize; j++) { cards.Add(myCardsHashKey[myCardsHashKey.Count - 1 - i + j]); } DDZ_POKER_TYPE myCardType = DDZ_POKER_TYPE.DDZ_PASS; bool isRule = PokerRules.PopEnable(cards, out myCardType); if (myCardType == DDZ_POKER_TYPE.STRAIGHT_SINGLE) { int myGrade2 = cards[cards.Count - 1]; // 最大的牌在最后 int prevGrade2 = lastCards[prevSize - 1]; // 最大的牌在最后 if (myGrade2 > prevGrade2) { for (int ii = 0; ii < cards.Count; ii++) { if ((int)myCardsHash[cards[ii]] < 2) { Debug.Log("是顺子但不是双顺"); return(PromptCards); } else { for (int iii = 0; iii < cards.Count; iii++) { cards.Add(cards[iii]); } //存进去PromptCards PromptCards.Add(tempCount, cards); tempCount++; } } } } } } } //上家出飞机 else if (lastCardType == DDZ_POKER_TYPE.PLANE_PURE) { if (mySize < prevSize) { } else { int tempCount = 0; for (int i = 0; i <= mySize - prevSize; i++) { List <int> cards = new List <int>(); for (int j = 0; j < prevSize; j++) { cards.Add(myCards[i + j]); } DDZ_POKER_TYPE myCardType = DDZ_POKER_TYPE.DDZ_PASS; bool isRule = PokerRules.PopEnable(cards, out myCardType); if (myCardType == DDZ_POKER_TYPE.PLANE_PURE) { int myGrade4 = cards[4]; // int prevGrade4 = lastCards[4]; // if (myGrade4 > prevGrade4) { //存进去PromptCards PromptCards.Add(tempCount, cards); tempCount++; } } } } } //上家出飞机带单 else if (lastCardType == DDZ_POKER_TYPE.PLANE_WITH_SINGLE) { if (mySize < prevSize) { } else { int tempCount = 0; for (int i = 0; i <= mySize - prevSize; i++) { List <int> cards = new List <int>(); for (int j = 0; j < prevSize - prevSize / 4; j++) { cards.Add(myCards[i + j]); } DDZ_POKER_TYPE myCardType = DDZ_POKER_TYPE.DDZ_PASS; bool isRule = PokerRules.PopEnable(cards, out myCardType); if (myCardType == DDZ_POKER_TYPE.PLANE_PURE) { int myGrade4 = cards[4]; // int prevGrade4 = lastCards[4]; // if (myGrade4 > prevGrade4) { int ii = 0; //存进去PromptCards 然后再找一个最小的两个单 foreach (int key in tempMyCardHash.Keys) { if (int.Parse(tempMyCardHash[key].ToString()) == 1) { cards.Add(key); ii++; if (ii == prevSize / 4) { break; } } } PromptCards.Add(tempCount, cards); tempCount++; } } } } } //上家出飞机带双 else if (lastCardType == DDZ_POKER_TYPE.PLANE_WITH_TWIN) { if (mySize < prevSize) { } else { int tempCount = 0; for (int i = 0; i <= mySize - prevSize; i++) { List <int> cards = new List <int>(); for (int j = 0; j < prevSize - prevSize / 5; j++) { cards.Add(myCards[i + j]); } DDZ_POKER_TYPE myCardType = DDZ_POKER_TYPE.DDZ_PASS; bool isRule = PokerRules.PopEnable(cards, out myCardType); if (myCardType == DDZ_POKER_TYPE.PLANE_PURE) { int myGrade4 = cards[4]; // int prevGrade4 = lastCards[4]; // if (myGrade4 > prevGrade4) { List <int> tempTwoList = new List <int>(); for (int ii = 0; ii < cards.Count; ii++) { int tempInt = 0; for (int j = 0; j < cards.Count; j++) { if (cards[ii] == cards[j]) { tempInt++; } } if (tempInt == 2) { tempTwoList.Add(cards[ii]); } } if (tempTwoList.Count / 2 < prevSize / 5) { } else { //存进去 int iii = 0; //存进去PromptCards 然后再找一个最小的两个单 foreach (int key in tempMyCardHash.Keys) { if (int.Parse(tempMyCardHash[key].ToString()) == 2) { cards.Add(key); cards.Add(key); iii++; if (iii == prevSize / 5) { break; } } } PromptCards.Add(tempCount, cards); tempCount++; } } } } } } // 集中判断对方不是炸弹,我出炸弹的情况 if (lastCardType != DDZ_POKER_TYPE.FOUR_BOMB) { List <int> myCardsHashKey = new List <int>(); foreach (int key in tempMyCardHash.Keys) { myCardsHashKey.Add(key); } myCardsHashKey.Sort(); for (int i = 0; i < myCardsHashKey.Count; i++) { if ((int)tempMyCardHash[myCardsHashKey[i]] == 4) { List <int> tempIntList = new List <int>(); tempIntList.Add(myCardsHashKey[i]); tempIntList.Add(myCardsHashKey[i]); tempIntList.Add(myCardsHashKey[i]); tempIntList.Add(myCardsHashKey[i]); Debug.Log("PromptCards.Count" + PromptCards.Count); PromptCards.Add(PromptCards.Count, tempIntList); } } } if (mySize >= 2) { List <int> myCardsHashKey = new List <int>(); foreach (int key in tempMyCardHash.Keys) { myCardsHashKey.Add(key); } if (myCardsHashKey.Contains(53) && myCardsHashKey.Contains(54)) { List <int> tempIntList = new List <int>(); tempIntList.Add(53); tempIntList.Add(54); PromptCards.Add(PromptCards.Count, tempIntList); } } return(PromptCards); }