コード例 #1
0
ファイル: Judgment.cs プロジェクト: w1233120/Big-2
    // 檢查怪物牌比較
    private static bool CheckMonsterCard(List <Card> cards, List <Card> LastCard, CardsType cardType)
    {
        // 先看看自己手上有沒有怪物牌
        // 如果我的怪物牌比場上怪物牌還大直接給過, 相同則需比較
        if (CheckCardType(cards) > cardType)
        {
            return(true);
        }
        else
        {
            switch (cardType)
            {
            case CardsType.FourOfKinds:
                if (CardTypeCheckMgr.IsFourOfKinds(cards) == CardsType.FourOfKinds)
                {
                    return(CardTypeCheckMgr.compFourOfKinds(cards, LastCard));
                }
                return(false);

            case CardsType.StraightFlush:
                if (CardTypeCheckMgr.IsStraightFlush(cards) == CardsType.StraightFlush)
                {
                    return(CardTypeCheckMgr.compStraightFlush(cards, LastCard));
                }
                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);
    }