Innobate.CardDeck.Factories 0.0.11-alpha

This is a prerelease version of Innobate.CardDeck.Factories.
dotnet add package Innobate.CardDeck.Factories --version 0.0.11-alpha                
NuGet\Install-Package Innobate.CardDeck.Factories -Version 0.0.11-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.Factories" Version="0.0.11-alpha" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Innobate.CardDeck.Factories --version 0.0.11-alpha                
#r "nuget: Innobate.CardDeck.Factories, 0.0.11-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.Factories as a Cake Addin
#addin nuget:?package=Innobate.CardDeck.Factories&version=0.0.11-alpha&prerelease

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

CardDeck Factories Card Deck Factories

CardDeck Factories Overview and Quick Guide

The CardDeck library includes several deck factories in the CardDeck.Factories namespace, each designed to create different types of card decks. This overview and quick guide provide an introduction to seven specific deck factories: Bezique, Euchre, Standard Spanish, Pinochle, Piquet, Full Spanish, and Standard German.

Bezique Deck Factory

The Bezique Deck Factory (BeziqueDeckFactory) is designed for creating decks suitable for the card game Bezique. Here's a quick guide to using this factory:

  • Deck Type: Bezique.
  • Deck Size: 32 cards (standard Bezique deck size).
  • Cards in a Standard Suit: 8 cards (suits: Hearts, Diamonds, Spades, and Clubs).
  • Number of Suits in Deck: 4 (Hearts, Diamonds, Spades, and Clubs).

Factory Methods:

  • CreateCard(int suit, int value): Create a card for the given suit and value.
  • CreateJokerCard(int suit, int value): Create a joker card for the given suit and value.
  • CreateJokerCard(int suit, int value, JokerType type): Create a joker card with a specific type.
  • InitialiseCards(Deck<TCard, TJokerCard> deck, bool includeJokers = false, int jokerQuantity = 2): Initialize the cards in the deck.
  • getDeckType(): Get the deck type ("Bezique").

Euchre Deck Factory

The Euchre Deck Factory (EuchreDeckFactory) is tailored for creating decks suitable for the card game Euchre. Here's a quick guide to using this factory:

  • Deck Type: Euchre.
  • Deck Size: 24 cards (standard Euchre deck size).
  • Cards in a Standard Suit: 6 cards (suits: Hearts, Diamonds, Spades, and Clubs).
  • Number of Suits in Deck: 4 (Hearts, Diamonds, Spades, and Clubs).

Factory Methods:

  • CreateCard(int suit, int value): Create a card for the given suit and value.
  • CreateJokerCard(int suit, int value): Create a joker card for the given suit and value.
  • CreateJokerCard(int suit, int value, JokerType type): Create a joker card with a specific type.
  • InitialiseCards(Deck<TCard, TJokerCard> deck, bool includeJokers = false, int jokerQuantity = 1): Initialize the cards in the deck.
  • getDeckType(): Get the deck type ("Euchre").

Spanish Deck Factory

The Spanish Deck Factory (SpanishDeckFactory) is intended for creating decks adhering to the standard Spanish-suited playing cards. Here's a quick guide to using this factory:

  • Deck Type: Standard Spanish.
  • Deck Size: 40 cards (standard Spanish deck size).
  • Cards in a Standard Suit: 10 cards (suits: Espadas, Bastos, Copas, and Oros).
  • Number of Suits in Deck: 4 (Espadas, Bastos, Copas, and Oros).

Factory Methods:

  • CreateCard(int suit, int value): Create a card for the given suit and value.
  • CreateJokerCard(int suit, int value): Create a joker card for the given suit and value.
  • CreateJokerCard(int suit, int value, JokerType type): Create a joker card with a specific type.
  • InitialiseCards(Deck<TCard, TJokerCard> deck, bool includeJokers = false, int jokerQuantity = 2): Initialize the cards in the deck.
  • getDeckType(): Get the deck type ("Standard Spanish").

Pinochle Deck Factory

The Pinochle Deck Factory (PinochleDeckFactory) is designed for creating decks suitable for the card game Pinochle. Here's a quick guide to using this factory:

  • Deck Type: Pinochle - French US.
  • Deck Size: 48 cards (standard Pinochle deck size).
  • Cards in a Standard Suit: 12 cards (suits: Hearts, Diamonds, Spades, and Clubs).
  • Number of Suits in Deck: 4 (Hearts, Diamonds, Spades, and Clubs).

