void InitCards()
 {
     for (int i = 0; i < Enum.GetNames(typeof(CardSuit)).Length; i++)
     {
         for (int j = 1; j <= CARDCOUNT; j++)
         {
             PlayingCard card = new PlayingCard();
             card.suit = (CardSuit)i;
             card.rank = j;
             allPlayingCards.Add(card);
         }
     }
 }
        public void Shuffle()
        {
            // Fisher Yates Shuffle
            Random rnd = new Random();

            for (int n = allPlayingCards.Count - 1; n > 0; --n)
            {
                int         k    = rnd.Next(n + 1);
                PlayingCard temp = allPlayingCards[n];
                allPlayingCards[n] = allPlayingCards[k];
                allPlayingCards[k] = temp;
            }
        }
        private List <PlayingCard> InitCards()
        {
            List <PlayingCard> temporary = new List <PlayingCard>();

            CardSuit[] suits = { CardSuit.Clubs, CardSuit.Diamonds, CardSuit.Hearts, CardSuit.Spades };
            int[]      cards = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 };

            for (int i = 0; i < suits.Length; i++)
            {
                for (int o = 0; o < cards.Length; o++)
                {
                    PlayingCard temp = new PlayingCard(cards[o], suits[i]);
                    temporary.Add(temp);
                }
            }

            return(temporary);
        }
Exemple #4
0
 public void AddCard(PlayingCard card)
 {
     cards.Add(card);
 }