유 니 티 개발 두 지주 알고리즘 - 두 손 카드 의 크기 비교

7348 단어 unity3d
카드http://blog.csdn.net/csdn_cjt / article / details / 78593140 제1장
다음은 코드.
#region isSelectCardCanPut 

    public static bool isSelectCardCanPut(List myCards,DDZ_POKER_TYPE myCardType, List lastCards, DDZ_POKER_TYPE lastCardTye)
    {
        //             null
        if (myCards == null || lastCards == null)
        {
            return false;
        }

        if (myCardType == null || lastCardTye == null)
        {
            Debug.Log("        ,     。");
            return false;
        }

        //        
        int prevSize = lastCards.Count;
        int mySize = myCards.Count;

        //     ,     
        if (prevSize == 0 && mySize != 0)
        {
            return true;
        }

        //         ,        
        if (lastCardTye == DDZ_POKER_TYPE.KingBomb)
        {
            Debug.Log("    ,     。");
            return false;
        }
        else if (myCardType == DDZ_POKER_TYPE.KingBomb)
        {
            Debug.Log("   ,    。");
            return true;
        }

        //           ,       
        if (lastCardTye != DDZ_POKER_TYPE.FourBomb && myCardType == DDZ_POKER_TYPE.FourBomb)
        {
            return true;
        }

        //         

        int myGrade = myCards[0];
        int prevGrade = lastCards[0];

        //   2   ,   2   ,1.           ,      ;
        // 2.    ,  ,            
        //          

        //  
        if (lastCardTye == DDZ_POKER_TYPE.Single && myCardType == DDZ_POKER_TYPE.Single)
        {
            //            
            return compareGrade(myGrade, prevGrade);
        }
        //   
        else if (lastCardTye == DDZ_POKER_TYPE.Twin
                && myCardType == DDZ_POKER_TYPE.Twin)
        {
            // 2          
            return compareGrade(myGrade, prevGrade);

        }
        // 3  
        else if (lastCardTye == DDZ_POKER_TYPE.Triple
                && myCardType == DDZ_POKER_TYPE.Triple)
        {
            // 3          
            return compareGrade(myGrade, prevGrade);
        }
        //   
        else if (lastCardTye == DDZ_POKER_TYPE.FourBomb
                && myCardType == DDZ_POKER_TYPE.FourBomb)
        {
            // 4          
            return compareGrade(myGrade, prevGrade);

        }
        // 3 1
        else if (lastCardTye == DDZ_POKER_TYPE.TripleWithSingle)
        {

            // 3 1     2     
            myGrade = myCards[1];
            prevGrade = lastCards[1];
            return compareGrade(myGrade, prevGrade);

        }
        else if (lastCardTye == DDZ_POKER_TYPE.TripleWithTwin)
        {

            // 3 2     3     
            myGrade = myCards[2];
            prevGrade = lastCards[2];
            return compareGrade(myGrade, prevGrade);

        }
        
        // 4 2
        else if (lastCardTye == DDZ_POKER_TYPE.FourWithSingle
                && myCardType == DDZ_POKER_TYPE.FourWithSingle)
        {

            // 4 2     3     
            myGrade = myCards[2];
            prevGrade = lastCards[2];

        }
        // 4 2  
        else if (lastCardTye == DDZ_POKER_TYPE.FourWithSingle
                && myCardType == DDZ_POKER_TYPE.FourWithSingle)
        {

            
            myGrade = myCards[2];
            prevGrade = lastCards[2];

        }
        //   
        else if (lastCardTye == DDZ_POKER_TYPE.StraightSingle
                && myCardType == DDZ_POKER_TYPE.StraightSingle)
        {
            if (mySize != prevSize)
            {
                return false;
            }
            else
            {
                //          1     
                myGrade = myCards[mySize-1];
                prevGrade = lastCards[prevSize - 1];
                return compareGrade(myGrade, prevGrade);
            }

        }
        //   
        else if (lastCardTye == DDZ_POKER_TYPE.StraightTwin
                && myCardType == DDZ_POKER_TYPE.StraightTwin)
        {
            if (mySize != prevSize)
            {
                return false;
            }
            else
            {
                //          1     
                myGrade = myCards[mySize - 1];
                prevGrade = lastCards[prevSize - 1];
                return compareGrade(myGrade, prevGrade);
            }

        }
        //     
        else if (lastCardTye == DDZ_POKER_TYPE.PlanePure
                && myCardType == DDZ_POKER_TYPE.PlanePure)
        {
            if (mySize != prevSize)
            {
                return false;
            }
            else
            {
                //333444555666            
                myGrade = myCards[4];
                prevGrade = lastCards[4];
                return compareGrade(myGrade, prevGrade);
            }
        }
        //    
        else if (lastCardTye == DDZ_POKER_TYPE.PlaneWithSingle
                && myCardType == DDZ_POKER_TYPE.PlaneWithSingle)
        {
            if (mySize != prevSize)
            {
                return false;
            }
            else
            {
                List tempThreeList = new List();
                for (int i = 0; i < myCards.Count; i++)
                {
                    int tempInt = 0;
                    for (int j = 0; j < myCards.Count; j++)
                    {

                        if (myCards[i] == myCards[j])
                        {
                            tempInt++;
                        }

                    }
                    if (tempInt == 3)
                    {
                        tempThreeList.Add(myCards[i]);
                    }
                }
                myGrade = tempThreeList[4];
                prevGrade = lastCards[4];
                return compareGrade(myGrade, prevGrade);
            }
        }
        //    
        else if (lastCardTye == DDZ_POKER_TYPE.PlaneWithTwin
                && myCardType == DDZ_POKER_TYPE.PlaneWithTwin)
        {
            if (mySize != prevSize)
            {
                return false;
            }
            else
            {
                List tempThreeList = new List();
                List tempTwoList = new List();
                for (int i = 0; i < myCards.Count; i++)
                {
                    int tempInt = 0;
                    for (int j = 0; j < myCards.Count; j++)
                    {

                        if (myCards[i] == myCards[j])
                        {
                            tempInt++;
                        }

                    }
                    if (tempInt == 3)
                    {
                        tempThreeList.Add(myCards[i]);
                    }
                    else if (tempInt == 2)
                    {
                        tempTwoList.Add(myCards[i]);
                    }

                }
                myGrade = tempThreeList[4];
                prevGrade = lastCards[4];
                if (compareGrade(myGrade, prevGrade))
                {
                    return DDZCardRule.IsAllDouble(tempTwoList);
                }
            }
        }

        //       
        return false;
    }
    #endregion

좋은 웹페이지 즐겨찾기