/// <summary> /// Replaces the returnedCards passed in either back into the deck or the discard pile depending on the ReplaceType used. /// </summary> /// <param name="type">The replace type to use.</param> /// <param name="returnedCards">The array of Cards being returned.</param> public void ReplaceCards(eReplaceType type, T[] returnedCards) { int length; T[] tempDeck; switch (type) { case eReplaceType.Discard: length = DiscardPile.Length + returnedCards.Length; tempDeck = new T[length]; int discardLength = DiscardPile.Length; for (int i = 0; i < discardLength; i++) { tempDeck[i] = DiscardPile[i]; } for (int i = discardLength; i < length; i++) { tempDeck[i] = returnedCards[i - discardLength]; } DiscardPile = tempDeck; break; case eReplaceType.Top: length = DeckCards.Length + returnedCards.Length; tempDeck = new T[length]; int returnedLength = returnedCards.Length; for (int i = 0; i < returnedLength; i++) { tempDeck[i] = returnedCards[i]; } for (int i = returnedLength; i < length; i++) { tempDeck[i] = DeckCards[i - returnedLength]; } DeckCards = tempDeck; break; case eReplaceType.Bottom: length = DeckCards.Length + returnedCards.Length; tempDeck = new T[length]; int deckLength = DeckCards.Length; for (int i = 0; i < deckLength; i++) { tempDeck[i] = DeckCards[i]; } for (int i = deckLength; i < length; i++) { tempDeck[i] = returnedCards[i - deckLength]; } DeckCards = tempDeck; break; case eReplaceType.Shuffle: ReplaceCards(eReplaceType.Top, returnedCards); ShuffleCards(); break; default: break; } }
/// <summary> /// Replaces the discard pile back into the main deck in the manner specified by replaceType. The default is to shuffle them back in. /// </summary> /// <param name="replaceType">The type of replacement to do. Selecting Discard will have no effect.</param> public void ReplaceDiscardPile(eReplaceType replaceType = eReplaceType.Shuffle) { ReplaceCards(replaceType, DiscardPile); DiscardPile = new T[0]; }