mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
Added .GetName extension method which will show human readable hand values in text. Also completely moved .betdraw the the new deck implementation. A renamed to Ace
This commit is contained in:
@@ -39,8 +39,16 @@ public abstract class NewDeck<TCard, TSuit, TValue>
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual TCard? Peek()
|
||||
=> _cards.First?.Value;
|
||||
public virtual TCard? Peek(int x = 0)
|
||||
{
|
||||
var card = _cards.First;
|
||||
for (var i = 0; i < x; i++)
|
||||
{
|
||||
card = card?.Next;
|
||||
}
|
||||
|
||||
return card?.Value;
|
||||
}
|
||||
|
||||
public virtual void Shuffle()
|
||||
{
|
||||
|
@@ -14,4 +14,7 @@ public sealed class RegularCard : NewCard<RegularSuit, RegularValue>
|
||||
|
||||
public override int GetHashCode()
|
||||
=> Suit.GetHashCode() * 17 + Value.GetHashCode();
|
||||
|
||||
public override string ToString()
|
||||
=> $"{Value.ToString()}-{Suit.ToString()}";
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
namespace Nadeko.Econ;
|
||||
|
||||
public static class DeckExtensions
|
||||
public static class RegularDeckExtensions
|
||||
{
|
||||
public static string GetEmoji(this RegularSuit suit)
|
||||
=> suit switch
|
||||
@@ -14,7 +14,7 @@ public static class DeckExtensions
|
||||
public static string GetEmoji(this RegularValue value)
|
||||
=> value switch
|
||||
{
|
||||
RegularValue.A => "🇦",
|
||||
RegularValue.Ace => "🇦",
|
||||
RegularValue.Two => "2️⃣",
|
||||
RegularValue.Three => "3️⃣",
|
||||
RegularValue.Four => "4️⃣",
|
||||
@@ -31,6 +31,15 @@ public static class DeckExtensions
|
||||
|
||||
public static string GetEmoji(this RegularCard card)
|
||||
=> $"{card.Value.GetEmoji()} {card.Suit.GetEmoji()}";
|
||||
|
||||
public static string GetName(this RegularValue value)
|
||||
=> value.ToString();
|
||||
|
||||
public static string GetName(this RegularSuit suit)
|
||||
=> suit.ToString();
|
||||
|
||||
public static string GetName(this RegularCard card)
|
||||
=> $"{card.Value.ToString()} of {card.Suit.GetName()}";
|
||||
}
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
public enum RegularValue
|
||||
{
|
||||
A = 1,
|
||||
Ace = 1,
|
||||
Two = 2,
|
||||
Three = 3,
|
||||
Four = 4,
|
||||
|
@@ -20,8 +20,7 @@ public sealed class BetdrawGame
|
||||
if (val is null && col is null)
|
||||
throw new ArgumentNullException(nameof(val));
|
||||
|
||||
_deck.Shuffle();
|
||||
var card = _deck.Peek()!;
|
||||
var card = _deck.Peek(_rng.Next(0, 52))!;
|
||||
|
||||
var realVal = (int)card.Value < 7
|
||||
? BetdrawValueGuess.Low
|
||||
|
Reference in New Issue
Block a user