public bool Analyze(IEnumerable <HandHistories.Objects.Cards.Card> playerCards, BoardCards boardCards)
        {
            if (playerCards == null || boardCards == null || playerCards.Count() != 2 || boardCards.Count() < 3)
            {
                return(false);
            }

            var allCards = boardCards.ToList();

            allCards.AddRange(playerCards);

            if (HandAnalyzerHelpers.IsPair(playerCards, 1) || HandAnalyzerHelpers.IsNofKind(boardCards, 3) || !HandAnalyzerHelpers.IsNofKind(allCards, 3))
            {
                return(false);
            }

            bool isThreeOfAKind = boardCards.Where(x => x.RankNumericValue == playerCards.ElementAt(0).RankNumericValue).Count() == 2 ||
                                  boardCards.Where(x => x.RankNumericValue == playerCards.ElementAt(1).RankNumericValue).Count() == 2;

            if (isThreeOfAKind)
            {
                var kicker = playerCards.FirstOrDefault(p => !boardCards.Any(b => b.Rank == p.Rank));
                if (kicker != null)
                {
                    return(HandAnalyzerHelpers.IsDecentKicker(kicker));
                }
            }

            return(false);
        }
Example #2
0
        public bool Analyze(IEnumerable <HandHistories.Objects.Cards.Card> playerCards, BoardCards boardCards)
        {
            if (playerCards == null || boardCards == null || playerCards.Count() != 2 || boardCards.Count() == 0)
            {
                return(false);
            }

            if (HandAnalyzerHelpers.IsFlush(playerCards))
            {
                var allCards  = new List <HandHistories.Objects.Cards.Card>(playerCards);
                var boardCopy = new List <HandHistories.Objects.Cards.Card>(boardCards.Where(x => x.Suit == allCards.First().Suit));
                allCards.AddRange(boardCopy);

                var royalFlushCards = HandAnalyzerHelpers.GetRoyalFlushCards(allCards);
                if (royalFlushCards != null)
                {
                    if (!playerCards.Any(c => !royalFlushCards.Contains(c)))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #3
0
        public bool Analyze(IEnumerable <Cards.Card> playerCards, BoardCards boardCards)
        {
            if (boardCards == null || boardCards.Count != 5)
            {
                return(false);
            }

            if (HandAnalyzerHelpers.IsStraight(boardCards, true))
            {
                if (boardCards.Any(x => x.Rank == Cards.Card.PossibleRanksHighCardFirst.First()) && boardCards.Any(x => x.Rank == Cards.Card.PossibleRanksHighCardFirst.Last()))
                {
                    return(!playerCards.Any(x => x.RankNumericValue == (boardCards
                                                                        .Where(b => b.Rank != Cards.Card.PossibleRanksHighCardFirst.First())
                                                                        .Max(m => m.RankNumericValue) + 1)));
                }
                else
                {
                    return(!playerCards.Any(x => x.RankNumericValue == (boardCards.Max(m => m.RankNumericValue) + 1)));
                }
            }

            return(false);
        }
Example #4
0
        public bool Analyze(IEnumerable <HandHistories.Objects.Cards.Card> playerCards, BoardCards boardCards)
        {
            if (playerCards == null || boardCards == null || playerCards.Count() != 2 || boardCards.Count() < 4)
            {
                return(false);
            }

            var allCards = new List <Cards.Card>(playerCards);

            allCards.AddRange(boardCards);

            var suitGroup = allCards.GroupBy(x => x.Suit);

            if (suitGroup.Any(g => g.Count() >= 5))
            {
                var flushBoardCards = suitGroup.Where(g => g.Count() >= 5).First().OrderByDescending(x => x.RankNumericValue).Take(5);
                if (playerCards.Any(x => flushBoardCards.Any(f => f.CardStringValue == x.CardStringValue)) &&
                    playerCards.Any(x => !flushBoardCards.Any(f => f.CardStringValue == x.CardStringValue)))
                {
                    var nutCardSuit = flushBoardCards.First().Suit;
                    var nutCardRank = Cards.Card.PossibleRanksHighCardFirst.First(rank => !boardCards.Where(b => b.Suit == nutCardSuit).Any(b => b.Rank == rank));
                    return(playerCards.Any(x => x.Rank == nutCardRank && x.Suit == nutCardSuit));
                }
            }
            return(false);
        }
Example #5
0
        public bool Analyze(IEnumerable <HandHistories.Objects.Cards.Card> playerCards, BoardCards boardCards)
        {
            if (!HandAnalyzerHelpers.IsFlushDraw(playerCards, boardCards, 1))
            {
                return(false);
            }

            var drawSuit = boardCards.GroupBy(x => x.Suit).FirstOrDefault(x => x.Count() == 3).Key;

            return((drawSuit != null) && HandAnalyzerHelpers.IsTopKicker(playerCards.OrderByDescending(x => x.RankNumericValue).First(x => x.Suit == drawSuit), boardCards.Where(b => b.Suit == drawSuit)));
        }
Example #6
0
        public bool Analyze(IEnumerable <HandHistories.Objects.Cards.Card> playerCards, BoardCards boardCards)
        {
            if (!HandAnalyzerHelpers.IsFlushDraw(playerCards, boardCards, 2, isBackdoor: true))
            {
                return(false);
            }

            return(HandAnalyzerHelpers.IsTopKicker(playerCards.OrderByDescending(x => x.RankNumericValue).First(), boardCards.Where(b => b.Suit == playerCards.First().Suit)));
        }