Пример #1
0
    public void CardDrawAtList(List <CardData> cardList, DRAWCARD_TYPE eDrawCardType, float fTopValue)
    {
        //기존 카드 비활성화 해볼까?
        foreach (CardData card in m_drawCardList)
        {
            card.m_gray.SetActive(true);
        }

        foreach (CardData card in cardList)
        {
            if (!m_bHaveDragon && card.type == CARD_TYPE.DRACHE)
            {
                //용이 있다.
                m_bHaveDragon = true;
            }
            else if (card.type == CARD_TYPE.DASHUND)
            {
                //개를 냈다.
                m_bDrawDog = true;
            }

            //int siblingIndex = card.transform.GetSiblingIndex();

            card.transform.SetSiblingIndex(70 + m_depth++);

            card.SetOwnerPlayer(null);
        }

        m_drawCardList.AddRange(cardList);
        m_cardCount    = cardList.Count;
        m_drawCardType = eDrawCardType;
        m_topValue     = fTopValue;

        //++m_depth;
    }
Пример #2
0
    public void initCardDraw()
    {
        m_drawCardType = DRAWCARD_TYPE.NONE;
        m_topValue     = 0;
        m_cardCount    = 0;
        m_depth        = 0;
        m_bDrawDog     = false;
        m_bHaveDragon  = false;

        m_drawCardList.Clear();
    }
Пример #3
0
    public void Init()
    {
        if (m_bHavePhoenix)
        {
            CardData phoenixCard = m_selectedCard.Find(item => item.type == CARD_TYPE.PHOENIX);

            phoenixCard.value = 15;
        }

        for (int i = 0; i < m_selectedCard.Count; ++i)
        {
            m_selectedCard[i].RelaseSelect();
        }

        m_selectedCard.Clear();
        m_topValue      = 0;
        m_eDrawCardType = DRAWCARD_TYPE.NONE;
        m_bHavePhoenix  = false;
    }
Пример #4
0
    public virtual bool DrawCheck()
    {
        int size = m_selectedCard.GetSize();

        //리스트가 비어있으면 체크할 필요가 없다.
        if (size <= 0)
        {
            //내가 처음이다?
            if (CardDrawHandler.Instance.GetDrawCardType() == DRAWCARD_TYPE.NONE)
            {
                GameManager.Instance.SetActivePlayBtn(true);
                GameManager.Instance.m_drawBtn.Inactive();
            }
            else
            {
                GameManager.Instance.SetActivePlayBtn(false);
                GameManager.Instance.m_passBtn.Active();
            }
            return(false);
        }

        GameManager.Instance.SetActivePlayBtn(true);

        if (GameManager.Instance.GetTurnPlayer() == this)
        {
            GameManager.Instance.m_drawBtn.Active();
        }
        else
        {
            GameManager.Instance.m_drawBtn.Inactive();
        }

        DRAWCARD_TYPE eDrawCardType = CardDrawHandler.Instance.GetDrawCardType();

        //참새가 있다.
        if (GameManager.Instance.m_wishCardPopup.Selected())
        {
            string wishCardStr = GameManager.Instance.m_wishCardPopup.GetWishCard();

            //내가 선택한 카드중에 소원이 있다 없다?
            //내 카드중에 위시카드가 있고 선택한 카드안에 소원이 있는지 체크
            if (HaveWishCard(wishCardStr))
            {
                //낼수가 있다.
                if (IsDrawWishCard())
                {
                    //선택카드에 wish가 없으면 못낸다.
                    if (!m_selectedCard.FindWishCard(wishCardStr))
                    {
                        return(false);
                    }
                }
            }
        }

        // NONE 타입이거나 나랑 타입이 같으면 낼수 있다.
        if (eDrawCardType == DRAWCARD_TYPE.NONE)
        {
            return(m_selectedCard.GetDrawCardType() != DRAWCARD_TYPE.NONE);
        }
        else if (eDrawCardType == m_selectedCard.GetDrawCardType())
        {
            if (CardDrawHandler.Instance.GetCardCount() == m_selectedCard.GetSize() && CardDrawHandler.Instance.GetTopValue() < m_selectedCard.GetTopValue())
            {
                return(true);
            }
        }

        return(false);
    }
