Ejemplo n.º 1
0
        public void EvaluateHands()
        {
            //create player's computer's evaluation object(passing SORTED hand to Constructor)
            HandEvaluator playerHandEvaluator   = new HandEvaluator(sortedPlayerHand);
            HandEvaluator computerHandEvaluator = new HandEvaluator(sortedComputerHand);

            //get the player's and computer'hand
            Hand playerHand   = playerHandEvaluator.EvaluateHand();
            Hand computerHand = computerHandEvaluator.EvaluateHand();

            //display each hand
            Console.WriteLine("\n\n\n\nPlayer's Hand: " + playerHand);
            Console.WriteLine("\nComputer's Hand: " + computerHand);

            //evaluate hands
            if (playerHand > computerHand)
            {
                Console.WriteLine("Player WINS!");
            }
            else if (playerHand < computerHand)
            {
                Console.WriteLine("Computer WINS!");
            }
            else // if the hands are the same , evaluate the values
            {
                //first evaluate who has higher value of poker hand
                if (playerHandEvaluator.HandValues.Total > computerHandEvaluator.HandValues.Total)
                {
                    Console.WriteLine("Player WINS!");
                }
                else if (playerHandEvaluator.HandValues.Total < computerHandEvaluator.HandValues.Total)
                {
                    Console.WriteLine("Computer WINS!");
                }
                // if both have the same poker hand (for example both have a pair of queens),
                //then the player with the next higher card wins
                else if (playerHandEvaluator.HandValues.HighCard > computerHandEvaluator.HandValues.HighCard)
                {
                    Console.WriteLine("Player WINS!");
                }
                else if (playerHandEvaluator.HandValues.HighCard < computerHandEvaluator.HandValues.HighCard)
                {
                    Console.WriteLine("Computer WINS!");
                }
                else
                {
                    Console.WriteLine("DRAW!!!, no one wins!");
                }
            }
        }
Ejemplo n.º 2
0
        private void EvaluateWinnigHand()
        {
            HandEvaluator playerHandEvaluator   = new HandEvaluator(sortedPlayerHand);
            HandEvaluator computerHandEvaluator = new HandEvaluator(sortedComputerHand);

            //get the player;s and computer's hand
            HandType playerHand   = playerHandEvaluator.EvaluateHand();
            HandType computerHand = computerHandEvaluator.EvaluateHand();

            //display each hand
            Console.WriteLine("\n\n\n\n\nPlayer's Hand: " + playerHand);
            Console.WriteLine("\nComputer's Hand: " + computerHand);

            //evaluate hands
            if (playerHand > computerHand)
            {
                Console.WriteLine("Player WINS!");
            }
            else if (playerHand < computerHand)
            {
                Console.WriteLine("Computer WINS!");
            }
            else //if the hands are the same, evaluate the values
            {
                //first evaluate who has higher value of poker hand
                if (playerHandEvaluator.HandValue.TotalValue > computerHandEvaluator.HandValue.TotalValue)
                {
                    Console.WriteLine("Player WINS!");
                }
                else if (playerHandEvaluator.HandValue.TotalValue < computerHandEvaluator.HandValue.TotalValue)
                {
                    Console.WriteLine("Computer WINS!");
                }
                //if both have the same poker hand (for example, both have a pair of queens),
                //than the player with the next higher card wins
                else if (playerHandEvaluator.HandValue.HighCardValue > computerHandEvaluator.HandValue.HighCardValue)
                {
                    Console.WriteLine("Player WINS!");
                }
                else if (playerHandEvaluator.HandValue.HighCardValue < computerHandEvaluator.HandValue.HighCardValue)
                {
                    Console.WriteLine("Computer WINS!");
                }
                else
                {
                    Console.WriteLine("DRAW, no one wins!");
                }
            }
        }
Ejemplo n.º 3
0
        public void EvaluateHands()
        {
            Console.ForegroundColor = ConsoleColor.White;

            HandEvaluator playerHandEval = new HandEvaluator(sortedPlayerHand);
            HandEvaluator cpuHandEval    = new HandEvaluator(sortedCpuHand);

            Hand playerHand = playerHandEval.EvaluateHand();
            Hand cpuHand    = cpuHandEval.EvaluateHand();

            Console.WriteLine("\n\nPlayer's Hand: " + playerHand);
            Console.WriteLine("CPU's Hand: " + cpuHand);

            if (playerHand > cpuHand)
            {
                Console.WriteLine("Player wins!");
            }
            else if (playerHand < cpuHand)
            {
                Console.WriteLine("Computer wins!");
            }
            else
            {
                if (playerHandEval.HandValues.Total > cpuHandEval.HandValues.Total)
                {
                    Console.WriteLine("Player wins!");
                }
                else if (playerHandEval.HandValues.Total < cpuHandEval.HandValues.Total)
                {
                    Console.WriteLine("Computer wins!");
                }
                else if (playerHandEval.HandValues.HighCard > cpuHandEval.HandValues.HighCard)
                {
                    Console.WriteLine("Player wins!");
                }
                else if (playerHandEval.HandValues.HighCard < cpuHandEval.HandValues.HighCard)
                {
                    Console.WriteLine("Computer wins!");
                }
                else
                {
                    Console.WriteLine("Draw!");
                }
            }

            Console.WriteLine();
        }
Ejemplo n.º 4
0
        private void EvaluateHands()
        {
            HandEvaluator playerHandEvaluator = new HandEvaluator(sortedPlayerHand);
            HandEvaluator computerHandEvaluator = new HandEvaluator(sortedComputerHand);

            Hand playerHand = playerHandEvaluator.EvaluateHand();
            Hand computerHand = computerHandEvaluator.EvaluateHand();

            Console.WriteLine("\n\n\n\n\nPlayer's Hand: " + playerHand);
            Console.WriteLine("\nComputer's Hand: " + computerHand);

            if (playerHand > computerHand)
            {
                Console.WriteLine("Player WINS!");
                playerWins++;
            }
            else if (playerHand < computerHand)
            {
                Console.WriteLine("Computer WINS!");
                computerWins++;
            }
            else
            {
                if (playerHandEvaluator.HandValues.Total > computerHandEvaluator.HandValues.Total)
                {
                    Console.WriteLine("Player WINS!");
                    playerWins++;
                }
                else if (playerHandEvaluator.HandValues.Total < computerHandEvaluator.HandValues.Total)
                {
                    Console.WriteLine("Computer WINS!");
                    computerWins++;
                }
                else if (playerHandEvaluator.HandValues.HighCard > computerHandEvaluator.HandValues.HighCard)
                {
                    Console.WriteLine("Player WINS!");
                    playerWins++;
                }
                else if (playerHandEvaluator.HandValues.HighCard < computerHandEvaluator.HandValues.HighCard)
                {
                    Console.WriteLine("Computer WINS!");
                    computerWins++;
                }
                else
                    Console.WriteLine("DRAW, no one wins!");
            }
        }