Skip to content

Commit

Permalink
Add showdown
Browse files Browse the repository at this point in the history
Add showdown functionality to TwoPlayersHandLogic. The list of player`s showdown cards is passed as property ShowdownCards of the EndHandContext object to IPlayer.EndHand() method.
  • Loading branch information
todorm85 committed Nov 27, 2015
1 parent b9e2ff0 commit 2fcdb8e
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 @@ -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; }
}
}

0 comments on commit 2fcdb8e

Please sign in to comment.