Пример #1
0
        internal static int CompareTwoStraightFlushHands(IHand firstHand, IHand secondHand)
        {
            if (checker.IsStraightFlush(firstHand) && !checker.IsStraightFlush(secondHand))
            {
                return(1);
            }
            else if (!checker.IsStraightFlush(firstHand) && checker.IsStraightFlush(secondHand))
            {
                return(-1);
            }

            List <ICard> firstHandCards  = (List <ICard>)firstHand.Cards;
            List <ICard> secondHandCards = (List <ICard>)secondHand.Cards;

            PokerHandsChecker.SortCardsByFace(firstHandCards);
            PokerHandsChecker.SortCardsByFace(secondHandCards);

            int valueLastCardFromFirstHand  = (int)firstHandCards[firstHandCards.Count - 1].Face;
            int valueLastCardFromSecondHand = (int)secondHandCards[secondHandCards.Count - 1].Face;

            if (valueLastCardFromFirstHand > valueLastCardFromSecondHand)
            {
                return(1);
            }
            else if (valueLastCardFromFirstHand < valueLastCardFromSecondHand)
            {
                return(-1);
            }
            else
            {
                return(0);
            }
        }
Пример #2
0
        internal static int CompareTwoFlushHands(IHand firstHand, IHand secondHand)
        {
            if (checker.IsFlush(firstHand) && !checker.IsFlush(secondHand))
            {
                return(1);
            }
            else if (!checker.IsFlush(firstHand) && checker.IsFlush(secondHand))
            {
                return(-1);
            }

            var firstHandSortedCards  = firstHand.Cards;
            var secondHandSortedCards = secondHand.Cards;

            PokerHandsChecker.SortCardsByFace(firstHandSortedCards);
            PokerHandsChecker.SortCardsByFace(secondHandSortedCards);

            for (int i = firstHandSortedCards.Count - 1; i >= 0; i--)
            {
                if ((int)firstHandSortedCards[i].Face > (int)secondHandSortedCards[i].Face)
                {
                    return(1);
                }
                else if ((int)firstHandSortedCards[i].Face < (int)secondHandSortedCards[i].Face)
                {
                    return(-1);
                }
            }

            return(0);
        }
Пример #3
0
        internal static int CompareTwoStraightHands(IHand firstHand, IHand secondHand)
        {
            if (checker.IsStraight(firstHand) && checker.IsStraight(secondHand))
            {
                return(1);
            }
            else if (checker.IsStraight(firstHand) && checker.IsStraight(secondHand))
            {
                return(-1);
            }

            var firstHandSortedCards  = firstHand.Cards;
            var secondHandSortedCards = secondHand.Cards;

            PokerHandsChecker.SortCardsByFace(firstHandSortedCards);
            PokerHandsChecker.SortCardsByFace(secondHandSortedCards);

            int biggestCardFirstHand  = (int)firstHandSortedCards[firstHandSortedCards.Count - 1].Face;
            int biggestCardSecondHand = (int)secondHandSortedCards[secondHandSortedCards.Count - 1].Face;

            if (biggestCardFirstHand > biggestCardSecondHand)
            {
                return(1);
            }
            else if (biggestCardFirstHand < biggestCardSecondHand)
            {
                return(-1);
            }
            else
            {
                return(0);
            }
        }