Cards/Standard52/Suit.cs

Defines the Suit enum for a standard 52-card deck and extension methods. Provides a Glyph() method that returns the Unicode symbol for each suit and an IsRed() method that returns true for hearts and diamonds.

namespace CardGames;

/// <summary>
/// The four suits of a standard 52-card deck.
/// </summary>
public enum Suit
{
	Clubs,
	Diamonds,
	Hearts,
	Spades
}

public static class SuitExtensions
{
	/// <summary>
	/// Unicode pip glyph for the suit.
	/// </summary>
	public static string Glyph( this Suit suit ) => suit switch
	{
		Suit.Clubs => "♣",    // ♣
		Suit.Diamonds => "♦", // ♦
		Suit.Hearts => "♥",   // ♥
		Suit.Spades => "♠",   // ♠
		_ => "?"
	};

	/// <summary>
	/// Hearts and diamonds are red, clubs and spades are black.
	/// </summary>
	public static bool IsRed( this Suit suit ) => suit is Suit.Diamonds or Suit.Hearts;
}