private static void PopulateCardListToCount(int targetCount, List<Card> list, UniqueCardPicker cardPicker, Func<Dominion.Card, bool> meetConstraint) { while (list.Count < targetCount) { Dominion.Card currentCard = cardPicker.GetCard(meetConstraint); if (currentCard == null) break; list.Add(currentCard); } }