/// <summary> /// Creates a new deck object of 52 cards with the standard suits and ranks /// </summary> public Deck() { // Instantiate variables used = 0; cards = new Card[52]; // Get the ranks and suits Enums.Suits[] tempSuits = (Enums.Suits[])Enum.GetValues(typeof(Enums.Suits)); Enums.Ranks[] tempRanks = (Enums.Ranks[])Enum.GetValues(typeof(Enums.Ranks)); Enums.Suits[] suits = new Enums.Suits[4]; for (int i = 1; i < tempSuits.Length; i++) { suits[i - 1] = tempSuits[i]; } Enums.Ranks[] ranks = new Enums.Ranks[13]; for (int i = 1; i < tempRanks.Length; i++) { ranks[i - 1] = tempRanks[i]; } // Go through each rank and suit and add the card to the deck for (int s = 0; s < 4; s++) { for (int r = 0; r < 13; r++) { cards[(s * 13) + r] = new Card(ranks[r], suits[s]); } } }
private IEnumerable <Card> GetAllCardsForSuit(Enums.Suits suit) { var cards = new List <Card>(); var cardValues = Enums.Suits.GetValues(typeof(Enums.CardValues)).Cast <Enums.CardValues>(); foreach (var value in cardValues) { cards.Add(new Card(value, suit)); } return(cards); }
public Card(Enums.Values value, Enums.Suits suit, bool isFaceUp) : this(value, suit) { IsFaceUp = isFaceUp; }
public Card(Enums.Values value, Enums.Suits suit) { Value = value; Suit = suit; IsFaceUp = true; }
/// <summary> /// Creates a new card of the given rank and suit /// </summary> /// <param name="rank"> The rank </param> /// <param name="suit"> The suit </param> public Card(Enums.Ranks rank, Enums.Suits suit) { // Set the variables this.rank = rank; this.suit = suit; }
public Card(Enums.CardValues value, Enums.Suits suit) { Value = (int)value; Name = value.ToString(); Suit = suit.ToString(); }