Xyaneon.Games.Cards 1.3.0

dotnet add package Xyaneon.Games.Cards --version 1.3.0                
NuGet\Install-Package Xyaneon.Games.Cards -Version 1.3.0                
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="Xyaneon.Games.Cards" Version="1.3.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Xyaneon.Games.Cards --version 1.3.0                
#r "nuget: Xyaneon.Games.Cards, 1.3.0"                
#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 Xyaneon.Games.Cards as a Cake Addin
#addin nuget:?package=Xyaneon.Games.Cards&version=1.3.0

// Install Xyaneon.Games.Cards as a Cake Tool
#tool nuget:?package=Xyaneon.Games.Cards&version=1.3.0                

Xyaneon.Games.Cards

License NuGet Nuget downloads .NET semantic-release: conventionalcommits

Package Icon

A .NET Standard 2.0 library for playing cards (standard and custom), draw piles and shuffling.

Usage

To use this library, you must first install the NuGet package for it, then add the following using statement at the top of each C# source file where you plan on using it:

using Xyaneon.Games.Cards;

The two most important classes in this library are Card and DrawPile<TCard>. If you are implementing your own custom card game application using this library, then your custom card class should inherit from the Card class, and you should supply that subclass type as the generic type parameter for your DrawPile<TCard> instances.

For example, you would declare your custom MyCard class as follows:

using Xyaneon.Games.Cards;

public class MyCard : Card
{
    // Your code here.
}

...and then set up a draw pile like so:

var myDrawPile = new DrawPile<MyCard>();

Note that draw piles are considered to be face-down by default. If you have a face-up pile of cards (for e.g., a discard pile), then you have to specify it in the constructor using the isFaceUp optional parameter:

var myDrawPile = new DrawPile<MyCard>(true);

After the draw pile is created, you can do several things with it, including:

// Count the number of cards in the draw pile.
int cardCount = myDrawPile.Cards.Count;

// Draw a card. An InvalidOperationException will be thrown if the pile is
// empty.
MyCard drawnCard = myDrawPile.Draw();

// Draw three cards (or at least as many as we can if there are fewer).
IEnumerable<MyCard> drawnCards = myDrawPile.DrawAtMost(3);

// Place a card on top of the draw pile.
var cardToPlaceOnTop = new MyCard();
drawPile.PlaceOnTop(cardToPlaceOnTop);

// Shuffle the draw pile using the default shuffling algorithm.
myDrawPile.Shuffle();

// Shuffle the draw pile using a custom shuffling algorithm you implemented.
IShuffleAlgorithm<MyCard> algorithm = new MyShuffleAlgorithm();
myDrawPile.Shuffle(algorithm);

// Shuffle one draw pile into another.
DrawPile<MyCard> other = myObject.YourMethodToGetAnotherDrawPile();
myDrawPile.ShuffleIn(other); // other is now empty, with its contents added to myDrawPile.

For a full list of the available properties and methods, see the source code for the DrawPile<TCard> class.

For an example usage of these classes, see the standard 52-card implementation provided with this library under the Xyaneon.Games.Cards.StandardPlayingCards namespace. This is also provided for your convenience if you want to implement a card game which uses the standard 52-card deck.

License

This library is free and open-source software provided under the MIT license. Please see the LICENSE.txt file for details.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Xyaneon.Games.Cards:

Package Downloads
Xyaneon.Games

A .NET Standard metapackage for card and board game functionality and components, such as dice and cards.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.0 428 1/16/2023
1.2.0 1,415 7/2/2022
1.1.0 446 6/5/2022
1.0.0 460 5/29/2022
0.4.0 797 12/5/2019
0.3.0 651 2/10/2019
0.2.0 642 2/9/2019
0.1.1 650 2/3/2019
0.1.0 636 2/2/2019