Пример #5
0
    public bool IsDrawWishCard()
    {
        //소원 카드를 낼 수 있는지 없는지 확인하자
        DRAWCARD_TYPE eCardType     = CardDrawHandler.Instance.GetDrawCardType();
        float         topValue      = CardDrawHandler.Instance.GetTopValue();
        float         wishCardValue = GameManager.Instance.m_wishCardPopup.GetWishCardValue();
        string        wishStr       = GameManager.Instance.m_wishCardPopup.GetWishCard();
        int           cardCount     = CardDrawHandler.Instance.GetCardCount();

        if (topValue < wishCardValue)
        {
            //내가 들고만 있으면 무조건 내야 되는 경우
            //시작, 싱글, 페어, 트리플
            switch (eCardType)
            {
            case DRAWCARD_TYPE.NONE:
            case DRAWCARD_TYPE.SINGLE:
            {
                if (HaveWishCard(wishStr))
                {
                    return(true);
                }

                return(false);
            }

            case DRAWCARD_TYPE.PAIR:
            {
                int wishCardCount = 0;

                //wish랑 같은 카드가 2장 이상이다 그럼 낼수 있다.
                for (int i = 0; i < m_myCard.Count; ++i)
                {
                    if (m_myCard[i].valueStr == wishStr)
                    {
                        ++wishCardCount;

                        if (wishCardCount >= 2)
                        {
                            return(true);
                        }
                    }
                }

                return(false);
            }

            case DRAWCARD_TYPE.TRIPPLE:
            {
                int wishCardCount = 0;

                //wish랑 같은 카드가 3장 이상이다 그럼 낼수 있다.
                for (int i = 0; i < m_myCard.Count; ++i)
                {
                    if (m_myCard[i].valueStr == wishStr)
                    {
                        ++wishCardCount;

                        if (wishCardCount >= 2)
                        {
                            return(true);
                        }
                    }
                }

                return(false);
            }
            }
        }

        //위시랑 top이랑 상관없이 조합을 비교해야 되는 경우
        //연속 페어, 스트레이트, 풀하우스,
        switch (eCardType)
        {
        case DRAWCARD_TYPE.FULLHOUSE:
        {
            //위시 카드로 트리플이나 페어가 있는지 확인하고
            //트리플이 top보다 높은지 확인을 해야 된다.
            if (topValue > wishCardValue)
            {
                //탑이 위시보다 높은 경우
                //위시는 트리플이 아니고 페어로 들고 있어야 되며
                //트리플이 탑보다 높아야 된다.
                int wishCardCount = 0;

                for (int i = 0; i < m_myCard.Count; ++i)
                {
                    if (m_myCard[i].valueStr == wishStr)
                    {
                        ++wishCardCount;

                        if (wishCardCount >= 2)
                        {
                            break;
                        }
                    }
                }

                if (wishCardCount < 2)
                {
                    return(false);
                }
                else
                {
                    //트리플을 찾아보자 트리플을 찾아도 top벨류보다 커야 된다.
                    for (int i = 0; i < m_myCard.Count - 2; ++i)
                    {
                        if (m_myCard[i].value == m_myCard[i + 1].value &&
                            m_myCard[i + 1].value == m_myCard[i + 2].value)
                        {
                            if (topValue < m_myCard[i].value)
                            {
                                return(true);
                            }
                        }
                    }

                    return(false);
                }
            }
            else
            {
                //위시로 트리플이나 페어가 있는지 확인한다.
                int wishCardCount = 0;

                for (int i = 0; i < m_myCard.Count; ++i)
                {
                    if (m_myCard[i].valueStr == wishStr)
                    {
                        ++wishCardCount;

                        if (wishCardCount >= 3)
                        {
                            break;
                        }
                    }
                }

                if (wishCardCount == 3)
                {
                    //위시카드로 트리플이 있다. 페어가 있는지 찾자
                    for (int i = 0; i < m_myCard.Count - 1; ++i)
                    {
                        if (m_myCard[i].value == m_myCard[i + 1].value)
                        {
                            if (m_myCard[i].valueStr != wishStr)
                            {
                                return(true);
                            }
                        }
                    }
                }
                else if (wishCardCount == 2)
                {
                    //위시로 페어가 있다. 트리플이 있는지 찾아보자.
                    //트리플을 찾아보자 트리플을 찾아도 top벨류보다 커야 된다.
                    for (int i = 0; i < m_myCard.Count - 2; ++i)
                    {
                        if (m_myCard[i].value == m_myCard[i + 1].value &&
                            m_myCard[i + 1].value == m_myCard[i + 2].value)
                        {
                            if (topValue < m_myCard[i].value)
                            {
                                return(true);
                            }
                        }
                    }
                }

                return(false);
            }
        }

        case DRAWCARD_TYPE.STRIGHT:
        {
            int        straightCount = 0;
            List <int> idxList       = new List <int>();

            //스트레이트를 찾아보자.
            for (int i = 0; i < m_myCard.Count - cardCount; ++i)
            {
                straightCount = 1;
                idxList.Clear();
                idxList.Add(i);

                for (int j = i + 1; j < m_myCard.Count; ++j)
                {
                    if (m_myCard[i].value + straightCount - 1 == m_myCard[j].value)
                    {
                        continue;
                    }

                    if (m_myCard[i].value + straightCount == m_myCard[j].value)
                    {
                        ++straightCount;

                        if (straightCount == cardCount)
                        {
                            bool wishOk = false;
                            //스트레이트를 찾았는데 위시가 있는지 보자.
                            for (int k = 0; k < idxList.Count; ++k)
                            {
                                //위시가 있는 스트레이트다
                                if (m_myCard[idxList[k]].valueStr == wishStr)
                                {
                                    wishOk = true;
                                }
                            }

                            //top보다 크면 낼수 있다.
                            if (wishOk && m_myCard[j].value > topValue)
                            {
                                return(true);
                            }
                        }
                    }
                }
            }

            //볼짱 다 봤는데도 리턴이 안된경우면 없다고 판단
            return(false);
        }

        case DRAWCARD_TYPE.PAIRS:
        {
            //이건 버그 해결되면 찾아보자.
            return(true);
        }
        }

        return(false);
    }
