Ejemplo n.º 1
0
        //------------------------------------------------------------------------------------
        /// <summary>
        /// Remove cards from the hand, except for the number of cards you specify.  The
        /// cards will be removed last in, first out order
        /// </summary>
        //------------------------------------------------------------------------------------
        internal void ClearAllBut(int keep)
        {
            var pocketCards = DealtCards.Take(keep);

            DealtCards.Clear();

            _suitBits   = new int[4];
            _suitCounts = new int[4];
            _rankBits   = 0;
            _evaluated  = false;
            CardBits    = 0;
            foreach (var card in pocketCards)
            {
                AddCard(card);
            }
        }
        //Deals out the cards
        private void DealStack()
        {
            //overflow goes to separeate pile
            DealtCards.ToList().ForEach(c => c.FaceUp = false);
            _wasteStack.AddRange(DealtCards);
            DealtCards.Clear();

            if (_cards.Count == 0)
            {
                CardsEmpty = true;

                // Resets
                _wasteStack.Reverse();
                _cards.AddRange(_wasteStack);
                _wasteStack.Clear();

                // Top card changes
                TopCard = _cards.Count > 0 ? _cards[_cards.Count - 1] : null;

                return;
            }
            if (CardsEmpty)
            {
                CardsEmpty = false;
            }

            int numToDeal = Math.Min(_cards.Count, NumCardsPerDeal);
            int index     = _cards.Count - numToDeal;

            // cycles through cards
            var deal = _cards.GetRange(index, numToDeal);

            deal.Reverse();
            DealtCards.AddRange(deal);
            _cards.RemoveRange(index, numToDeal);
            DealtCards.ToList().ForEach(c => c.FaceUp = true);

            // Top card changes
            TopCard = _cards.Count > 0 ? _cards[_cards.Count - 1] : null;
        }