Example #1
0
        /// <summary>
        /// Gets a standard 52-card stack that has been shuffled.
        /// </summary>
        /// <returns>The shuffled standard deck.</returns>
        /// <param name="orientation">The orientation for the new stack</param>
        public static CardStack GetShuffledStandardDeck(
            CardStackOrientation orientation)
        {
            CardStack stack = CardStack.GetSortedStandardDeck(orientation);

            stack.Shuffle();
            return(stack);
        }
Example #2
0
        /// <summary>
        /// Gets a standard 52-card stack, sorted by suit, then by rank.
        /// </summary>
        /// <returns>The sorted standard deck.</returns>
        /// <param name="orientation">The orientation for the new stack</param>
        public static CardStack GetSortedStandardDeck(
            CardStackOrientation orientation)
        {
            CardStack stack = new CardStack(orientation);

            foreach (CardSuit s in Enum.GetValues(typeof(CardSuit)))
            {
                foreach (CardRank v in Enum.GetValues(typeof(CardRank)))
                {
                    stack._cards.Add(new Card(s, v));
                }
            }

            return(stack);
        }
Example #3
0
        /// <summary>
        /// Creates a new card stack in the specified orientation from the
        /// supplied list. The first card in the list will be the "top" card in
        /// the new CardStack.
        /// </summary>
        /// <returns>A new card stack from the provided list.</returns>
        /// <param name="cards">The cards to create the stack from</param>
        /// <param name="orientation">
        ///     The orientation of the new card stack
        /// </param>
        public static CardStack FromList(
            List <Card> cards, CardStackOrientation orientation)
        {
            CardStack stack = CardStack.GetEmptyStack(orientation);

            //we'll temporarily flip the stack so that we can add the cards
            // in the correct order
            stack.Flip();

            //add the cards
            foreach (Card card in cards)
            {
                stack.AddCard(card);
            }

            //flip it back and return it
            stack.Flip();

            return(stack);
        }
Example #4
0
 /// <summary>
 /// Returns a new empty card stack with the specified orientation.
 /// </summary>
 /// <returns>The empty stack.</returns>
 /// <param name="orientation">The orientation for the new stack</param>
 public static CardStack GetEmptyStack(CardStackOrientation orientation)
 {
     return(new CardStack(orientation));
 }
Example #5
0
 /// <summary>
 /// Flips the orientation of the stack.
 /// </summary>
 public void Flip()
 {
     Orientation = (Orientation == CardStackOrientation.FaceDown) ?
                   CardStackOrientation.FaceUp : CardStackOrientation.FaceDown;
 }
Example #6
0
 /// <summary>
 /// Initializes an empty card stack with default (face down)
 /// orientation.
 /// </summary>
 private CardStack(CardStackOrientation orientation)
 {
     Orientation = orientation;
 }