Exemplo n.º 1
0
        public static void DealCard(int userCount, out List <List <PokerCard> > allUserCards, out List <PokerCard> bottomCards)
        {
            allUserCards = new List <List <PokerCard> >();
            bottomCards  = new List <PokerCard>();
            Random           ra        = new Random();
            List <PokerCard> tempCards = new List <PokerCard>(CardsCount);

            for (int userIndex = 0; userIndex < userCount; ++userIndex)
            {
                List <PokerCard> oneUserCards = new List <PokerCard>();
                for (int icard = 0; icard < UserCardsCount; ++icard)
                {
                    int       randIndex = ra.Next(0, _cards.Count - 1);
                    PokerCard card      = _cards[randIndex];
                    card.Status = CardStatus.CardInHand;
                    if (card.IsSpecialCard())
                    {
                        card.Status |= CardStatus.CardSpecialPoint;
                    }

                    oneUserCards.Add(card);
                    tempCards.Add(card);
                    _cards.RemoveAt(randIndex);
                }
                allUserCards.Add(oneUserCards);
            }
            int leftCount = _cards.Count;

            for (int i = 0; i < leftCount; ++i)
            {
                int       randIndex = ra.Next(0, _cards.Count - 1);
                PokerCard card      = _cards[randIndex];
                card.Status = CardStatus.CardInBottom;
                if (card.IsSpecialCard())
                {
                    card.Status |= CardStatus.CardSpecialPoint;
                }
                bottomCards.Add(card);
                tempCards.Add(card);
                _cards.RemoveAt(randIndex);
            }
            _cards = tempCards;
        }