Example #1
0
        public void Evaluator_Should_Accept_Multiple_Hands()
        {
            //arrange
            //act
            //var royalFlush = new List<Card>
            //{

            //    new Card(14, 1),
            //    new Card(13, 1),
            //    new Card(12, 1),
            //    new Card(11, 1),
            //    new Card(10, 1)
            //};
            //var result = evaluator.EvaluateHandScore(royalFlush);
            //assert

            var playerOne = HandBuilder.TwoPairSevensOverTwosThreeKicker();
            var playerTwo = HandBuilder.TwoPairSevensOverTwosThreeKicker();
            var playerThree = HandBuilder.TwoPairSevensOverTwosThreeKicker();
            var playerFour = HandBuilder.TwoPairSevensOverTwosThreeKicker();
            var playerFive = HandBuilder.TwoPairSevensOverTwosThreeKicker();
            var playerSix = HandBuilder.RoyalFlush();

            var hands = new List<Hand> { playerOne, playerTwo,playerThree,playerFour,playerFive,playerSix };

            var evaluator = new Evaluator(PokerHandAnalysers.FiveCardPoker());
            var result = evaluator.DetermineWinner(hands);
            Assert.That(result.Equals(playerSix));
        }
Example #2
0
        public void Evaluator_Should_Identify_A_Draw()
        {
            var playerOne = HandBuilder.RoyalFlush();
            var playerTwo = HandBuilder.RoyalFlush();

            var hands = new List<Hand> { playerOne, playerTwo };

            var evaluator = new Evaluator(PokerHandAnalysers.FiveCardPoker());
            var result = evaluator.DetermineWinner(hands);
            Assert.IsNull(result);
        }
Example #3
0
        public void Evaluator_Should_Determine_A_Winner()
        {
            var playerOne = HandBuilder.RoyalFlush();
            var playerTwo = HandBuilder.ThreeOfAKind();

            var hands = new List<Hand> {playerOne,playerTwo};

            var evaluator = new Evaluator(PokerHandAnalysers.FiveCardPoker());
            var result = evaluator.DetermineWinner(hands);
            Assert.That(result.Equals(playerOne));
        }
Example #4
0
        public void Evaluator_Should_Not_Allow_A_Lower_Ranked_Card_Set_Win()
        {
            //arrange
            //act
            //var royalFlush = new List<Card>
            //{

            //    new Card(14, 1),
            //    new Card(13, 1),
            //    new Card(12, 1),
            //    new Card(11, 1),
            //    new Card(10, 1)
            //};
            //var result = evaluator.EvaluateHandScore(royalFlush);
            //assert

            var playerOne = HandBuilder.ThreeOfAKind();
            var playerTwo = HandBuilder.RoyalFlush();

            var hands = new List<Hand> { playerOne, playerTwo };

            var evaluator = new Evaluator(PokerHandAnalysers.FiveCardPoker());
            var result = evaluator.DetermineWinner(hands);
            Assert.That(result.Equals(playerTwo));
        }
Example #5
0
        public void Run()
        {
            var aDeck = new Deck();
            var playerOne = new Hand();
            var playerTwo = new Hand();

            var poker = new GameRules();
            const int numberOfPlayers = 2;
            var gameWon = false;
            var pokerEvaluator = new Evaluator(PokerHandAnalysers.FiveCardPoker());
            aDeck.Shuffle();
            aDeck.Deal(playerOne);
            aDeck.Deal(playerTwo);

            while (!gameWon)
            {

                    for (int i = 0; i < numberOfPlayers; i++)
                    {

                        Console.WriteLine("Deck Cards:" + aDeck.Count());
                        Console.Write("Whose Turn: ");
                        if (i == 0)
                        {
                            Console.WriteLine("Player One");
                        }
                        else if (i == 1)
                        {
                            Console.WriteLine("Player Two");
                        }
                        Console.WriteLine("===Player One Hand===");

                        OutputCards(playerOne.GetCards());
                        Console.WriteLine("===Player Two Hand===");
                        OutputCards(playerTwo.GetCards());

                        var listOfHands = new List<Hand> { playerOne, playerTwo };
                        var result = pokerEvaluator.DetermineWinner(listOfHands);
                        if (result == playerOne)
                        {
                            Console.WriteLine("Player One Wins");
                        }else if (result == playerTwo)
                        {
                            Console.WriteLine("Player Two Wins");
                        }
                        else
                        {
                            Console.WriteLine("Draw");
                        }

                        Console.ReadKey();

                        //else if (//poker.CompareCards(player))

                        Console.WriteLine("D: Deal to Hand");
                        Console.WriteLine("S: Shuffle Deck");
                        Console.WriteLine("X: See Deck");
                        Console.WriteLine("R: Draw Cards");
                        Console.WriteLine("Escape: Quit");

                        var input = Console.ReadKey();

                        switch (input.Key)
                        {
                            case ConsoleKey.S:
                                aDeck.Shuffle();
                                break;
                            case ConsoleKey.D:
                                if (i == 0)
                                {

                                }
                                else if (i == 1)
                                {

                                }
                                break;
                            case ConsoleKey.R:
                                int cardsToReturn;

                                Console.WriteLine("How Many Cards?");
                                try
                                {
                                    cardsToReturn = int.Parse(Console.ReadLine());
                                }
                                finally
                                {

                                }
                                for (var j = 0; j < cardsToReturn; j++)
                                {
                                    Console.WriteLine(j);
                                }
                                Console.ReadKey();
                                if (i == 0)
                                {
                                    var cards = new List<int>();
                                    playerOne.ChangeCards(aDeck, cards);

                                }
                                else if (i == 1)
                                {
                                    var cards = new List<int>();
                                    playerTwo.ChangeCards(aDeck, cards);
                                }

                                break;

                            case ConsoleKey.Escape:
                                Environment.Exit(0);
                                break;
                            case ConsoleKey.X:

                                OutputCards(aDeck.GetCards());
                                Console.ReadKey();
                                break;
                        }
                        Console.Clear();
                    }

            }
        }