/// <summary> /// shuffles all piles specified in the List, if the bool is true all shuffled cards will be added to the drawpile, /// otherwise they will remain in their starting pile /// </summary> /// <param name="DeckList">list of all the decks that need to be shuffled</param> /// <param name="returnShuffledCardsToDrawPile"> /// true: cards will be returned to the draw pile after shuffling /// false: cards will remain in their current deck after shuffling /// </param> public void Shuffle(List <DeckType> DeckList, bool returnShuffledCardsToDrawPile) { for (int i = 0; i < DeckList.Count; ++i) { switch (DeckList[i]) { case DeckType.All: { //recursively shuffle all the piles Shuffle(new List <DeckType>() { DeckType.DrawPile }, returnShuffledCardsToDrawPile); Shuffle(new List <DeckType>() { DeckType.DiscardPile }, returnShuffledCardsToDrawPile); Shuffle(new List <DeckType>() { DeckType.ExilePile }, returnShuffledCardsToDrawPile); break; } case DeckType.DrawPile: { //just shuffle the draw pile DrawPile.Shuffle(); break; } case DeckType.DiscardPile: { //if shuffling into the draw pile if (returnShuffledCardsToDrawPile == true) { //get the list of cards List <Card> cardPile = DiscardPile.GetCardList(); //iterate through all the cards for (int j = 0; j < cardPile.Count; ++j) { //add this card to the draw pile DrawPile.AddCard(cardPile[j]); } DrawPile.Shuffle(); cardPile.Clear(); DiscardPile.Clear(); } else { //else just shuffle the discardpile DiscardPile.Shuffle(); } break; } case DeckType.ExilePile: { //if shuffling into the draw pile if (returnShuffledCardsToDrawPile == true) { //get the list of cards List <Card> cardPile = ExilePile.GetCardList(); //iterate through all the cards for (int j = 0; j < cardPile.Count; ++j) { //add this card to the draw pile DrawPile.AddCard(cardPile[j]); } DrawPile.Shuffle(); cardPile.Clear(); ExilePile.Clear(); } else { //else just shuffle the exile pile ExilePile.Shuffle(); } break; } } } }