Betdraw reimplemented (mostly) using the new deck implementation

This commit is contained in:
Kwoth
2022-07-22 17:36:43 +02:00
parent 39fc21d41c
commit c20b851dc7
5 changed files with 87 additions and 13 deletions

View File

@@ -0,0 +1,47 @@
namespace Nadeko.Econ;
public static class DeckExtensions
{
public static string GetEmoji(this RegularSuit suit)
=> suit switch
{
RegularSuit.Hearts => "♥️",
RegularSuit.Spades => "♠️",
RegularSuit.Diamonds => "♦️",
_ => "♣️",
};
public static string GetEmoji(this RegularValue value)
=> value switch
{
RegularValue.A => "🇦",
RegularValue.Two => "2⃣",
RegularValue.Three => "3⃣",
RegularValue.Four => "4⃣",
RegularValue.Five => "5⃣",
RegularValue.Six => "6⃣",
RegularValue.Seven => "7⃣",
RegularValue.Eight => "8⃣",
RegularValue.Nine => "9⃣",
RegularValue.Ten => "🔟",
RegularValue.Jack => "🇯",
RegularValue.Queen => "🇶",
_ => "🇰",
};
public static string GetEmoji(this RegularCard card)
=> $"{card.Value.GetEmoji()} {card.Suit.GetEmoji()}";
}

View File

@@ -39,13 +39,16 @@ public abstract class NewDeck<TCard, TSuit, TValue>
return null;
}
public virtual TCard? Peek()
=> _cards.First?.Value;
public virtual void Shuffle()
{
var cards = _cards.ToList();
cards.Shuffle();
var newCards = cards.Shuffle();
_cards.Clear();
foreach (var card in cards)
foreach (var card in newCards)
_cards.AddFirst(card);
}
}