예제 #1
0
파일: Cards.cs 프로젝트: eagle79/cardgames
        /// <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);
        }