private List <Card> GetCanPassCardForHard() { List <Card> PassCard = new List <Card>(); var lastCards = Judgment.GetLastTableCards(); var lastCardsType = Judgment.CheckCardType(lastCards); if (gamescene.m_player[0].deck.transform.childCount < 7) { return(GetCanPassCard_2()); } return(_GetCanPassCardForHard()); }
private List <Card> GetCanPassCard_2() { List <Card> PassCard = new List <Card>(); var lastCards = Judgment.GetLastTableCards(); var lastCardsType = Judgment.CheckCardType(lastCards); Debug.Log(lastCardsType); int count = 0; switch (lastCardsType) { case CardsType.None: break; case CardsType.Single: count = 0; while (count < 1000) { Card card = deck.transform.GetChild(deck.transform.childCount - 1).gameObject.transform.GetComponent <Card>(); card.IsChoose = true; if (card.CheckCanPassCard()) { PassCard.Add(card); break; } else { card.IsChoose = false; } count++; } break; case CardsType.Pair: var pairdeck = CardTypeCheckMgr.FindPair(HandCards); for (int i = 0; i < pairdeck.Count; i++) { var IsCanPass = CardTypeCheckMgr.compPair( pairdeck[i][pairdeck[i].Count - 1], lastCards[lastCards.Count - 1]); if (IsCanPass) { PassCard = pairdeck[i]; break; } } break; case CardsType.ThreeOfKinds: var threedeck = CardTypeCheckMgr.FindThreeOfKinds(HandCards); for (int i = 0; i < threedeck.Count; i++) { var IsCanPass = CardTypeCheckMgr.compThreeOfKinds( threedeck[i][threedeck[i].Count - 1], lastCards[lastCards.Count - 1]); if (IsCanPass) { PassCard = threedeck[i]; break; } } break; case CardsType.Straight: var Straightdeck = CardTypeCheckMgr.FindStraight(HandCards); for (int i = 0; i < Straightdeck.Count; i++) { var IsCanPass = CardTypeCheckMgr.compStraight( Straightdeck[i], lastCards); if (IsCanPass) { PassCard = Straightdeck[i]; break; } } break; case CardsType.FullHouse: var FullHousedeck = CardTypeCheckMgr.FindFullHouse(HandCards); for (int i = 0; i < FullHousedeck.Count; i++) { var IsCanPass = CardTypeCheckMgr.compFullHouse( FullHousedeck[i], lastCards); if (IsCanPass) { PassCard = FullHousedeck[i]; break; } } break; case CardsType.FourOfKinds: var FourOfKindsDeck = CardTypeCheckMgr.FindFourOfKinds(HandCards); for (int i = 0; i < FourOfKindsDeck.Count; i++) { var IsCanPass = CardTypeCheckMgr.compFourOfKinds( FourOfKindsDeck[i], lastCards); if (IsCanPass) { PassCard = FourOfKindsDeck[i]; break; } } break; case CardsType.StraightFlush: var StraightFlushDeck = CardTypeCheckMgr.FindStraightFlush(HandCards); for (int i = 0; i < StraightFlushDeck.Count; i++) { var IsCanPass = CardTypeCheckMgr.compStraightFlush( StraightFlushDeck[i], lastCards); if (IsCanPass) { PassCard = StraightFlushDeck[i]; break; } } break; default: break; } return(PassCard); }
private List <Card> _GetCanPassCardForHard() { List <Card> PassCard = new List <Card>(); var lastCards = Judgment.GetLastTableCards(); var lastCardsType = Judgment.CheckCardType(lastCards); List <Card> tempHandCards = new List <Card>(); tempHandCards = HandCards; var monsterCards_1 = CardTypeCheckMgr.FindFourOfKinds(tempHandCards); var monsterCards_2 = CardTypeCheckMgr.FindStraightFlush(tempHandCards); for (int i = 0; i < tempHandCards.Count; i++) { if (monsterCards_1.Count == 0) { break; } for (int j = 0; j < monsterCards_1[0].Count; j++) { if (tempHandCards[i].symbol == monsterCards_1[0][j].symbol && tempHandCards[i].value == monsterCards_1[0][j].value) { tempHandCards.RemoveAt(i); } } } for (int i = 0; i < tempHandCards.Count; i++) { if (monsterCards_2.Count == 0) { break; } for (int j = 0; j < monsterCards_2[0].Count; j++) { if (tempHandCards[i].symbol == monsterCards_2[0][j].symbol && tempHandCards[i].value == monsterCards_2[0][j].value) { tempHandCards.RemoveAt(i); } } } int count = 0; switch (lastCardsType) { case CardsType.None: break; case CardsType.Single: count = 0; while (count < 1000) { int index = Random.Range(0, tempHandCards.Count); Card card = new Card(0, 0); for (int i = 0; i < deck.transform.childCount; i++) { if (tempHandCards[index].value == deck.transform.GetChild(i).gameObject.transform.GetComponent <Card>().value) { card = deck.transform.GetChild(i).gameObject.transform.GetComponent <Card>(); card.IsChoose = true; } } if (card.CheckCanPassCard() && card.value != 2) { PassCard.Add(card); break; } else { card.IsChoose = false; } count++; } break; case CardsType.Pair: var pairdeck = CardTypeCheckMgr.FindPair(tempHandCards); for (int i = 0; i < pairdeck.Count; i++) { var IsCanPass = CardTypeCheckMgr.compPair( pairdeck[i][pairdeck[i].Count - 1], lastCards[lastCards.Count - 1]); if (lastCards[lastCards.Count - 1].value == 14) { break; } if (IsCanPass) { PassCard = pairdeck[i]; break; } } break; case CardsType.ThreeOfKinds: var threedeck = CardTypeCheckMgr.FindThreeOfKinds(tempHandCards); for (int i = 0; i < threedeck.Count; i++) { var IsCanPass = CardTypeCheckMgr.compThreeOfKinds( threedeck[i][threedeck[i].Count - 1], lastCards[lastCards.Count - 1]); if (lastCards[lastCards.Count - 1].value == 2) { break; } if (IsCanPass) { PassCard = threedeck[i]; break; } } break; case CardsType.Straight: var Straightdeck = CardTypeCheckMgr.FindStraight(tempHandCards); bool hasTwo = false; for (int i = 0; i < Straightdeck.Count; i++) { var IsCanPass = CardTypeCheckMgr.compStraight( Straightdeck[i], lastCards); foreach (var item in lastCards) { if (item.value == 2) { hasTwo = true; } } if (hasTwo) { break; } if (IsCanPass) { PassCard = Straightdeck[i]; break; } } break; case CardsType.FullHouse: var FullHousedeck = CardTypeCheckMgr.FindFullHouse(tempHandCards); hasTwo = false; for (int i = 0; i < FullHousedeck.Count; i++) { var IsCanPass = CardTypeCheckMgr.compFullHouse( FullHousedeck[i], lastCards); foreach (var item in lastCards) { if (item.value == 2) { hasTwo = true; } } if (hasTwo) { break; } if (IsCanPass) { PassCard = FullHousedeck[i]; break; } } break; case CardsType.FourOfKinds: var FourOfKindsDeck = CardTypeCheckMgr.FindFourOfKinds(tempHandCards); for (int i = 0; i < FourOfKindsDeck.Count; i++) { var IsCanPass = CardTypeCheckMgr.compFourOfKinds( FourOfKindsDeck[i], lastCards); if (IsCanPass) { PassCard = FourOfKindsDeck[i]; break; } } break; case CardsType.StraightFlush: var StraightFlushDeck = CardTypeCheckMgr.FindStraightFlush(tempHandCards); for (int i = 0; i < StraightFlushDeck.Count; i++) { var IsCanPass = CardTypeCheckMgr.compStraightFlush( StraightFlushDeck[i], lastCards); if (IsCanPass) { PassCard = StraightFlushDeck[i]; break; } } break; default: break; } return(PassCard); }
// 檢查當前牌型可以用哪些牌型 private void CheckCardTypeBtnEnable(List <Card> deck) { if (Judgment.CheckAllPlayerPass()) { // 如果是你的自由出牌機會,則不給pass UIManger.btn_PassRank.interactable = false; if (CardTypeCheckMgr.FindPair(deck).Count != 0) { UIManger.btn_findpair.interactable = true; } if (CardTypeCheckMgr.FindThreeOfKinds(deck).Count != 0) { UIManger.btn_findthree.interactable = true; } if (CardTypeCheckMgr.FindStraight(deck).Count != 0) { UIManger.btn_findStraight.interactable = true; } if (CardTypeCheckMgr.FindFullHouse(deck).Count != 0) { UIManger.btn_findFullHouse.interactable = true; } if (CardTypeCheckMgr.FindFourOfKinds(deck).Count != 0) { UIManger.btn_findFour.interactable = true; } if (CardTypeCheckMgr.FindStraightFlush(deck).Count != 0) { UIManger.btn_findStraightFlush.interactable = true; } } else { UIManger.btn_PassRank.interactable = true; // 獲得最後一手牌 var LastCardsOfTable = Judgment.GetLastTableCards(); // 檢查最後一手牌的牌型 var type = Judgment.CheckCardType(LastCardsOfTable); switch (type) { case CardsType.Pair: if (CardTypeCheckMgr.FindPair(deck).Count != 0) { UIManger.btn_findpair.interactable = true; } break; case CardsType.ThreeOfKinds: if (CardTypeCheckMgr.FindThreeOfKinds(deck).Count != 0) { UIManger.btn_findthree.interactable = true; } break; case CardsType.Straight: if (CardTypeCheckMgr.FindStraight(deck).Count != 0) { UIManger.btn_findStraight.interactable = true; } break; case CardsType.FullHouse: if (CardTypeCheckMgr.FindFullHouse(deck).Count != 0) { UIManger.btn_findFullHouse.interactable = true; } break; } if (CardTypeCheckMgr.FindFourOfKinds(deck).Count != 0) { UIManger.btn_findFour.interactable = true; } if (CardTypeCheckMgr.FindStraightFlush(deck).Count != 0) { UIManger.btn_findStraightFlush.interactable = true; } } }