Пример #6
0
    public void SetDrawCardType()
    {
        m_eDrawCardType = DRAWCARD_TYPE.NONE;

        CardData phoenixCard = m_selectedCard.Find(item => item.type == CARD_TYPE.PHOENIX);

        if (m_selectedCard.Count == 1)
        {
            m_eDrawCardType = DRAWCARD_TYPE.SINGLE;

            if (m_bHavePhoenix)
            {
                float topValue = CardDrawHandler.Instance.GetTopValue();

                if (topValue != 25)
                {
                    m_topValue = topValue + 0.5f;
                }
                else
                {
                    m_eDrawCardType = DRAWCARD_TYPE.NONE;
                }
            }
        }
        else if (m_selectedCard.Count == 2)
        {
            if (m_selectedCard[0].value == m_selectedCard[1].value)
            {
                m_eDrawCardType = DRAWCARD_TYPE.PAIR;
            }

            if (m_selectedCard[0].type == CARD_TYPE.PHOENIX)
            {
                m_eDrawCardType         = DRAWCARD_TYPE.PAIR;
                m_selectedCard[0].value = m_selectedCard[1].value;
            }
            else if (m_selectedCard[1].type == CARD_TYPE.PHOENIX)
            {
                m_eDrawCardType         = DRAWCARD_TYPE.PAIR;
                m_selectedCard[1].value = m_selectedCard[0].value;
            }
        }
        else if (m_selectedCard.Count == 3)
        {
            float num  = m_selectedCard[0].value;
            float num2 = m_selectedCard[1].value;
            float num3 = m_selectedCard[2].value;

            if (num == num2 && num2 == num3)
            {
                m_eDrawCardType = DRAWCARD_TYPE.TRIPPLE;
            }

            if (m_bHavePhoenix)
            {
                //페어 검사를 하자.
                for (int i = 0; i < m_selectedCard.Count - 1; ++i)
                {
                    for (int j = i + 1; j < m_selectedCard.Count; ++j)
                    {
                        if (m_selectedCard[i] == m_selectedCard[j])
                        {
                            m_phoenixValue = m_selectedCard[i].value;

                            m_eDrawCardType = DRAWCARD_TYPE.TRIPPLE;
                        }
                    }
                }
            }
        }
        else if (m_selectedCard.Count == 4)
        {
            //4장인 경우 연속 페어와 폭탄이 있다
            //폭탄부터 검사를 하자
            float num    = m_selectedCard[0].value;
            bool  isBomb = true;

            for (int i = 1; i < m_selectedCard.Count && isBomb; ++i)
            {
                if (num != m_selectedCard[i].value)
                {
                    isBomb = false;
                }
            }

            if (isBomb)
            {
                m_eDrawCardType = DRAWCARD_TYPE.BOMB;
            }
            else
            {
                bool isPairs = true;
                int  count   = m_selectedCard.Count / 2;
                int  idx     = 0;

                {
                    //일단 정렬
                    m_selectedCard.Sort(delegate(CardData a, CardData b) { return(a.value.CompareTo(b.value)); });

                    if (m_bHavePhoenix)
                    {
                        List <PairList> pairLists = new List <PairList>();

                        for (int i = 0; i < m_selectedCard.Count - 1; ++i)
                        {
                            if (m_selectedCard[i].value == m_selectedCard[i + 1].value)
                            {
                                PairList pair = new PairList();

                                pair.cardIdx1  = i;
                                pair.cardIdx2  = i + 1;
                                pair.pairValue = m_selectedCard[i].value;
                                pairLists.Add(pair);
                                ++i;
                            }
                            else
                            {
                                if (m_selectedCard[i] == phoenixCard)
                                {
                                    m_phoenixValue = m_selectedCard[i + 1].value;
                                }
                                else if (m_selectedCard[i + 1] == phoenixCard)
                                {
                                    m_phoenixValue = m_selectedCard[i].value;
                                }
                            }
                        }

                        if (pairLists.Count >= count - 1)
                        {
                            m_eDrawCardType = DRAWCARD_TYPE.PAIRS;
                            return;
                        }
                    }
                    else
                    {
                        if (m_selectedCard.Count % 2 != 0)
                        {
                            isPairs = false;
                        }

                        float num1 = m_selectedCard[0].value;

                        do
                        {
                            if (m_selectedCard[(idx * 2)].value == m_selectedCard[(idx * 2) + 1].value)
                            {
                                num1 = m_selectedCard[idx * 2].value;
                            }
                            else
                            {
                                isPairs = false;
                            }

                            if (isPairs)
                            {
                                ++idx;

                                if (idx < count && num1 + 1 != m_selectedCard[idx * 2].value)
                                {
                                    isPairs = false;
                                }
                            }
                        }while (isPairs && idx < count);
                    }
                }

                if (isPairs && idx == count)
                {
                    m_eDrawCardType = DRAWCARD_TYPE.PAIRS;
                }
            }
        }
        else if (m_selectedCard.Count == 5)
        {
            //5장인 경우는 스트레이트 폭탄
            //풀하우스
            //스트레이트

            //풀 하우스부터 체크를 해보자
            //일단 정렬
            m_selectedCard.Sort(delegate(CardData a, CardData b) { return(a.value.CompareTo(b.value)); });
            bool isFullHouse = true;

            {
                if (m_bHavePhoenix)
                {
                    int count = 0;

                    for (int i = 0; i < m_selectedCard.Count - 1; ++i)
                    {
                        for (int j = i + 1; j < m_selectedCard.Count; ++j)
                        {
                            if (m_selectedCard[i].value != m_selectedCard[j].value)
                            {
                                if (m_selectedCard[j].type != CARD_TYPE.PHOENIX)
                                {
                                    i = j;
                                    ++count;

                                    if (count >= 2)
                                    {
                                        //서로 다른숫자가 2개가 넘는다? 에러!
                                        isFullHouse = false;
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    //풀하우스인 경우는 2 / 3 혹은 3 / 2인 경우 말곤 없다.
                    //숫자순으로 정렬하면 첫장과 마지막장은 무조건 다르다.
                    float num1 = m_selectedCard[0].value;
                    float num2 = m_selectedCard[4].value;
                    int   count1, count2;
                    count1 = count2 = 0;

                    for (int i = 0; i < m_selectedCard.Count && isFullHouse; ++i)
                    {
                        if (num1 == m_selectedCard[i].value)
                        {
                            ++count1;
                        }
                        if (num2 == m_selectedCard[i].value)
                        {
                            ++count2;
                        }

                        if (count1 + count2 != i + 1)
                        {
                            isFullHouse = false;
                        }
                    }
                }
            }

            if (isFullHouse)
            {
                m_eDrawCardType = DRAWCARD_TYPE.FULLHOUSE;
            }
            else
            {
                if (m_bHavePhoenix)
                {
                    float num1       = m_selectedCard[0].value;
                    bool  isStright  = true;
                    bool  usePhoenix = m_bHavePhoenix;
                    int   searchCard = 1;
                    int   cardCount  = 1;

                    while (isStright && cardCount < m_selectedCard.Count)
                    {
                        if (m_selectedCard[searchCard].type == CARD_TYPE.NONE && num1 + 1 == m_selectedCard[searchCard].value)
                        {
                            num1 = m_selectedCard[searchCard].value;
                            ++searchCard;
                        }
                        else if (usePhoenix)
                        {
                            usePhoenix     = false;
                            num1           = num1 + 1;
                            m_phoenixValue = num1;
                        }
                        else
                        {
                            isStright = false;
                        }

                        ++cardCount;
                    }

                    if (isStright)
                    {
                        m_eDrawCardType = DRAWCARD_TYPE.STRIGHT;
                    }
                }
                else
                {
                    bool isBomb    = true;
                    bool isStright = true;

                    float      num1   = m_selectedCard[0].value;
                    CARD_COLOR eColor = m_selectedCard[0].color;

                    for (int i = 1; i < m_selectedCard.Count && isStright; ++i)
                    {
                        if (num1 + 1 == m_selectedCard[i].value)
                        {
                            num1 = m_selectedCard[i].value;

                            if (isBomb && eColor != m_selectedCard[i].color)
                            {
                                isBomb = false;
                            }
                        }
                        else
                        {
                            isStright = false;
                        }
                    }

                    if (isStright)
                    {
                        if (isBomb)
                        {
                            m_eDrawCardType = DRAWCARD_TYPE.STRIGHT_BOMB;
                        }
                        else
                        {
                            m_eDrawCardType = DRAWCARD_TYPE.STRIGHT;
                        }
                    }
                }
            }
        }
        else if (m_selectedCard.Count >= 6)
        {
            //6장 이상인 경우
            //스트레이트, 스트레이트 폭탄, 연속페어가 있다.
            //연속페어부터 검사를 하자.
            bool isPairs = true;
            int  count   = m_selectedCard.Count / 2;
            int  idx     = 0;

            {
                //일단 정렬
                m_selectedCard.Sort(delegate(CardData a, CardData b) { return(a.value.CompareTo(b.value)); });

                if (m_bHavePhoenix)
                {
                    List <PairList> pairLists = new List <PairList>();

                    for (int i = 0; i < m_selectedCard.Count - 1; ++i)
                    {
                        if (m_selectedCard[i].value == m_selectedCard[i + 1].value)
                        {
                            PairList pair = new PairList();

                            pair.cardIdx1  = i;
                            pair.cardIdx2  = i + 1;
                            pair.pairValue = m_selectedCard[i].value;
                            pairLists.Add(pair);
                            ++i;
                        }
                        else
                        {
                            if (m_selectedCard[i] == phoenixCard)
                            {
                                m_phoenixValue = m_selectedCard[i + 1].value;
                            }
                            else if (m_selectedCard[i + 1] == phoenixCard)
                            {
                                m_phoenixValue = m_selectedCard[i].value;
                            }
                        }
                    }

                    if (pairLists.Count >= count - 1)
                    {
                        m_eDrawCardType = DRAWCARD_TYPE.PAIRS;
                        return;
                    }
                }
                else
                {
                    if (m_selectedCard.Count % 2 != 0)
                    {
                        isPairs = false;
                    }

                    float num = m_selectedCard[0].value;

                    do
                    {
                        if (m_selectedCard[(idx * 2)].value == m_selectedCard[(idx * 2) + 1].value)
                        {
                            num = m_selectedCard[idx * 2].value;
                        }
                        else
                        {
                            isPairs = false;
                        }

                        if (isPairs)
                        {
                            ++idx;

                            if (idx < count && num + 1 != m_selectedCard[idx * 2].value)
                            {
                                isPairs = false;
                            }
                        }
                    }while (isPairs && idx < count);
                }
            }

            if (isPairs && idx == count)
            {
                m_eDrawCardType = DRAWCARD_TYPE.PAIRS;
            }
            else
            {
                if (m_bHavePhoenix)
                {
                    bool  isStright  = true;
                    float num1       = m_selectedCard[0].value;
                    bool  usePhoenix = m_bHavePhoenix;
                    int   searchCard = 1;
                    int   cardCount  = 1;

                    while (isStright && cardCount < m_selectedCard.Count)
                    {
                        if (m_selectedCard[searchCard].type == CARD_TYPE.NONE && num1 + 1 == m_selectedCard[searchCard].value)
                        {
                            num1 = m_selectedCard[searchCard].value;
                            ++searchCard;
                        }
                        else if (usePhoenix)
                        {
                            usePhoenix     = false;
                            num1           = num1 + 1;
                            m_phoenixValue = num1;
                        }
                        else
                        {
                            isStright = false;
                        }

                        ++cardCount;
                    }

                    if (isStright)
                    {
                        m_eDrawCardType = DRAWCARD_TYPE.STRIGHT;
                    }
                }
                else
                {
                    bool isBomb    = true;
                    bool isStright = true;

                    float      num1   = m_selectedCard[0].value;
                    CARD_COLOR eColor = m_selectedCard[0].color;

                    for (int i = 1; i < m_selectedCard.Count && isStright; ++i)
                    {
                        if (num1 + 1 == m_selectedCard[i].value)
                        {
                            num1 = m_selectedCard[i].value;

                            if (isBomb && eColor != m_selectedCard[i].color)
                            {
                                isBomb = false;
                            }
                        }
                        else
                        {
                            isStright = false;
                        }
                    }

                    if (isStright)
                    {
                        if (isBomb)
                        {
                            m_eDrawCardType = DRAWCARD_TYPE.STRIGHT_BOMB;
                        }
                        else
                        {
                            m_eDrawCardType = DRAWCARD_TYPE.STRIGHT;
                        }
                    }
                }
            }
        }
    }