Esempio n. 1
0
        private static Player DecideWinner(List <Player> players)
        {
            foreach (var player in players)
            {
                player.HandAndBoard = player.Hand;
                player.HandAndBoard.AddRange(CardData.Board);
                BestHand.SetBestCards(player);
            }

            Player bestPlayer = players[0];

            for (int i = 1; i < players.Count; i++)
            {
                if (players[i].BestHand.Value > bestPlayer.BestHand.Value)
                {
                    bestPlayer = players[i];
                }
                else if (players[i].BestHand.Value == bestPlayer.BestHand.Value)
                {
                    for (int j = 0; j < 5; j++)
                    {
                        if (players[i].BestHand.BestCards[j].Number > bestPlayer.BestHand.BestCards[j].Number)
                        {
                            bestPlayer = players[i];
                            break;
                        }
                        else if (players[i].BestHand.BestCards[j].Number < bestPlayer.BestHand.BestCards[j].Number)
                        {
                            break;
                        }
                    }
                }
            }
            return(bestPlayer);
        }
Esempio n. 2
0
        public void CheckForFullHouse()
        {
            User player = new User("Gosho", 1000);
            player.HandAndBoard = fullHouseCards.ToList();
            BestHand.SetBestCards(player);

            Assert.AreEqual(7, player.BestHand.Value);
        }
Esempio n. 3
0
        public void CheckForTwoPair()
        {
            User player = new User("Gosho", 1000);
            player.HandAndBoard = twoPairCards.ToList();
            BestHand.SetBestCards(player);

            Assert.AreEqual(3, player.BestHand.Value);
        }
Esempio n. 4
0
        public void CheckForStraightFlushWithDuplicates()
        {
            User player = new User("Gosho", 1000);
            player.HandAndBoard = straightFlushCardsWithDupl.ToList();
            BestHand.SetBestCards(player);

            Assert.AreEqual(9, player.BestHand.Value);
        }
Esempio n. 5
0
        public void ChecksForStraight()
        {
            User player = new User("Gosho", 1000);
            player.HandAndBoard = straightCards.ToList();
            BestHand.SetBestCards(player);

            Assert.AreEqual(5, player.BestHand.Value);
        }
Esempio n. 6
0
        public void ChecksForFlush()
        {
            User player = new User("Gosho", 1000);
            player.HandAndBoard = flushCards.ToList();
            BestHand.SetBestCards(player);

            Assert.AreEqual(6, player.BestHand.Value);
        }
Esempio n. 7
0
        public void ChecksForStraightWithAceLow()
        {
            User player = new User("Gosho", 1000);
            player.HandAndBoard = aceLowStraightCards.ToList();
            BestHand.SetBestCards(player);

            Assert.AreEqual(5, player.BestHand.Value);
            Assert.AreEqual(14, player.BestHand.BestCards.Last().Number);
        }