예제 #1
0
        public CardDeck(DeckSize size, bool useJokers)
        {
            _size      = size;
            _useJokers = useJokers;

            _deck = BuildDeck();
            ShuffleDeck(4);
        }
예제 #2
0
        /// <summary>
        /// Creates a deck using the selected deck size.
        /// </summary>
        /// <param name="size"></param>
        private void generateDeck(DeckSize size = DeckSize.FIFTY_TWO)
        {
            // the number of suits in a card deck
            const int NUMBER_SUITS = 4;
            int       lowCard;

            if (size == DeckSize.TWENTY)
            {
                lowCard = (int)TWENTY_LOW_VALUE;   // 10 is the low value in a 20 card deck
            }
            else if (size == DeckSize.THIRTY_SIX)
            {
                lowCard = (int)THIRTY_SIX_LOW_VALUE;    // 6 is the low value in a 36 card deck
            }
            else if (size == DeckSize.FIFTY_TWO)
            {
                lowCard = (int)FIFTY_TWO_LOW_VALUE;    // 2 is the low value in a 52 card deck
            }
            else
            {
                throw new System.ArgumentException("Cannot create a deck of size " + (size.ToString()));
            }

            // clear old deck
            clear();

            // now re-allocate memory
            deck.Capacity = (int)size;

            // set the deck size field
            myDeckSize = size;

            // start with the lowest suit and add all values, than continue
            // doing the same with all other suits.
            for (int i = 0; i < NUMBER_SUITS; ++i)
            {
                for (int j = lowCard; j <= (int)Rank.ACE; ++j)
                {
                    deck.Add(new Card((Suit)i, (Rank)j));
                }
            }
        }
예제 #3
0
		public CardDeck( DeckSize size, bool useJokers )
		{
			_size = size;
			_useJokers = useJokers;

			_deck = BuildDeck();
			ShuffleDeck( 4 );
		}
예제 #4
0
		public CardDeck( DeckSize size ) : this( size, false ) { }
예제 #5
0
 public CardDeck(DeckSize size) : this(size, false)
 {
 }
예제 #6
0
		public GameItem( DeckSize deckSize )
			: base( 0x12AB )
		{
			_deck = new CardDeck( deckSize );
		}
예제 #7
0
 /// <summary>
 /// Constructs a deck based on the selected deck size.
 /// </summary>
 /// <param name="size"></param>
 public Deck(DeckSize size = DeckSize.FIFTY_TWO)
 {
     deck = new List <Card>();
     generateDeck(size);
 }
예제 #8
0
 public GameItem(DeckSize deckSize)
     : base(0x12AB)
 {
     _deck = new CardDeck(deckSize);
 }