Skip to content

Commit

Permalink
Merge pull request #23 from todorm85/master
Browse files Browse the repository at this point in the history
Implement showdown
  • Loading branch information
NikolayIT committed Nov 28, 2015
2 parents b9e2ff0 + 93a6a4a commit 31b7bf0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
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 @@ -71,8 +73,7 @@ public void Play()

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

Expand All @@ -85,6 +86,15 @@ private void DetermineWinnerAndAddPot(int pot)
}
else
{
// showdown
foreach (var player in this.players)
{
if (player.PlayerMoney.InHand)
{
this.showdownCards.Add(player.Name, player.Cards);
}
}

var betterHand = Helpers.CompareCards(
this.players[0].Cards.Concat(this.communityCards),
this.players[1].Cards.Concat(this.communityCards));
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; }
}
}

0 comments on commit 31b7bf0

Please sign in to comment.