public void GetPossibleWinningPlayers_ReturnsPlayersWithBestCategoryOfHand()
        {
            string      player1Name  = "mockPlayer1";
            List <Card> player1Cards = TestUtil.CreateTestFlushCards(Suit.Club, new int[] { 13, 10, 3, 5, 4 });
            Player      player1      = new Player(player1Name, player1Cards);

            string      player2Name  = "mockPlayer2";
            List <Card> player2Cards = TestUtil.CreateDefaultThreeOfAKindCards();
            Player      player2      = new Player(player2Name, player2Cards);

            string      player3Name  = "mockPlayer3";
            List <Card> player3Cards = TestUtil.CreateTestFlushCards(Suit.Heart, new int[] { 6, 1, 3, 5, 4 });
            Player      player3      = new Player(player3Name, player3Cards);

            List <Player> players = new List <Player>
            {
                { player1 },
                { player2 },
                { player3 }
            };

            List <Player> result = PlayerUtils.GetPossibleWinningPlayers(players);

            Assert.AreEqual(result.Count, 2);
            Assert.IsNotNull(result.Find((player) => player.Name == player1Name));
            Assert.IsNotNull(result.Find((player) => player.Name == player3Name));
            Assert.AreEqual(result.Find((player) => player.Name == player1Name).HandOfCards.GetHandType(), HandType.Flush);
            Assert.AreEqual(result.Find((player) => player.Name == player3Name).HandOfCards.GetHandType(), HandType.Flush);
        }
Exemplo n.º 2
0
        public List <Player> GetWinningPlayers(Dictionary <string, List <Card> > gameData)
        {
            PlayerUtils.ValidateGameData(gameData);

            List <Player> players = PlayerUtils.GeneratePlayers(gameData);

            List <Player> possibleWinners = PlayerUtils.GetPossibleWinningPlayers(players);

            List <Player> winningPlayers = PlayerUtils.ResolveTies(possibleWinners);

            return(winningPlayers);
        }