Exemplo n.º 1
0
    public void EasyAISystem()  // 簡單電腦
    {
        List <Card> PassCard = new List <Card>();

        if (Judgment.CheckAllPlayerPass())
        {
            // Random看要出什麼牌型
            PassCard = PassRandomCards();

            if (PassCard.Count == 0)
            {
                EasyAISystem(); // 重新呼叫, 不可過水, 第一位不可以亂出
                return;
            }
        }
        else
        {
            //獲得可以出的牌
            PassCard = GetCanPassCard();
        }

        // 把牌塞入
        foreach (var card in PassCard)
        {
            for (int i = 0; i < deck.transform.childCount; i++)
            {
                var handCard = deck.transform.GetChild(i).transform.GetComponent <Card>();

                if (card.value == handCard.value &&
                    card.symbol == handCard.symbol)
                {
                    handCard.SetCardSelect();
                }
            }
        }

        // 檢查如果前三家都pass, 並且不通過時,則必須重來
        if (Judgment.CheckAllPlayerPass() && !Judgment.CheckCanPassCard(deck))
        {
            for (int i = 0; i < deck.transform.childCount; i++)
            {
                Transform card = deck.transform.GetChild(i);
                if (card != null)
                {
                    card.GetComponent <Card>().SetCardCancel();
                }
            }
            EasyAISystem();
        }
        else
        {
            // 在這邊執行最後的出牌
            if (PassCard.Count != 0)
            {
                PassCards();
            }
            else
            {
                PassThisRank();
            }
        }
    }
Exemplo n.º 2
0
    // 檢查當前牌型可以用哪些牌型
    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;
            }
        }
    }