예제 #1
0
        protected internal ICardCollection GenerateCardsFor(ICardCollection cardCollection, int count)
        {
            var availableCardTypes = m_cardTypeDescriptor.GetAvailableCardTypesOf(cardCollection.ContentType);
            var rnd = new Random();

            // shuffle add cards
            for (int i = 0; i < count; i++)
            {
                var index = rnd.Next(0, availableCardTypes.Count - 1);
                cardCollection.Add(m_cardObjectFactory.CreateCardObject(availableCardTypes.ElementAt(index)));
            }

            return(cardCollection);
        }
예제 #2
0
        public Deck()
        {
            _cards = new CardCollection();

            var colors = Enum.GetValues(typeof(CardColor));

            foreach (CardColor c in colors)
            {
                for (var i = MinCardValue; i <= MaxCardValue; i++)
                {
                    _cards.Add(new Card(c, i));
                }
            }

            _cards.Shuffle();
        }
예제 #3
0
 // The default way to handle cards - may be overridden
 public virtual void AcceptCard(ICard card)
 {
     Cards.Add(card);
 }