Ejemplo n.º 1
0
        public string CompareHands()
        {
            var result = CheckForStraightFlush();

            if (result != Constants.NO_RESULT)
            {
                return(result);
            }

            result = CheckFor4OfaKind();
            if (result != Constants.NO_RESULT)
            {
                return(result);
            }

            result = CheckForAFullHouse();
            if (result != Constants.NO_RESULT)
            {
                return(result);
            }

            result = CheckForAFlush();
            if (result != Constants.NO_RESULT)
            {
                return(result);
            }

            result = CheckForAStraight();
            if (result != Constants.NO_RESULT)
            {
                return(result);
            }

            result = CheckForTrips();
            if (result != Constants.NO_RESULT)
            {
                return(result);
            }

            result = CheckForTwoPairs();
            if (result != Constants.NO_RESULT)
            {
                return(result);
            }

            result = CheckForPair();
            if (result != Constants.NO_RESULT)
            {
                return(result);
            }

            var highCardFirstPlayer  = evaluator.HighestRankAceIsHigh(firstPlayerCards);
            var highCardSecondPlayer = evaluator.HighestRankAceIsHigh(secondPlayerCards);

            if (highCardFirstPlayer > highCardSecondPlayer)
            {
                return(string.Format("{0} wins - high card", firstPlayerName));
            }
            return(highCardFirstPlayer < highCardSecondPlayer?string.Format("{0} wins - high card", secondPlayerName) : "Tie");
        }