Innobate.CardDeck.Cards 0.0.10-alpha

This is a prerelease version of Innobate.CardDeck.Cards.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Innobate.CardDeck.Cards --version 0.0.10-alpha                
NuGet\Install-Package Innobate.CardDeck.Cards -Version 0.0.10-alpha                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Innobate.CardDeck.Cards" Version="0.0.10-alpha" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Innobate.CardDeck.Cards --version 0.0.10-alpha                
#r "nuget: Innobate.CardDeck.Cards, 0.0.10-alpha"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Innobate.CardDeck.Cards as a Cake Addin
#addin nuget:?package=Innobate.CardDeck.Cards&version=0.0.10-alpha&prerelease

// Install Innobate.CardDeck.Cards as a Cake Tool
#tool nuget:?package=Innobate.CardDeck.Cards&version=0.0.10-alpha&prerelease                

CardDeck-Cards

CardDeck - Cards library

Spanish-Suited Playing Cards

A standard Spanish-suited pack of playing cards consists of 48 cards, divided into four suits:

  • Espadas (swords)
  • Bastos (clubs)
  • Copas (cups)
  • Oros (coins)

Each suit contains 12 cards: ace (as), king, knight (caballero), jack (sota), and 2-7. The 8-9 cards are usually removed due to a rise in popularity of games only involving 40 cards to play.

Court Card Ranking

The court cards are ranked as follows:

  1. King (rey)
  2. Knight (caballero)
  3. Jack (sota)

The other cards are ranked in numerical order, with the ace being the highest card.

Usage

Spanish-suited playing cards are commonly used in the following regions:

  • Spain
  • Portugal
  • Many parts of Latin America
  • The Philippines

They are also used in some parts of France and Italy.

Note

Some Spanish-suited packs may include two jokers, which are not assigned to any suit.

Example

Here is an example of a standard Spanish-suited pack of playing cards:

Suit Ace King Knight Jack 2 3 4 5 6 7
Espadas A♠ K♠ Q♠ J♠ 2♠ 3♠ 4♠ 5♠ 6♠ 7♠
Bastos A♣ K♣ Q♣ J♣ 2♣ 3♣ 4♣ 5♣ 6♣ 7♣
Copas A♥ K♥ Q♥ J♥ 2♥ 3♥ 4♥ 5♥ 6♥ 7♥
Oros A♦ K♦ Q♦ J♦ 2♦ 3♦ 4♦ 5♦ 6♦ 7♦

Espadas (Swords): E1, E2, E3, E4, E5, E6, E7, E8, E9, ES, EC, ER

Copas (Cups): C1, C2, C3, C4, C5, C6, C7, C8, C9, CS, CC, CR

Oros (Coins): O1, O2, O3, O4, O5, O6, O7, O8, O9, OS, OC, OR

Bastos (Clubs): B1, B2, B3, B4, B5, B6, B7, B8, B9, BS, BC, BR

Additional Information

  • Spanish Name: Spanish cards are called naipes españoles in Spanish. They are also sometimes referred to as baraja española (Spanish deck) or cartas de baraja (playing cards).

  • Differences from French Cards: Spanish cards are different from French-suited playing cards in a few ways. First, they have different suits: espadas (swords), bastos (clubs), copas (cups), and oros (coins). Second, they have different court cards: rey (king), caballo (knight), and sota (jack). Third, they have a different ranking system: the ace is the highest card in each suit, followed by the rey, caballo, and sota.

  • Usage in Card Games: Spanish cards are used in a variety of card games, including chinchón, brisca, and mus. They are also used in fortune telling and other divination practices.

Names in English and Spanish

Here is a table of the different names for Spanish cards in English and Spanish:

English Spanish
Ace As
King Rey
Knight Caballo
Jack Sota
Clubs Bastos
Cups Copas
Swords Espadas
Coins Oros

CardDeck.Cards.Spanish