Factory Methods:

  • CreateCard(int suit, int value): Create a card for the given suit and value.
  • CreateJokerCard(int suit, int value): Create a joker card for the given suit and value.
  • CreateJokerCard(int suit, int value, JokerType type): Create a joker card with a specific type.
  • InitialiseCards(Deck<TCard, TJokerCard> deck, bool includeJokers = false, int jokerQuantity = 2): Initialize the cards in the deck.
  • getDeckType(): Get the deck type ("Pinochle - French US").

Piquet Deck Factory

The Piquet Deck Factory (PiquetDeckFactory) is tailored for creating decks suitable for the card game Piquet. Here's a quick guide to using this factory:

  • Deck Type: Piquet.
  • Deck Size: 32 cards (standard Piquet deck size).
  • Cards in a Standard Suit: 8 cards (suits: Hearts, Diamonds, Spades, and Clubs).
  • Number of Suits in Deck: 4 (Hearts, Diamonds, Spades, and Clubs).

Factory Methods:

  • CreateCard(int suit, int value): Create a card for the given suit and value.
  • CreateJokerCard(int suit, int value): Create a joker card for the given suit and value.
  • CreateJokerCard(int suit, int value, JokerType type): Create a joker card with a specific type.
  • InitialiseCards(Deck<TCard, TJokerCard> deck, bool includeJokers = false, int jokerQuantity = 2): Initialize the cards in the deck.
  • getDeckType(): Get the deck type ("Piquet").

Spanish Full Deck Factory

The Spanish Full Deck Factory (SpanishFullDeckFactory) is intended for creating decks adhering to the full Spanish-suited playing cards, including full card values. Here's a quick guide to using this factory:

  • Deck Type: Full Spanish.
  • Deck Size: 48 cards (standard full Spanish deck size).
  • Cards in a Standard Suit: 12 cards (suits: Espadas, Bastos, Copas, and Oros).
  • Number of Suits in Deck: 4 (Espadas, Bastos, Copas, and Oros).

Factory Methods:

  • CreateCard(int suit, int value): Create a card for the given suit and value.
  • CreateJokerCard(int suit, int value): Create a joker card for the given suit and value.
  • CreateJokerCard(int suit, int value, JokerType type): Create a joker card with a specific type.
  • InitialiseCards(Deck<TCard, TJokerCard> deck, bool includeJokers = false, int jokerQuantity = 2): Initialize the cards in the deck.
  • getDeckType(): Get the deck type ("Full Spanish").

Standard German Deck Factory

The Standard German Deck Factory (GermanDeckFactory) is intended for creating decks adhering to the standard German-suited playing cards. Here's a quick guide to using this factory:

  • Deck Type: Standard German.
  • Deck Size: 32 cards (standard German deck size).
  • Cards in a Standard Suit: 8 cards (suits: Hearts, Diamonds, Spades, and Clubs).
  • Number of Suits in Deck: 4 (Hearts, Diamonds, Spades, and Clubs).

Factory Methods:

  • CreateCard(int suit, int value): Create a card for the given suit and value.
  • CreateJokerCard(int suit, int value): Create a joker card for the given suit and value.
  • CreateJokerCard(int suit, int value, JokerType type): Create a joker card with a specific type.
  • InitialiseCards(Deck<TCard, TJokerCard> deck, bool includeJokers = false, int jokerQuantity = 2): Initialize the cards in the deck.
  • getDeckType(): Get the deck type ("Standard German").

These deck factories provide a convenient way to create and initialize decks for different card games. You can select the appropriate factory based on the requirements of your card game and use the provided methods to create and configure your decks.

Example Usage

// Example of creating a Bezique deck using the Generic Deck Factory
var beziqueDeckFactory = new GenericDeckFactory<BeziqueCard, BeziqueJokerCard, BeziqueSuit, BeziqueValue>();
var beziqueDeck = new Deck<BeziqueCard, BeziqueJokerCard>();
beziqueDeckFactory.InitialiseCards(beziqueDeck, includeJokers: true);

Example

An example in C# of how to use the different deck factories to create decks of cards for various types:

using CardDeck.Cards;
using CardDeck.Factories;

