diff --git a/src/CardGames.Core.French/CardGames.Core.French.csproj b/src/CardGames.Core.French/CardGames.Core.French.csproj index 32f36f8..062efa7 100644 --- a/src/CardGames.Core.French/CardGames.Core.French.csproj +++ b/src/CardGames.Core.French/CardGames.Core.French.csproj @@ -20,7 +20,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/CardGames.Playground.Runner/CardGames.Poker.Benchmarks.csproj b/src/CardGames.Playground.Runner/CardGames.Poker.Benchmarks.csproj index 439574c..c3af967 100644 --- a/src/CardGames.Playground.Runner/CardGames.Poker.Benchmarks.csproj +++ b/src/CardGames.Playground.Runner/CardGames.Poker.Benchmarks.csproj @@ -1,4 +1,4 @@ - + Exe @@ -6,7 +6,7 @@ - + diff --git a/src/CardGames.Poker.CLI/Program.cs b/src/CardGames.Poker.CLI/Program.cs index accfdc7..cbe55bc 100644 --- a/src/CardGames.Poker.CLI/Program.cs +++ b/src/CardGames.Poker.CLI/Program.cs @@ -1,36 +1,29 @@ using CardGames.Poker.CLI.Simulation; using Spectre.Console.Cli; -namespace CardGames.Poker.CLI; - -internal static class Program +var app = new CommandApp(); +app.Configure(configuration => { - private static void Main(string[] args) + configuration.SetApplicationName("poker-cli"); + configuration.AddBranch("sim", sim => { - var app = new CommandApp(); - app.Configure(configuration => - { - configuration.SetApplicationName("poker-cli"); - configuration.AddBranch("sim", sim => - { - sim - .AddCommand("stud-hi") - .WithAlias("7cs-hi") - .WithAlias("stud") - .WithDescription("Runs a 7-card Stud hi simulation."); + sim + .AddCommand("stud-hi") + .WithAlias("7cs-hi") + .WithAlias("stud") + .WithDescription("Runs a 7-card Stud hi simulation."); + + sim + .AddCommand("holdem") + .WithAlias("nlh") + .WithAlias("lhe") + .WithDescription("Runs a Holdem simulation."); - sim - .AddCommand("holdem") - .WithAlias("nlh") - .WithAlias("lhe") - .WithDescription("Runs a Holdem simulation."); + sim + .AddCommand("omaha") + .WithAlias("plo") + .WithDescription("Runs an Omaha simulation."); + }); +}); - sim - .AddCommand("omaha") - .WithAlias("plo") - .WithDescription("Runs an Omaha simulation."); - }); - }); - app.Run(args); - } -} +app.Run(args); diff --git a/src/CardGames.Poker/Simulations/Holdem/CommunityCardGamePlayer.cs b/src/CardGames.Poker/Simulations/Holdem/CommunityCardGamePlayer.cs index 082f1f8..fbad93b 100644 --- a/src/CardGames.Poker/Simulations/Holdem/CommunityCardGamePlayer.cs +++ b/src/CardGames.Poker/Simulations/Holdem/CommunityCardGamePlayer.cs @@ -7,7 +7,10 @@ namespace CardGames.Poker.Simulations.Holdem; public class CommunityCardGamePlayer { public string Name { get; init; } + public IReadOnlyCollection GivenHoleCards { get; init; } + public IReadOnlyCollection DealtHoleCards { get; set; } + public IEnumerable Cards => GivenHoleCards.Concat(DealtHoleCards); } diff --git a/src/CardGames.Poker/Simulations/Holdem/HoldemSimulation.cs b/src/CardGames.Poker/Simulations/Holdem/HoldemSimulation.cs index 4fc41ee..1f6befa 100644 --- a/src/CardGames.Poker/Simulations/Holdem/HoldemSimulation.cs +++ b/src/CardGames.Poker/Simulations/Holdem/HoldemSimulation.cs @@ -11,7 +11,7 @@ namespace CardGames.Poker.Simulations.Holdem; public class HoldemSimulation { private FrenchDeckDealer _dealer; - private IList _players = new List(); + private readonly List _players = new(); private IReadOnlyCollection _flop = new List(); private Card _turn; private Card _river; @@ -68,14 +68,14 @@ private HoldemSimulationResult Play(int nrOfHands) return new HoldemSimulationResult(nrOfHands, results.ToList()); } - private IDictionary PlayHand() + private Dictionary PlayHand() { _dealer.Shuffle(); RemoveKnownCardsFromDeck(); DealMissingHoleCards(); var communityCards = DealCommunityCards(); - return _players.ToDictionary(player => player.Name, p => new HoldemHand(p.Cards.ToList(), communityCards)); + return _players.ToDictionary(player => player.Name, player => new HoldemHand(player.Cards.ToList(), communityCards)); } private IReadOnlyCollection DealCommunityCards() diff --git a/src/Tests/CardGames.Core.French.Tests/CardGames.Core.French.Tests.csproj b/src/Tests/CardGames.Core.French.Tests/CardGames.Core.French.Tests.csproj index 7e9b0ba..0a4bf5a 100644 --- a/src/Tests/CardGames.Core.French.Tests/CardGames.Core.French.Tests.csproj +++ b/src/Tests/CardGames.Core.French.Tests/CardGames.Core.French.Tests.csproj @@ -6,11 +6,11 @@ - - - - - + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/Tests/CardGames.Core.Tests/CardGames.Core.Tests.csproj b/src/Tests/CardGames.Core.Tests/CardGames.Core.Tests.csproj index cb7fa81..6ec8cb2 100644 --- a/src/Tests/CardGames.Core.Tests/CardGames.Core.Tests.csproj +++ b/src/Tests/CardGames.Core.Tests/CardGames.Core.Tests.csproj @@ -6,11 +6,11 @@ - - - - - + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/Tests/CardGames.Poker.Tests/CardGames.Poker.Tests.csproj b/src/Tests/CardGames.Poker.Tests/CardGames.Poker.Tests.csproj index 424f206..cf900c9 100644 --- a/src/Tests/CardGames.Poker.Tests/CardGames.Poker.Tests.csproj +++ b/src/Tests/CardGames.Poker.Tests/CardGames.Poker.Tests.csproj @@ -7,11 +7,11 @@ - - - - - + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/Tests/CardGames.Poker.Tests/Hands/HoldemHandTests.cs b/src/Tests/CardGames.Poker.Tests/Hands/HoldemHandTests.cs index a84dc3a..e429158 100644 --- a/src/Tests/CardGames.Poker.Tests/Hands/HoldemHandTests.cs +++ b/src/Tests/CardGames.Poker.Tests/Hands/HoldemHandTests.cs @@ -10,7 +10,10 @@ public class HoldemHandTests { [Theory] [InlineData("2s 5d", "8d Js Kc 5c 5h", HandType.Trips)] + [InlineData("2s 6d", "5d Js Kc 5c 5h", HandType.Trips)] [InlineData("2s 2d", "8d Js Kc 5c 5h", HandType.TwoPair)] + [InlineData("Qs 2d", "8d Js Qc 5c 5h", HandType.TwoPair)] + [InlineData("Qs 5d", "8d Js Qc 2c 5h", HandType.TwoPair)] [InlineData("2s 2d", "5d Js Kc 5c 5h", HandType.FullHouse)] [InlineData("2s 2h", "5d Jh Kh 6h 5h", HandType.Flush)] [InlineData("2s 2c", "7h Jh Kh 6h 5h", HandType.Flush)]