예제 #1
0
파일: AIPlayer.cs 프로젝트: w1233120/Big-2
    private void CheckCardTypeAmount(List <Card> deck)
    {
        int count = 0;

        count += CardTypeCheckMgr.FindPair(deck).Count;
        count += CardTypeCheckMgr.FindThreeOfKinds(deck).Count;
        count += CardTypeCheckMgr.FindStraight(deck).Count;
        count += CardTypeCheckMgr.FindFullHouse(deck).Count;
        count += CardTypeCheckMgr.FindFourOfKinds(deck).Count;
        count += CardTypeCheckMgr.FindStraightFlush(deck).Count;
    }
예제 #2
0
파일: AIPlayer.cs 프로젝트: w1233120/Big-2
    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);
    }
예제 #3
0
파일: AIPlayer.cs 프로젝트: w1233120/Big-2
    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);
    }
예제 #4
0
파일: AIPlayer.cs 프로젝트: w1233120/Big-2
    private List <Card> PassRandomCards()
    {
        List <Card> PassCard = new List <Card>();
        CardsType   type     = (CardsType)Random.Range((int)CardsType.None, (int)CardsType.StraightFlush);

        switch (type)
        {
        case CardsType.None:
            break;

        case CardsType.Single:
            int count = 0;
            while (count < 1000)
            {
                int  index = Random.Range(0, deck.transform.childCount);
                Card card  = deck.transform.GetChild(index).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);
            if (pairdeck.Count > 0)
            {
                PassCard = pairdeck[0];
            }
            break;

        case CardsType.ThreeOfKinds:
            var threedeck = CardTypeCheckMgr.FindThreeOfKinds(HandCards);
            if (threedeck.Count > 0)
            {
                PassCard = threedeck[0];
            }
            break;

        case CardsType.Straight:
            var Straightdeck = CardTypeCheckMgr.FindStraight(HandCards);
            if (Straightdeck.Count > 0)
            {
                PassCard = Straightdeck[0];
            }
            break;

        case CardsType.FullHouse:
            var FullHousedeck = CardTypeCheckMgr.FindFullHouse(HandCards);
            if (FullHousedeck.Count > 0)
            {
                PassCard = FullHousedeck[0];
            }
            break;

        case CardsType.FourOfKinds:
            var FourOfKindsdeck = CardTypeCheckMgr.FindFourOfKinds(HandCards);
            if (FourOfKindsdeck.Count > 0)
            {
                PassCard = FourOfKindsdeck[0];
            }
            break;

        case CardsType.StraightFlush:
            var StraightFlushdeck = CardTypeCheckMgr.FindStraightFlush(HandCards);
            if (StraightFlushdeck.Count > 0)
            {
                PassCard = StraightFlushdeck[0];
            }
            break;

        default:
            break;
        }


        return(PassCard);
    }
예제 #5
0
파일: Player.cs 프로젝트: w1233120/Big-2
    // 檢查當前牌型可以用哪些牌型
    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;
            }
        }
    }
예제 #6
0
파일: UIManger.cs 프로젝트: w1233120/Big-2
    // 牌型選擇ui監聽事件實作
    private void SenderFunction(string senderName)
    {
        List <List <Card> > decks = new List <List <Card> >();
        Player      player        = GameView.transform.GetComponent <GameView>().m_player[0];
        List <Card> cards         = player.GetCardList();

        // 將牌先全部放下
        for (int i = 0; i < player.deck.transform.childCount; i++)
        {
            player.deck.transform.GetChild(i).transform.GetComponent <Card>().SetCardCancel();
        }

        // 如果是同顆按鈕則尋找下一個位置
        if (tempButton == senderName)
        {
            tempButtonindex++;
        }
        else
        {
            tempButton      = senderName;
            tempButtonindex = 0;
        }

        switch (senderName)
        {
        case "btn_findpair":
            decks = CardTypeCheckMgr.FindPair(cards);
            break;

        case "btn_findthree":
            decks = CardTypeCheckMgr.FindThreeOfKinds(cards);
            break;

        case "btn_findStraight":
            decks = CardTypeCheckMgr.FindStraight(cards);
            break;

        case "btn_findFullHouse":
            decks = CardTypeCheckMgr.FindFullHouse(cards);
            break;

        case "btn_findFour":
            decks = CardTypeCheckMgr.FindFourOfKinds(cards);
            break;

        case "btn_findStraightFlush":
            decks = CardTypeCheckMgr.FindStraightFlush(cards);
            break;
        }

        // 找牌,並選起
        for (int i = 0; i < player.deck.transform.childCount; i++)
        {
            Card card      = player.deck.transform.GetChild(i).transform.GetComponent <Card>();
            var  tempdecks = decks[tempButtonindex % decks.Count];
            for (int j = 0; j < tempdecks.Count; j++)
            {
                if (card.value == tempdecks[j].value &&
                    card.symbol == tempdecks[j].symbol)
                {
                    card.SetCardSelect();
                }
            }
        }

        // 去檢查是否可以出牌
        if (Judgment.CheckCanPassCard(player.deck))
        {
            btn_PassCards.interactable = true;
        }
        else
        {
            btn_PassCards.interactable = false;
        }
    }