/// <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; } } } }
public void DrawCard(CardPile pile) { // Can't draw cards if we're not the active player if (!activePlayer) { return; } // Can't draw a card if we have one floating if (currentCard != null) { return; } // Check if pile has cards if (pile.GetCardCount() <= 0) { // Check if we can dump the graveyard back in the deck if (GameMng.GetRules().infiniteDeck) { var cards = graveyard.GetCards(); graveyard.Clear(); if (GameMng.GetRules().reshuffleInfinite) { ShuffleDeck(cards); } pile.Add(cards); if (pile.GetCardCount() <= 0) { return; } } else { return; } } // Check if we can draw cards (cards in hand is less than maximum allowed) if (hand.GetCardCount() >= GameMng.GetRules().maxCardsInHand) { return; } // Check if we've already drawn enough cards this turn if (drawCount >= GameMng.GetRules().drawPerTurn) { return; } drawCount++; // Get the first card CardDesc card = pile.GetFirstCard(); // Create the card itself and pop it on the hand var cardObject = GameMng.CreateCard(card); hand.Add(cardObject); }