예제 #1
0
        public void BuildDeckOfXPoints(ICardData cards, IDeck deck, int points)
        {
            List<Card> avail = cards.Cards.ToList();

            while (points > 0)
            {
                var canChoose = avail.Where(c => c.Points <= points).ToList();

                if (canChoose.Count == 0)
                    return;

                int index = _randomNumberGenerator.Next(0, canChoose.Count);

                avail.Remove(canChoose[index]).Should().Be(true);

                deck.AddCard(canChoose[index]);

                points -= canChoose[index].Points;
            }
        }