private void EnsureDeckHaveCards(int numCards) { if (Deck.Count < numCards + 2) { //we need to shuffle List <int> cards = new List <int>(); while (Deck.Count > 0) { cards.Add(Deck.Dequeue()); } while (Discard.Count > 0) { cards.Add(Discard.Dequeue()); } while (cards.Count > 0) { int id = Random.Next(0, cards.Count); int card = cards[id]; cards.RemoveAt(id); Deck.Enqueue(card); } } }