public static string ToFriendlyString(this PlayingCardSuit suit) { string str; if (suit == PlayingCardSuit.None) { str = suit.ToString(); } else { switch (suit) { case PlayingCardSuit.Hearts: str = "♡"; break; case PlayingCardSuit.Diamonds: str = "♦"; break; case PlayingCardSuit.Spades: str = "♠"; break; case PlayingCardSuit.Clubs: str = "♧"; break; default: str = suit.ToString(); break; } } return(str); }
public PlayingCard DrawCard(PlayingCardSuit suit) { lock (m_cardsRemaining) { var possibleCards = m_cardsRemaining.FindAll(card => card.Suit == suit); if (possibleCards.Count < 1) { return(null); } var cardPick = m_Random.Next(possibleCards.Count); var pickedCard = possibleCards[cardPick]; m_cardsRemaining.Remove(pickedCard); return(pickedCard); } }
/// <summary> /// Build a standard deck of 52 playing cards /// </summary> /// <returns></returns> public static IList <PlayingCard> BuildDeck() { var deck = new List <PlayingCard>(52); for (PlayingCardSuit suit = PlayingCardSuit.Spades; suit <= PlayingCardSuit.Clubs; suit++) { for (PlayingCardRank rank = PlayingCardRank.Ace; rank <= PlayingCardRank.King; rank++) { deck.Add(new PlayingCard(rank, suit)); } } return(deck); }
public PlayingCard(PlayingCardSuit suit, PlayingCardValue suitValue) { Suit = suit; SuitValue = suitValue; }
public PlayingCard(int id, PlayingCardSuit suit, PlayingCardRank rank) { Id = id; Suit = suit; Rank = rank; }
public PlayingCard(PlayingCardRank rank, PlayingCardSuit suit) { Rank = rank; Suit = suit; }
public static PlayingCard AllButHighestCardOfSuit(this IEnumerable <PlayingCard> cards, PlayingCardSuit suit, bool aceRankHigh = true) { var comparer = new PlayingCardRankComparer { AceRankHigh = aceRankHigh }; var cardsOfSuit = cards.Where(x => x.Suit == suit).OrderByDescending(x => x.Rank, comparer).ToList(); var result = cardsOfSuit.FirstOrDefault(); return(result); }
/// <summary> /// Creates a playing card. /// </summary> /// <param name="options">The options on how cards are played.</param> /// <param name="suit">The suit of the card.</param> /// <param name="rank">The rank of the card.</param> internal PlayingCard(PlayingCardOptions options, PlayingCardSuit suit, PlayingCardRank rank) { Rank = rank; Suit = suit; Options = options; }
public PlayingCard(char cardValue, char cardSuit) { CardValue = CreateCardValue(cardValue); CardSuit = CreateCardSuit(cardSuit); }
public void PlayingCard_ConvertsSuitToEnum(char cardSuit, PlayingCardSuit expectedSuit) { var playingCard = new PlayingCard('2', cardSuit); Assert.AreEqual(expectedSuit, playingCard.CardSuit); }
public PlayingCard(PlayingCardSuit suit, PlayingCardRank rank) { Suit = suit; Rank = rank; }
public static string AsString(this PlayingCardSuit value) => Strings[value];