The CardDeck.Cards.Spanish library is a component of the CardDeck library that allows developers to create custom cards for use with the CardDeck library's Deck class. These custom cards are designed to enable the creation of customized card decks tailored for specific card games or applications. While the provided code is specific to Spanish-suited playing cards, developers can adapt it to create cards for other card types.

Key Features of the CardDeck.Cards.Spanish Library:

  • Custom Card Implementation: The library provides a simple and extensible implementation for creating custom Spanish-suited playing cards. Developers can customize the suit and face values of the cards to match their specific requirements.

  • Unicode Symbols for Suits: The library includes Unicode symbols for representing the four Spanish suits: Espadas (Swords), Bastos (Clubs), Copas (Cups), and Oros (Coins). These symbols can be used to display the suits of the cards.

  • Face Values: The library defines face values for Spanish-suited cards, including Ace, King, Knight, Jack, and numeric values from 2 to 7.

  • Card Representation: Each card is represented by a combination of its suit and face value, and a short code is generated based on these values. For example, "3♠" represents the 3 of Espadas (Swords).

  • Joker Card Support: The library includes support for Joker cards with customizable values.

  • Full Card Values: In addition to standard face values, the library also provides full card values that include Eight and Nine.

Developers can use this library to create their own custom card types for various card games and applications. The provided code serves as a starting point for implementing Spanish-suited cards, and similar approaches can be applied to other types of playing cards.

The CardDeck.Cards.Spanish library can be used in conjunction with the CardDeck library to create and manage custom card decks for a wide range of card-based applications.

German-Suited Playing Cards

CardDeck-Cards: card-suits.png

A standard German-suited pack of playing cards consists of 32 or 36 cards, divided into four suits:

  • Eichel (acorns)
  • Grün (leaves)
  • Herz (hearts)
  • Schelle (bells)

Each suit contains 8 or 9 cards: Unter (under), Ober (over), König (king), and 6-10.

Court Card Ranking

The court cards are ranked as follows:

  1. Unter (Under or Jack)
  2. Ober (Over)
  3. König (king)

The other cards are ranked in numerical order, with the 10 being the highest card.

Usage

German-suited playing cards are commonly used in the following regions:

  • Germany
  • Austria
  • Switzerland
  • Liechtenstein
  • Parts of Belgium
  • Parts of the Netherlands
  • Parts of the Czech Republic
  • Parts of Slovakia
  • Parts of Hungary

Note

Some German-suited packs may include one or two jokers, which are not assigned to any suit.

###Example

Here is an example of a standard German-suited pack of playing cards: | Suit | Unter | Ober | König | 10 | 9 | 8 | 7 | 6 | | ------- | ----- | ----- | ----- | ----- | ----- | ----- | ----- | ----- | | Eichel | U♠ | O♠ | K♠ | 10♠ | 9♠ | 8♠ | 7♠ | 6♠ | | Grün | U♣ | O♣ | K♣ | 10♣ | 9♣ | 8♣ | 7♣ | 6♣ | | Herz | U♥ | O♥ | K♥ | 10♥ | 9♥ | 8♥ | 7♥ | 6♥ | | Schelle | U♦ | O♦ | K♦ | 10♦ | 9♦ | 8♦ | 7♦ | 6♦ |

Eichel (Acorns): E7, E8, E9, E10, EU, EO, EK, EA

Grün (Leaves): G7, G8, G9, G10, GU, GO, GK, GA

Herz (Hearts): H7, H8, H9, H10, HU, HO, HK, HA

Schellen (Bells): S7, S8, S9, S10, SU, SO, SK, SA

Additional Information

  • German Name: German cards are called deutsche Spielkarten in German. They are also sometimes referred to as Spielkarten (playing cards) or Kartendeck (deck of cards).

  • Differences from French Cards: German cards are different from French-suited playing cards in a few ways. First, they have different suits: Eichel (acorns), Grün (leaves), Herz (hearts), and Schelle (bells). Second, they have different court cards: Ober (over), Unter (under), and König (king). Third, they have a different ranking system: the 10 is the highest card in each suit, followed by the König, Ober, and Unter.

  • Usage in Card Games: German cards are used in a variety of card games, including Skat, Doppelkopf, Schafkopf, and Cego. They are also sometimes used to play tarot games, such as Bavarian Tarock and Swiss Tarock.

