Beispiel #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);
        }
        public void CheckForFullHouse()
        {
            User player = new User("Gosho", 1000);
            player.HandAndBoard = fullHouseCards.ToList();
            BestHand.SetBestCards(player);

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

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

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

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

            Assert.AreEqual(6, player.BestHand.Value);
        }
        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);
        }