/// <summary> /// Shuffles the cards in the main deck. /// </summary> /// <param name="withDiscard">Defaults to false; determines if the discard pile should be placed back into the deck before shuffling.</param> public void ShuffleCards(bool withDiscard = false) { if (withDiscard) { ReplaceDiscardPile(eReplaceType.Top); } List <T> deckList = DeckCards.ToList <T>(); T[] deckArray = new T[DeckCards.Length]; Random rng = new Random(); int size = deckArray.Length; for (int i = 0; i < size; i++) { int index = rng.Next(0, deckList.Count()); T card = deckList.ElementAt(index); deckArray[i] = card; deckList.Remove(card); } }