Names in English and German

Here is a table of the different names for German cards in English and German:

English German
Unter Unter
Ober Ober
König König
10 Zehn
9 Neun
8 Acht
7 Sieben
6 Sechs
Clubs Grün
Cups Herz
Swords Eichel
Coins Schelle

CardDeck.Cards.German

To create a German Suited Deck of playing cards using the CardDeck.Cards.German namespace, you can follow these steps:

  1. Create a new instance of the GermanDeckFactory<TCard, TJokerCard> class, where TCard is the type of card that you want to use in your deck and TJokerCard is the type of joker card that you want to use in your deck.
  2. Call the InitialiseCards() method on the deck factory, passing in the following parameters:
    • The deck that you want to initialise.
    • A boolean value indicating whether or not to include joker cards in the deck.
    • The number of joker cards to include in the deck (if includeJokers is true).

The InitialiseCards() method will add the following cards to the deck:

  • Four of each suit (Herz, Karo, Kreuz, and Pik) for the standard card values (Ass, Sieben, Acht, Neun, Zehn, Unter, Ober, and König).
  • Two joker cards (if includeJokers is true).

Here is an example of how to create a German Suited Deck of playing cards using the CardDeck.Cards.German namespace:

using CardDeck.Cards.German;
using CardDeck.Factories;

// Create a new German deck factory.
var deckFactory = new GermanDeckFactory<StandardCard<GermanCard.CardSuit, GermanCard.CardValue>, JokerCard<GermanCard.CardSuit, GermanCard.CardValue>>();

// Create a new deck and initialise it with joker cards.
var deck = new Deck<StandardCard<GermanCard.CardSuit, GermanCard.CardValue>, JokerCard<GermanCard.CardSuit, GermanCard.CardValue>>();
deckFactory.InitialiseCards(deck, includeJokers: true);

Once you have created a German Suited Deck of playing cards, you can use it to play a variety of card games, such as Skat, Doppelkopf, and Schafkopf.

Feature: Retrieve card value enums based on search criteria in ValueRetriever<TValue>

This feature allows users to retrieve a list of card value enums based on a variety of search criteria, including name, English name, symbol, and alternative symbol, in the ValueRetriever<TValue> class.

Benefits:

  • This feature makes it easier to find the card value enum that you are looking for, especially if you do not know the exact name or symbol.
  • This feature can be used to create more powerful and flexible card game applications.

Implementation:

  • Four new methods were added to the ValueRetriever<TValue> class:

    • GetCardEnumValuesByName()
    • GetCardEnumValuesByEnglishName()
    • GetCardEnumValuesBySymbol()
    • GetCardEnumValuesByAlternativeSymbol()
  • These methods use reflection to iterate over the enum values and get the ValueInfo object for each enum value.

  • The ValueInfo object contains information about the enum value, such as the name, English name, symbol, and alternative symbol.

  • The methods then filter the enum values based on the search criteria and return a list of the matching enum values.

Usage:

  • To use the new methods, simply create a new instance of the ValueRetriever<TValue> class and call the appropriate method.
  • The method will return a list of the matching enum values.

Example:

//Create a card value enum type
    public enum CardValueEnum
    {
        [Description("{\r\n    \"Name\": \"Joker\",\r\n    \"EnglishName\": \"Joker\",\r\n    \"IsJoker\": true\r\n}")]
        Joker,

        [Description("{\r\n    \"Name\": \"Ace\",\r\n    \"EnglishName\": \"Ace\",\r\n    \"IsAceCard\": true\r\n}")]
        Ace = 1,
    }

// Create a new instance of the ValueRetriever<TValue> class. 
var valueRetriever = new ValueRetriever<CardValueEnum>();

// Get a list of all card value enums with the name "Ace". 
var aces = valueRetriever.GetCardEnumValuesByName("Ace");

