Esempio n. 1
0
        List <int> GetPokerNum(List <byte> cards)
        {
            List <int> num = new List <int>();

            for (int i = 0; i < cards.Count; i++)
            {
                num.Add(PokerCardsHelper.GetPokerNum(cards[i]));
            }
            return(num);
        }
Esempio n. 2
0
        public List <byte> QuickSort(List <byte> card)
        {
            if (card.Count == 0)
            {
                return(card);
            }
            card = PokerCardsHelper.QuickSort(card.ToArray(), 0, card.Count - 1, true).ToList();
            card = HaveTwoQuickSort(card);

            return(card);
        }
Esempio n. 3
0
        public void DealCards()
        {
            ResetCurrentCards();

            for (int i = 0; i < 3; i++)
            {
                byte card = new byte();
                for (int j = 0; j < 17; j++)
                {
                    card = PokerCardsHelper.TackOneCard(CurrentPokers, true);
                    if (i == 0)
                    {
                        player1Pokers.Add(card);
                    }
                    else if (i == 1)
                    {
                        player2Pokers.Add(card);
                    }
                    else if (i == 2)
                    {
                        player3Pokers.Add(card);
                    }

                    CurrentPokers.Remove(card);
                }
                card = PokerCardsHelper.TackOneCard(CurrentPokers, true);
                dpPokers.Add(card);
                CurrentPokers.Remove(card);
            }

            for (int i = 0; i < 4; i++)
            {
                if (i == 0)
                {
                    dpPokers = QuickSort(dpPokers);
                }
                else if (i == 1)
                {
                    player1Pokers = QuickSort(player1Pokers);
                }
                else if (i == 2)
                {
                    player2Pokers = QuickSort(player2Pokers);
                }
                else if (i == 3)
                {
                    player3Pokers = QuickSort(player3Pokers);
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 设置扑克牌
        /// </summary>
        /// <param name="poker"></param>
        public void SetPokerImageSprite(byte pokerId, bool isDiZhu = false)
        {
            this.Panel.SetActive(true);

            this.pokerId = pokerId;

            this.isDiZhu = isDiZhu;

            this.pokerInt = PokerCardsHelper.GetPokerOfInt(pokerId);

            this.pokerValue = DDZGameHelper.GetPokerNum(pokerId);

            _poker.sprite = SpriteHelper.GetPokerSprite(PokerCardsHelper.GetPokerOfInt(pokerId));

            this._dizhu.SetActive(isDiZhu);
        }
Esempio n. 5
0
        public DDZCard ChaiFen(List <byte> pokers)
        {
            DDZCard card = new DDZCard();

            if (pokers == null)
            {
                return(card);
            }

            for (int i = 0; i < pokers.Count; i++)
            {
                var num = PokerCardsHelper.GetPokerNum(pokers[i]);
                card.Points = num.ToString() + "点";
                card.Value  = num;
            }
            card.Card = (ByteString.CopyFrom(pokers.ToArray()));

            return(card);
        }
Esempio n. 6
0
        /// <summary>
        /// 获取斗地主真实的牌值
        /// </summary>
        /// <param name="iPoker"></param>
        /// <returns></returns>
        public static int GetPokerNum(byte iPoker)
        {
            //A 14 //2是2
            byte Num = PokerCardsHelper.GetPokerNum(iPoker);

            if (Num == 2)
            {
                return(15);
            }

            if (Num == 15)
            {
                return(16);
            }
            ;

            if (Num == 16)
            {
                return(17);
            }
            ;

            return(Num);
        }
Esempio n. 7
0
        public DDZInteractivePlugin Awake(GameObject panel)
        {
            this.panel = panel;

            _rf = this.panel.GetComponent <ReferenceCollector>();

            Clock = _rf.Get <GameObject>("Clock");

            Num = _rf.Get <GameObject>("Num").GetComponent <Text>();

            TipBtn = _rf.Get <GameObject>("TipBtn").GetComponent <Button>();

            Clock.SetActive(false);

            clockComponent = AddComponent <DDZClockComponent>().Awake(Num.gameObject);

            ButtonHelper.RegisterButtonEvent(_rf, "NotOutBtn", () =>
            {
                Game.PopupComponent.SetClickLock();

                SoundComponent.Instance.PlayClip(DataCenterComponent.Instance.soundInfo.click);

                DDZConfig.GameScene.RequestPlayCard(1, new DDZCard());
            });

            ButtonHelper.RegisterButtonEvent(_rf, "ReSetBtn", () =>
            {
                SoundComponent.Instance.PlayClip(DataCenterComponent.Instance.soundInfo.click);

                DDZConfig.GameScene.DDZHandCardPlugin.ReSelect();
            });

            ButtonHelper.RegisterButtonEvent(_rf, "TipBtn", () =>
            {
                Game.PopupComponent.SetClickLock();

                SoundComponent.Instance.PlayClip(DataCenterComponent.Instance.soundInfo.click);

                DDZConfig.GameScene.DDZHandCardPlugin.ReSelect();

                var tipCardDic = DDZConfig.GameScene.DDZAIComponent.GetTipCards();

                if (tipCardDic != null && tipCardDic.Count > 0)
                {
                    Log.Debug("获得的提示长度是:" + tipCardDic.Count);

                    if (tipCardIndex == -1)
                    {
                        tipCardIndex = 0;
                    }

                    if (tipCardIndex > tipCardDic.Count - 1)
                    {
                        tipCardIndex = 0;
                    }

                    List <int> tipCards = tipCardDic[tipCardIndex];

                    DDZConfig.GameScene.DDZHandCardPlugin.SelectTipCard(tipCards);

                    tipCardIndex++;
                }
                else
                {
                    Game.PopupComponent.ShowTips(DataCenterComponent.Instance.tipInfo.NoTipCardsTip);
                }
            });

            ButtonHelper.RegisterButtonEvent(_rf, "OutBtn", () =>
            {
                Game.PopupComponent.SetClickLock();

                SoundComponent.Instance.PlayClip(DataCenterComponent.Instance.soundInfo.click);

                DDZCard _data = new DDZCard();

                List <byte> outCardList = DDZConfig.GameScene.DDZHandCardPlugin.GetOutCardList();

                _data.Card = PbHelper.CopyFrom(outCardList);

                foreach (var item in outCardList)
                {
                    Log.Debug("牌值:" + PokerCardsHelper.GetPokerOfInt(item));

                    Log.Debug("中文牌:" + PokerCardsHelper.GetPokerString(item));
                }

                _data.CardsNum = outCardList.Count;

                Log.Debug("出牌的长度:" + _data.CardsNum);

                //增加判断:出牌是否为空
                if (_data.CardsNum <= 0)
                {
                    DDZConfig.GameScene.DDZMaskPlugin.Show(2);
                }
                else
                {
                    DDZConfig.GameScene.RequestPlayCard(0, _data);
                }
            });

            this.Reset();

            return(this);
        }
Esempio n. 8
0
        public bool CompareCards(List <byte> myCards, long userId, List <DDZCompareCard> lastCardsList)
        {
            DDZCompareCard lastCards = new DDZCompareCard(); lastCards.pokers = new List <byte>();

            if (lastCardsList.Count > 0)
            {
                for (int i = lastCardsList.Count - 1; i > -1; i--)
                {
                    if (lastCardsList[i].POKER_TYPE == DDZCardType.DDZ_POKER_TYPE.DDZ_PASS && lastCardsList[i].pokers.Count == 0)
                    {
                        continue;
                    }

                    lastCards.POKER_TYPE = lastCardsList[i].POKER_TYPE; lastCardsList[i].pokers.ForEach(u => lastCards.pokers.Add(u)); lastCards.userId = lastCardsList[i].userId;

                    break;
                }
            }
            DDZCardType.DDZ_POKER_TYPE myCardType = DDZCardType.DDZ_POKER_TYPE.DDZ_PASS;

            bool IsPopEnable = PopEnable(myCards, out myCardType);

            if (!IsPopEnable)
            {
                return(false);
            }

            if (lastCards.pokers.Count == 0 && lastCards.POKER_TYPE == DDZCardType.DDZ_POKER_TYPE.DDZ_PASS)
            {
                if (myCardType == DDZCardType.DDZ_POKER_TYPE.KING_BOMB || myCardType == DDZCardType.DDZ_POKER_TYPE.FOUR_BOMB)
                {
                    bombNum++;
                }

                ChangeCard(myCards, userId, myCardType);
                return(true);
            }
            else
            {
                if (lastCards.POKER_TYPE == DDZCardType.DDZ_POKER_TYPE.KING_BOMB)
                {
                    return(false);
                }
                else if (myCardType == DDZCardType.DDZ_POKER_TYPE.KING_BOMB)
                {
                    bombNum++;
                    ChangeCard(myCards, userId, myCardType);
                    return(true);
                }
                if (lastCards.POKER_TYPE != DDZCardType.DDZ_POKER_TYPE.FOUR_BOMB && myCardType == DDZCardType.DDZ_POKER_TYPE.FOUR_BOMB)
                {
                    bombNum++;
                    ChangeCard(myCards, userId, myCardType);
                    return(true);
                }

                if (myCards.Count != lastCards.pokers.Count)
                {
                    return(false);
                }

                if (myCardType != lastCards.POKER_TYPE)
                {
                    return(false);
                }

                var pokerNum0 = PokerCardsHelper.GetPokerNum(lastCards.pokers[0]);
                var pokerNum1 = PokerCardsHelper.GetPokerNum(myCards[0]);

                if (pokerNum1 == 2 && pokerNum0 <= 14 && pokerNum0 != 2)
                {
                    if (myCardType == DDZCardType.DDZ_POKER_TYPE.FOUR_BOMB)
                    {
                        bombNum++;
                    }
                    ChangeCard(myCards, userId, myCardType);
                    return(true);
                }
                else if (pokerNum0 == 2 && pokerNum1 <= 14)
                {
                    return(false);
                }
                if (pokerNum1 > pokerNum0)
                {
                    if (myCardType == DDZCardType.DDZ_POKER_TYPE.FOUR_BOMB)
                    {
                        bombNum++;
                    }
                    ChangeCard(myCards, userId, myCardType);
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 9
0
        public List <byte> PaiXingPaiXu(List <byte> cards)
        {
            List <int> num = new List <int>();

            cards = PokerCardsHelper.QuickSort(cards.ToArray(), 0, cards.Count - 1).ToList();
            num   = GetPokerNum(cards);
            switch (cards.Count)
            {
            case 4:
                if (num[1] == num[2] && num[2] == num[3])
                {
                    cards.Add(cards[0]); cards.RemoveAt(0);
                }
                break;

            case 5:
                if (num[0] == num[1] && num[1] != num[2] && num[2] == num[3] && num[3] == num[4])
                {
                    cards.Add(cards[0]); cards.Add(cards[1]);
                    cards = RemoveAtFirst(2, cards);
                }
                break;

            case 6:
                if (num[2] == num[3] && num[3] == num[4] && num[4] == num[5])
                {
                    cards.Add(cards[0]); cards.Add(cards[1]);

                    cards = RemoveAtFirst(2, cards);
                }
                else if (num[1] == num[2] && num[2] == num[3] && num[3] == num[4])
                {
                    cards.Add(cards[0]); cards.RemoveAt(0);
                }
                break;

            case 8:
                if (num[1] != num[2] && num[2] == num[3] && num[3] == num[4] && num[4] + 1 == num[5] && num[5] == num[6] && num[6] == num[7])
                {
                    cards.Add(cards[0]); cards.Add(cards[1]);

                    cards = RemoveAtFirst(2, cards);
                }

                else if (num[0] != num[1] && num[1] == num[2] && num[2] == num[3] && num[3] + 1 == num[4] && num[4] == num[5] && num[5] == num[6])
                {
                    cards.Add(cards[0]); cards.RemoveAt(0);
                }
                else if (num[0] == num[1] && num[1] != num[2] && num[2] == num[3] && num[3] == num[4] && num[4] == num[5] && num[5] != num[6] && num[6] == num[7])
                {
                    cards.Add(cards[0]); cards.Add(cards[1]);
                    cards = RemoveAtFirst(2, cards);
                }
                else if (num[0] == num[1] && num[1] != num[2] && num[2] == num[3] && num[3] != num[4] && num[4] == num[5] && num[5] == num[6] && num[6] == num[7])
                {
                    cards.Add(cards[0]); cards.Add(cards[1]); cards.Add(cards[2]); cards.Add(cards[3]);

                    cards = RemoveAtFirst(4, cards);
                }
                break;

            case 10:
                if (num[4] == num[5] && num[5] == num[6] && num[6] + 1 == num[7] && num[7] == num[8] && num[8] == num[9])
                {
                    cards.Add(cards[0]); cards.Add(cards[1]); cards.Add(cards[2]); cards.Add(3);
                    cards = RemoveAtFirst(4, cards);
                }
                break;

            case 12:
                if (num[3] == num[4] && num[4] == num[5] && num[5] + 1 == num[6] && num[6] == num[7] && num[7] == num[8] && num[8] + 1 == num[9] && num[9] == num[10] && num[10] == num[11])
                {
                    cards.Add(cards[0]); cards.Add(cards[1]); cards.Add(cards[2]);
                    cards = RemoveAtFirst(3, cards);
                }
                break;

            case 15:
                if (num[6] == num[7] && num[7] == num[8] && num[8] + 1 == num[9] && num[9] == num[10] && num[10] == num[11] && num[11] + 1 == num[12] && num[12] == num[13] && num[13] == num[14])
                {
                    cards.Add(cards[0]); cards.Add(cards[1]); cards.Add(cards[2]); cards.Add(cards[3]); cards.Add(cards[4]); cards.Add(cards[5]);
                    cards = RemoveAtFirst(6, cards);
                }
                else if (num[4] == num[5] && num[5] == num[6] && num[6] + 1 == num[7] && num[7] == num[8] && num[8] == num[9] && num[9] + 1 == num[10] && num[10] == num[11] && num[11] == num[12])
                {
                    cards.Add(cards[0]); cards.Add(cards[1]); cards.Add(cards[2]); cards.Add(cards[3]);
                    cards = RemoveAtFirst(4, cards);
                }
                else if (num[2] == num[3] && num[3] == num[4] && num[4] + 1 == num[5] && num[5] == num[6] && num[6] == num[7] && num[7] + 1 == num[8] && num[8] == num[9] && num[9] == num[10])
                {
                    cards.Add(cards[0]); cards.Add(cards[1]);
                    cards = RemoveAtFirst(2, cards);
                }
                break;

            case 16:
                if (num[4] == num[5] && num[5] == num[6] && num[6] + 1 == num[7] && num[7] == num[8] && num[8] == num[9] && num[9] + 1 == num[10] && num[10] == num[11] && num[11] == num[12] && num[12] + 1 == num[13] && num[13] == num[14] && num[14] == num[15])
                {
                    cards.Add(cards[0]); cards.Add(cards[1]); cards.Add(cards[2]); cards.Add(cards[3]);
                    cards = RemoveAtFirst(4, cards);
                }
                else if (num[3] == num[4] && num[4] == num[5] && num[5] + 1 == num[6] && num[6] == num[7] && num[7] == num[8] && num[8] + 1 == num[9] && num[9] == num[10] && num[10] == num[11] && num[11] + 1 == num[12] && num[12] == num[13] && num[13] == num[14])
                {
                    cards.Add(cards[0]); cards.Add(cards[1]); cards.Add(cards[2]);
                    cards = RemoveAtFirst(3, cards);
                }
                else if (num[2] == num[3] && num[3] == num[4] && num[4] + 1 == num[5] && num[5] == num[6] && num[6] == num[7] && num[7] + 1 == num[8] && num[8] == num[9] && num[9] == num[10] && num[10] + 1 == num[11] && num[11] == num[12] && num[12] == num[13])
                {
                    cards.Add(cards[0]); cards.Add(cards[1]);
                    cards = RemoveAtFirst(2, cards);
                }
                else if (num[1] == num[2] && num[2] == num[3] && num[3] + 1 == num[4] && num[4] == num[5] && num[5] == num[6] && num[6] + 1 == num[7] && num[7] == num[8] && num[8] == num[9] && num[9] + 1 == num[10] && num[10] == num[11] && num[11] == num[12])
                {
                    cards.Add(cards[0]);
                    cards.RemoveAt(0);
                }
                break;


            default:
                break;
            }


            return(cards);
        }