コード例 #1
0
        public void ShouldThrowExceptionTwoPlayersSameCards()
        {
            Player p1 = new Player
            {
                Name = "Player 1",
                Hand = new PokerHand
                       (
                    new Card(RankType.Ace, SuitType.Spades), new Card(RankType.King, SuitType.Hearts), new Card(RankType.Ten, SuitType.Hearts),
                    new Card(RankType.Ten, SuitType.Spades), new Card(RankType.Ace, SuitType.Hearts)
                       )
            };
            Player p2 = new Player
            {
                Name = "Player 2",
                Hand = new PokerHand
                       (
                    new Card(RankType.Ace, SuitType.Spades), new Card(RankType.Nine, SuitType.Clubs), new Card(RankType.Ten, SuitType.Clubs),
                    new Card(RankType.Two, SuitType.Clubs), new Card(RankType.Seven, SuitType.Clubs)
                       )
            };
            List <Player> players = new List <Player> {
                p1, p2
            };
            Action todo = () => PokerHand.Evaluate(players);

            todo.Should().Throw <Exception>();
        }
コード例 #2
0
        public void ShouldTwoWinnersWithTwoPairs()
        {
            Player p1 = new Player
            {
                Name = "Player 1",
                Hand = new PokerHand
                       (
                    new Card(RankType.Ace, SuitType.Spades), new Card(RankType.Two, SuitType.Hearts), new Card(RankType.Ten, SuitType.Hearts),
                    new Card(RankType.Ten, SuitType.Spades), new Card(RankType.Ace, SuitType.Hearts)
                       )
            };
            Player p2 = new Player
            {
                Name = "Player 2",
                Hand = new PokerHand
                       (
                    new Card(RankType.Ace, SuitType.Clubs), new Card(RankType.Ace, SuitType.Diamonds), new Card(RankType.Ten, SuitType.Clubs),
                    new Card(RankType.Two, SuitType.Clubs), new Card(RankType.Ten, SuitType.Diamonds)
                       )
            };
            List <Player> players = new List <Player> {
                p1, p2
            };
            IList <Player> winners = PokerHand.Evaluate(players);

            winners[0].HandType.Should().BeEquivalentTo(winners[1].HandType);
        }
コード例 #3
0
        public void ShouldFulshWinOverTwoPair()
        {
            Player p1 = new Player
            {
                Name = "Player 1",
                Hand = new PokerHand
                       (
                    new Card(RankType.Ace, SuitType.Spades), new Card(RankType.King, SuitType.Hearts), new Card(RankType.Ten, SuitType.Hearts),
                    new Card(RankType.Ten, SuitType.Spades), new Card(RankType.Ace, SuitType.Hearts)
                       )
            };
            Player p2 = new Player
            {
                Name = "Player 2",
                Hand = new PokerHand
                       (
                    new Card(RankType.Ace, SuitType.Clubs), new Card(RankType.Nine, SuitType.Clubs), new Card(RankType.Ten, SuitType.Clubs),
                    new Card(RankType.Two, SuitType.Clubs), new Card(RankType.Seven, SuitType.Clubs)
                       )
            };
            List <Player> players = new List <Player> {
                p1, p2
            };
            IList <Player> winners = PokerHand.Evaluate(players);

            winners[0].HandType.Should().Be(HandType.Flush);
        }
コード例 #4
0
        public static WinnerDTO GetWinner()
        {
            KeyValuePair <string, PokerHand> winningPlayer1   = new KeyValuePair <string, PokerHand>(player1.Name, player1.Hand);
            KeyValuePair <string, PokerHand> winningPlayer2   = new KeyValuePair <string, PokerHand>(player2.Name, player2.Hand);
            IDictionary <string, PokerHand>  potentialWinners = new Dictionary <string, PokerHand>();

            potentialWinners.Add(winningPlayer1);
            potentialWinners.Add(winningPlayer2);

            KeyValuePair <string, string> winners = PokerHand.Evaluate(potentialWinners);

            return(new WinnerDTO()
            {
                Winner = winners.Key, Type = winners.Value
            });
        }
コード例 #5
0
 public List <PokerPlayer> CalculateWinners()
 {
     return(PokerHand.Evaluate(_activePlayersHands));
 }