// Get a list of all card value enums with the symbol "A". 
var acesWithASymbol = valueRetriever.GetCardEnumValuesBySymbol("A");

Introduce ValueRetriver class to retrieve card value enum values

This commit introduces the ValueRetriver class, which provides methods for retrieving all card value enum values and all numeral card value enum values from an enum of type TValue. This class facilitates easier access to card value enum values and enhances the ability to handle different deck types and card values.

Key changes:

  • Created the ValueRetriver class to provide methods for retrieving card value enum values.
  • Implemented the GetAllCardEnumValues method to retrieve all card value enum values from an enum of type TValue.
  • Implemented the GetAllNumeralCardEnumValues method to retrieve all numeral card value enum values from an enum of type TValue.

Benefits:

  • Enhanced ease of access to card value enum values.
  • Improved code organization and maintainability.
  • Facilitates the development of new card types for various card games.

Enhance ValueInfo class to support various deck types

This commit enhances the ValueInfo class to provide better support for different deck types by introducing more specific properties for different card types. These properties allow the class to determine the specific type of a given card value. This enhancement enables the development of new card types for various types of card decks, making the class more versatile and adaptable.

Key changes:

  • Added IsJoker property to indicate whether a card value represents a joker.
  • Added IsCourtCard property to indicate whether a card value represents a court card.
  • Added IsNumeral property to indicate whether a card value represents a numeral card.
  • Added IsAceCard property to indicate whether a card value represents an ace.
  • Added IsQueenCard property to indicate whether a card value represents a queen.
  • Added IsJackCard property to indicate whether a card value represents a jack.
  • Added IsKnightCard property to indicate whether a card value represents a knight.
  • Added IsKingCard property to indicate whether a card value represents a king.
  • Added IsKnaveCard property to indicate whether a card value represents a knave.

Benefits:

  • Enhanced flexibility in handling different deck types and card values.
  • Improved clarity and accuracy of card value information.
  • Facilitates the development of new card types for various card games.

Example of how to develop a new card type:

  1. Create a new enum type for the card values.
  2. Add Description attributes to the enum values to encode information about the cards.
  3. Use the ValueInfo class to extract information from the Description attributes.
  4. Use the ValueRetriver class to retrieve all card value enum values or all numeral card value enum values.

Developing New Card Types

The ValueInfo class provides a mechanism to store and access information about card values. This information can be encoded into the description attribute of each enum value. For example, the following code shows how to define a new card type called "Deuce":

public enum CardValue
{
    [Description("{\r\n  \"Name\": \"Deuce\",\r\n  \"EnglishName\": \"Deuce\",\r\n  \"IsNumeral\": true\r\n}")]
    Deuce = 2
}

The description attribute for the Deuce enum value contains JSON-formatted data that specifies the name, English name, and indicates that the card is a numeral card. This information can be extracted using the ValueInfo class:

var valueInfo = ValueInfo.GetValueInfo(CardValue.Deuce);
Console.WriteLine(valueInfo.Name); // Output: Deuce
Console.WriteLine(valueInfo.EnglishName); // Output: Deuce
Console.WriteLine(valueInfo.IsNumeral); // Output: True

Developing New Card Decks

The ValueRetriever class provides methods for retrieving all card enum values and all numeral card enum values from an enum of type TValue. This allows for easy iteration over all card values or numeral card values. For example, the following code shows how to iterate over all card values in the CardValue enum:

var cardValues = ValueRetriever.GetAllCardEnumValues<CardValue>();
foreach (var cardValue in cardValues)
{
    Console.WriteLine(cardValue);
}

The ValueRetriever class can also be used to retrieve all numeral card values:

var numeralCardValues = ValueRetriever.GetAllNumeralCardEnumValues<CardValue>();
foreach (var numeralCardValue in numeralCardValues)
{
    Console.WriteLine(numeralCardValue);
}

Summary