class Program
{
    static void Main()
    {
        // Create a Bezique deck
        IDeckFactory<Card, JokerCard> beziqueFactory = new BeziqueDeckFactory<Card, JokerCard>();
        Deck<Card, JokerCard> beziqueDeck = new Deck<Card, JokerCard>(beziqueFactory);
        beziqueFactory.InitialiseCards(beziqueDeck, includeJokers: true, jokerQuantity: 2);

        // Create an Euchre deck
        IDeckFactory<Card, JokerCard> euchreFactory = new EuchreDeckFactory<Card, JokerCard>();
        Deck<Card, JokerCard> euchreDeck = new Deck<Card, JokerCard>(euchreFactory);
        euchreFactory.InitialiseCards(euchreDeck, includeJokers: true, jokerQuantity: 1);

        // Create a Spanish Full deck
        IDeckFactory<SpanishCard, SpanishJokerCard> spanishFullFactory = new SpanishFullDeckFactory<SpanishCard, SpanishJokerCard>();
        Deck<SpanishCard, SpanishJokerCard> spanishFullDeck = new Deck<SpanishCard, SpanishJokerCard>(spanishFullFactory);
        spanishFullFactory.InitialiseCards(spanishFullDeck, includeJokers: true, jokerQuantity: 2);

        // Create a Pinochle deck
        IDeckFactory<Card, JokerCard> pinochleFactory = new PinochleDeckFactory<Card, JokerCard>();
        Deck<Card, JokerCard> pinochleDeck = new Deck<Card, JokerCard>(pinochleFactory);
        pinochleFactory.InitialiseCards(pinochleDeck, includeJokers: true, jokerQuantity: 2);

        // Create a Piquet deck
        IDeckFactory<Card, JokerCard> piquetFactory = new PiquetDeckFactory<Card, JokerCard>();
        Deck<Card, JokerCard> piquetDeck = new Deck<Card, JokerCard>(piquetFactory);
        piquetFactory.InitialiseCards(piquetDeck, includeJokers: true, jokerQuantity: 2);

        // You now have decks of different types ready to be used in card games!
    }
}

Generic Deck Factory

CardDeck-Factories: deck-factory.png

The Generic Deck Factory (GenericDeckFactory) is a flexible factory class within the CardDeck library designed for creating decks in various card games. It allows the creation and configuration of card decks based on specified constraints for standard playing cards and joker cards. The factory supports generic types and is developed to be compatible with any subtype of the Card and JokerCard classes, ensuring adherence to specific type constraints for TCard and TJokerCard.

Factory Details

GenericDeckFactory Methods

  • StandardDeckSize(): Returns the size of the standard deck created by the factory.
  • CardsInStandardSuit(): Returns the number of cards in a standard suit.
  • SuitsInDeck(): Returns the number of suits in the deck.
  • CreateCard(int suit, int value): Creates a standard playing card based on the specified suit and value.
  • CreateJokerCard(int suit, int value): Creates a joker card based on the specified suit and value.
  • CreateJokerCard(int suit, int value, JokerType type): Creates a joker card with a specific type.
  • InitialiseCards(Deck<TCard, TJokerCard> deck, bool includeJokers = false, int jokerQuantity = 2): Initializes the cards in the deck.
  • GetDeckType(): Returns a string representing the type of deck created by the factory.

Constructor

The factory initializes its properties, such as standardDeckSize and cardsInStandardSuit, based on the provided generic types for TSuit and TValue. It uses reflection to retrieve all possible suit and value enum values and calculates the deck size accordingly.

Usage

The Generic Deck Factory provides a versatile solution for creating and configuring card decks in various card games. It supports the inclusion of jokers, allowing for even greater flexibility.

Example Usage

// Example of creating a Bezique deck using the Generic Deck Factory
var gDeckFactory = new GenericDeckFactory<StandardCard, JokerCard, CardSuit, CardValue>();
var gDeck = new Deck<StandardCard, JokerCard>();
gDeckFactory.InitialiseCards(gDeck, includeJokers: true);

Make sure to replace StandardCard, JokerCard, CardSuit, and CardValue with your specific card, joker card, suit, and value types when using the factory for different card games.

Note The factory uses enums for suits (TSuit) and values (TValue) to ensure type safety. The deck type returned by GetDeckType() includes the suit type name to provide additional context.

Attribution

<a href="https://www.flaticon.com/free-icons/spanish-deck" title="spanish-deck icons">Spanish-deck 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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.