예제 #1
0
파일: Judgment.cs 프로젝트: w1233120/Big-2
    // 檢查非怪物牌比較
    private static bool CheckNomalCard(List <Card> cards, List <Card> LastCards, CardsType cardType)
    {
        if (CheckCardType(cards) > CardsType.FullHouse) // 如果自身牌為怪物牌直接給過
        {
            return(true);
        }

        switch (cardType)   // 不是的話另外判斷
        {
        case CardsType.Single:
            if (CardTypeCheckMgr.IsSingle(cards) == CardsType.Single)
            {
                return(CardTypeCheckMgr.compSingle(cards[0], LastCards[0]));
            }
            return(false);

        case CardsType.Pair:
            if (CardTypeCheckMgr.IsPair(cards) == CardsType.Pair)
            {
                return(CardTypeCheckMgr.compPair(cards[cards.Count - 1], LastCards[LastCards.Count - 1]));
            }
            return(false);

        case CardsType.ThreeOfKinds:
            if (CardTypeCheckMgr.IsThreeOfKinds(cards) == CardsType.ThreeOfKinds)
            {
                return(CardTypeCheckMgr.compThreeOfKinds(cards[cards.Count - 1], LastCards[LastCards.Count - 1]));
            }
            return(false);

        case CardsType.Straight:
            if (CardTypeCheckMgr.IsStraight(cards) == CardsType.Straight)
            {
                return(CardTypeCheckMgr.compStraight(cards, LastCards));
            }
            return(false);

        case CardsType.FullHouse:
            if (CardTypeCheckMgr.IsFullHouse(cards) == CardsType.FullHouse)
            {
                return(CardTypeCheckMgr.compFullHouse(cards, LastCards));
            }
            return(false);
        }
        return(false);
    }
예제 #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);
    }