The ValueInfo and ValueRetriever classes provide a powerful mechanism for developing new card types and decks. These classes allow for the encapsulation of card information in the description attribute of enum values and provide methods for easy access to this information. As a result, it is easy to develop new card types and decks without modifying existing code.

Introduce SuitRetriver class to retrieve suit enum values

This commit introduces the SuitRetriver class, which provides methods for retrieving all suit enum values and all joker suit enum values from an enum of type TSuit. This class facilitates easier access to suit enum values and enhances the ability to handle different deck types and suit values.

Key changes:

  • Created the SuitRetriver class to provide methods for retrieving suit enum values.
  • Implemented the GetAllSuitEnumValues method to retrieve all suit enum values from an enum of type TSuit.
  • Implemented the GetAllJokerSuitEnumValues method to retrieve all joker suit enum values from an enum of type TSuit.

Benefits:

  • Enhanced ease of access to suit enum values.
  • Improved code organization and maintainability.
  • Facilitates the development of new suit types for various card games.

Enhance SuitInfo class to support various deck types

This commit enhances the SuitInfo class to provide better support for different deck types by introducing two new properties: IsSuit and IsJoker. These properties allow the class to determine whether a given suit value represents a standard card suit or a special value like a joker. This enhancement enables the development of new suit types for various types of card decks, making the class more versatile and adaptable.

Key changes:

  • Added IsSuit property to indicate whether a suit value represents a standard card suit.
  • Added IsJoker property to indicate whether a suit value represents a joker.
  • Updated GetSuitInfo method to utilize the new IsSuit and IsJoker properties.

Benefits:

  • Enhanced flexibility in handling different deck types and suit values.
  • Improved clarity and accuracy of suit information.
  • Facilitates the development of new suit types for various card games.

The new feature allows for the development of different types of cards and the encoding of information about them into the description of the card value and card suit enum types. This facilitates easier development for new card types and various types of suited decks.

Key elements of the new feature:

  1. Description Attributes: Each enum value has a Description attribute that contains JSON-formatted data about the card.

  2. SuitInfo Class: The SuitInfo class can be used to extract information from the JSON-formatted data in the Description attributes.

  3. SuitRetriever Class: The SuitRetriever class provides methods for retrieving all suit enum values and all joker suit enum values from an enum of type TSuit.

Benefits of the new feature:

  1. Flexibility: The new feature allows for the development of new card types without modifying the existing enum types or code.

  2. Encapsulation: The information about cards is encapsulated in the Description attributes and extracted using the SuitInfo and SuitRetriever classes.

  3. Maintainability: The code is more maintainable because the information about cards is not scattered throughout the codebase.

Example of how to develop a new card type:

  1. Create a new enum type for the card values.

  2. Add Description attributes to the enum values to encode information about the cards.

  3. Use the SuitInfo class to extract information from the Description attributes.

  4. Use the SuitRetriever class to retrieve all card enum values or all joker card enum values.

This new feature makes it easier to develop new card types and various types of suited decks. It also makes the code more flexible, maintainable, and understandable.

Attribuition

<a href="https://www.flaticon.com/free-icons/playing-cards" title="playing cards icons">Playing cards icons created by Freepik - Flaticon</a>

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Innobate.CardDeck.Cards:

Package Downloads
Innobate.CardDeck.Factories

CardDeck Factories: A library of versatile deck factory classes for creating and initializing card decks tailored to various card games. Includes factories for Bezique, Euchre, Standard Spanish, Pinochle, Piquet, and Full Spanish decks, providing developers with the tools to easily generate custom card decks for their applications and card games

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.11-alpha 186 11/16/2023
0.0.10-alpha 69 11/15/2023
0.0.9-alpha 71 11/13/2023
0.0.8-alpha 71 11/10/2023
0.0.7-alpha 67 11/7/2023
0.0.6-alpha 66 11/7/2023
0.0.1-alpha5 72 11/7/2023
0.0.1-alpha4 72 11/6/2023
0.0.1-alpha3 75 11/6/2023
0.0.1-alpha2 69 11/5/2023