Esempio n. 1
0
        public bool?IsBetterThanHand(SortedHand secondHand)
        // Compare the main hand and kicker hand of two hands of the same type (e.g. flush, pair, etc...)
        {
            for (int i = 0; i < MainHand.CardCount(); i++)
            {
                if (MainHand.GetCards()[i].Value > secondHand.MainHand.GetCards()[i].Value)
                {
                    return(true);
                }
                else if (MainHand.GetCards()[i].Value < secondHand.MainHand.GetCards()[i].Value)
                {
                    return(false);
                }
            }

            if (KickerHand != null)
            {
                for (int i = 0; i < KickerHand.CardCount(); i++)
                {
                    if (KickerHand.GetCards()[i].Value > secondHand.KickerHand.GetCards()[i].Value)
                    {
                        return(true);
                    }
                    else if (KickerHand.GetCards()[i].Value < secondHand.KickerHand.GetCards()[i].Value)
                    {
                        return(false);
                    }
                }
            }

            return(null);
        }
Esempio n. 2
0
        private SortedHand FindStraightFlush()
        {
            SortedHand flushHand = FindFlush();

            if (flushHand.MainHand == null)
            {
                return(new SortedHand());
            }
            else
            {
                return(flushHand.MainHand.FindStraight());
            }
        }
Esempio n. 3
0
        private SortedHand FindRoyalFlush()
        {
            SortedHand straightFlushHand = FindStraightFlush();

            if (straightFlushHand.MainHand == null)
            {
                return(new SortedHand());
            }
            else
            {
                if (straightFlushHand.MainHand.FindCardsByValue(14).CardCount() == 1)
                {
                    return(straightFlushHand);
                }
                else
                {
                    return(new SortedHand());
                }
            }
        }
Esempio n. 4
0
        public (SortedHand, HandType) FindBestHand()
        {
            var handCheckingMethods = new List <Func <SortedHand> > {
                FindRoyalFlush, FindStraightFlush, FindFour,
                FindFullHouse, FindFlush, FindStraight, FindTriple, FindTwoPair, FindPair, FindHighCard
            };

            SortedHand bestHand      = new SortedHand();
            int        handTypeIndex = 0;

            foreach (var method in handCheckingMethods)
            {
                bestHand = method();
                if (bestHand.MainHand != null)
                {
                    break;
                }
                handTypeIndex++;
            }

            return(bestHand, (HandType)handTypeIndex);
        }