42 lines
980 B
C#
42 lines
980 B
C#
|
using Sequence.Entities;
|
||
|
|
||
|
public static class CardUtility
|
||
|
{
|
||
|
public static readonly IDictionary<int, string> faceCardMap = new Dictionary<int, string>
|
||
|
{
|
||
|
[11] = "J",
|
||
|
[12] = "Q",
|
||
|
[13] = "K"
|
||
|
};
|
||
|
|
||
|
public static ICollection<Card> GenerateDeck()
|
||
|
{
|
||
|
var cards = new List<Card>();
|
||
|
var suits = Enum.GetValues<Suit>();
|
||
|
|
||
|
foreach (var suit in suits)
|
||
|
{
|
||
|
for (var i = 1; i <= 10; i++)
|
||
|
{
|
||
|
cards.Add(new Card
|
||
|
{
|
||
|
Id = Guid.NewGuid(),
|
||
|
Suit = suit,
|
||
|
Value = i.ToString()
|
||
|
});
|
||
|
}
|
||
|
|
||
|
foreach (var faceCard in faceCardMap)
|
||
|
{
|
||
|
cards.Add(new Card
|
||
|
{
|
||
|
Id = Guid.NewGuid(),
|
||
|
Suit = suit,
|
||
|
Value = faceCard.Value
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return cards;
|
||
|
}
|
||
|
}
|