mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-01-06 18:14:27 -08:00
Add Table and Player abstractions
This commit is contained in:
@@ -4,6 +4,8 @@ namespace Poker;
|
||||
|
||||
internal class Hand
|
||||
{
|
||||
public static readonly Hand Empty = new Hand();
|
||||
|
||||
private readonly Card[] _cards;
|
||||
private readonly Card _highCard;
|
||||
private readonly string _name1;
|
||||
@@ -11,6 +13,15 @@ internal class Hand
|
||||
private readonly int _keepMask;
|
||||
private readonly Func<int, int> _iTransform;
|
||||
|
||||
private Hand()
|
||||
{
|
||||
_cards = Array.Empty<Card>();
|
||||
_name1 = "";
|
||||
_name2 = "";
|
||||
_iTransform = Identity;
|
||||
Name = "";
|
||||
}
|
||||
|
||||
public Hand(IEnumerable<Card> cards)
|
||||
{
|
||||
_cards = cards.ToArray();
|
||||
@@ -101,12 +112,12 @@ internal class Hand
|
||||
iTransform = To6;
|
||||
}
|
||||
return (handRank, handName1, handName2, highCard, keepMask, iTransform);
|
||||
|
||||
int Identity(int x) => x;
|
||||
int To6(int _) => 6;
|
||||
int To6If1(int x) => x == 1 ? 6 : x;
|
||||
}
|
||||
|
||||
private int Identity(int x) => x;
|
||||
private int To6(int _) => 6;
|
||||
private int To6If1(int x) => x == 1 ? 6 : x;
|
||||
|
||||
private string GetHandName()
|
||||
{
|
||||
var sb = new StringBuilder(_name1).Append(_name2);
|
||||
|
||||
Reference in New Issue
Block a user