Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add showdown #22

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions Source/TexasHoldem.Logic/GameMechanics/TwoPlayersHandLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ internal class TwoPlayersHandLogic

private readonly TwoPlayersBettingLogic bettingLogic;

private Dictionary<string, ICollection<Card>> showdownCards;

public TwoPlayersHandLogic(IList<InternalPlayer> players, int handNumber, int smallBlind)
{
this.handNumber = handNumber;
Expand Down Expand Up @@ -69,10 +71,18 @@ public void Play()

this.DetermineWinnerAndAddPot(this.bettingLogic.Pot);

// showdown
foreach (var player in this.players)
{
if (player.PlayerMoney.InHand)
{
this.showdownCards.Add(player.Name, player.Cards);
}
}

foreach (var player in this.players)
{
// TODO: Showdown?
player.EndHand(new EndHandContext());
player.EndHand(new EndHandContext(this.showdownCards));
}
}

Expand Down
9 changes: 9 additions & 0 deletions Source/TexasHoldem.Logic/Players/EndHandContext.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
namespace TexasHoldem.Logic.Players
{
using System.Collections.Generic;
using TexasHoldem.Logic.Cards;

public class EndHandContext
{
public EndHandContext(Dictionary<string, ICollection<Card>> showdownCards)
{
this.ShowdownCards = showdownCards;
}

public Dictionary<string, ICollection<Card>> ShowdownCards { get; private set; }
}
}