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

            if (!HandAnalyzerHelpers.IsPair(playerCards, 1))
            {
                return(false);
            }

            var allCards = boardCards.ToList();

            allCards.AddRange(playerCards);

            var pairs = allCards.GroupBy(x => x.RankNumericValue).Where(x => x.Count() == 2);

            if (pairs != null && pairs.Count() > 1)
            {
                return(playerCards.First().RankNumericValue > boardCards.Max(x => x.RankNumericValue));
            }

            return(false);
        }
Esempio n. 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.IsPair(playerCards, 1))
            {
                return(false);
            }

            var allCards = HandAnalyzerHelpers.CombineCardLists(playerCards, boardCards);

            if (HandAnalyzerHelpers.IsNofKind(allCards, 4))
            {
                return(false);
            }

            var groupedCards = allCards.GroupBy(x => x.RankNumericValue).OrderByDescending(x => x.Key);

            var trips = groupedCards.FirstOrDefault(x => x.Count() == 3);

            if (trips != null)
            {
                var pair = groupedCards.Where(x => x.Key != trips.Key).FirstOrDefault(x => x.Count() >= 2);
                if (pair != null && pair.Key == playerCards.First().RankNumericValue)
                {
                    return(true);
                }
            }

            return(false);
        }
        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(allCards, 3))
            {
                return(false);
            }

            var flopCards = boardCards.GetBoardOnStreet(Street.Flop);
            var flopPair  = boardCards.GroupBy(x => x.Rank).FirstOrDefault(x => x.Count() == 2);

            if (flopPair != null)
            {
                return(flopPair.Any(f => playerCards.Any(p => p.CardIntValue == f.CardIntValue)));
            }

            return(false);
        }
        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);
            }

            var secondSetCard = boardCards.OrderByDescending(x => x.RankNumericValue).ElementAt(1);

            if (boardCards.Count(x => x.RankNumericValue == secondSetCard.RankNumericValue) == 2 &&
                playerCards.Any(x => x.RankNumericValue == secondSetCard.RankNumericValue))
            {
                var kicker = playerCards.FirstOrDefault(p => !boardCards.Any(b => b.Rank == p.Rank));
                if (kicker != null)
                {
                    return(HandAnalyzerHelpers.IsWeakKicker(kicker));
                }
            }

            return(false);
        }
        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(allCards, 3) || HandAnalyzerHelpers.IsNofKind(boardCards, 3))
            {
                return(false);
            }

            var kicker = playerCards.FirstOrDefault(p => !boardCards.Any(b => b.Rank == p.Rank));

            if (kicker != null)
            {
                return(HandAnalyzerHelpers.IsWeakKicker(kicker));
            }

            return(false);
        }
        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);
        }
        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(allCards, 3))
            {
                return(false);
            }

            var bottomBoardCardRank = boardCards.Min(x => x.RankNumericValue);

            if (playerCards.Any(x => x.RankNumericValue == bottomBoardCardRank))
            {
                return(true);
            }

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

            if (HandAnalyzerHelpers.IsPair(playerCards, 1))
            {
                return(false);
            }

            var allCards = HandAnalyzerHelpers.CombineCardLists(boardCards, playerCards);

            if (HandAnalyzerHelpers.IsNofKind(allCards, 3) || HandAnalyzerHelpers.IsNofKind(allCards, 4))
            {
                return(false);
            }

            var topTwo = boardCards.OrderByDescending(x => x.RankNumericValue).Take(2).Distinct();

            if (topTwo != null && topTwo.Count() == 2)
            {
                return(playerCards.All(x => topTwo.Any(t => t.RankNumericValue == x.RankNumericValue)));
            }

            return(false);
        }
        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(allCards, 3))
            {
                return(false);
            }

            var secondBoardCardRank = boardCards.OrderByDescending(x => x.RankNumericValue).ElementAt(1).RankNumericValue;

            if (playerCards.Any(x => x.RankNumericValue == secondBoardCardRank))
            {
                return(true);
            }

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

            if (HandAnalyzerHelpers.IsPair(playerCards, 1))
            {
                return(false);
            }

            var allCards = HandAnalyzerHelpers.CombineCardLists(boardCards, playerCards);

            if (HandAnalyzerHelpers.IsNofKind(allCards, 3) || HandAnalyzerHelpers.IsNofKind(allCards, 4))
            {
                return(false);
            }

            var pairs = allCards.GroupBy(x => x.RankNumericValue).Where(x => x.Count() == 2);

            if (pairs != null && pairs.Count() > 1)
            {
                var bottomPair = boardCards.Min(x => x.RankNumericValue);
                return(pairs.ElementAt(1).Key == bottomPair &&
                       playerCards.Any(x => x.RankNumericValue == bottomPair) &&
                       !playerCards.Any(x => pairs.First().Key == x.RankNumericValue));
            }

            return(false);
        }
Esempio n. 11
0
        public virtual bool Analyze(IEnumerable <HandHistories.Objects.Cards.Card> playerCards, BoardCards boardCards)
        {
            if (boardCards == null || boardCards.Count == 0)
            {
                return(false);
            }

            return(!HandAnalyzerHelpers.IsPair(playerCards, 1) &&
                   !playerCards.Any(p => boardCards.Any(b => b.Rank == p.Rank)) &&
                   HandAnalyzerHelpers.IsPair(boardCards, 1));
        }
Esempio n. 12
0
        public bool Analyze(IEnumerable <Cards.Card> playerCards, BoardCards boardCards)
        {
            if (playerCards == null || boardCards == null || playerCards.Count() != 2 || boardCards.Count() == 0)
            {
                return(false);
            }

            if (!HandAnalyzerHelpers.IsPair(playerCards, 1))
            {
                return(false);
            }

            return(boardCards.GroupBy(x => x.Rank).Any(g => (g.Count() == 2) && (g.Key == playerCards.First().Rank)));
        }
Esempio n. 13
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);
            }

            var allCards = HandAnalyzerHelpers.CombineCardLists(boardCards, playerCards);

            if (HandAnalyzerHelpers.IsPair(playerCards, 1) && HandAnalyzerHelpers.IsPair(allCards, 1))
            {
                if (boardCards.All(x => x.RankNumericValue < playerCards.First().RankNumericValue))
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 14
0
        public bool Analyze(IEnumerable <HandHistories.Objects.Cards.Card> playerCards, BoardCards boardCards)
        {
            if (boardCards == null || playerCards == null || playerCards.Count() == 0 || boardCards.Count == 0)
            {
                return(false);
            }

            var allCards = HandAnalyzerHelpers.CombineCardLists(boardCards, playerCards);

            if (HandAnalyzerHelpers.IsNofKind(allCards, 3) || HandAnalyzerHelpers.IsNofKind(allCards, 4))
            {
                return(false);
            }

            return(!HandAnalyzerHelpers.IsPair(playerCards, 1) &&
                   !playerCards.Any(p => boardCards.Any(b => b.Rank == p.Rank)) &&
                   HandAnalyzerHelpers.IsPair(boardCards, 2));
        }
Esempio n. 15
0
        public virtual bool Analyze(IEnumerable <HandHistories.Objects.Cards.Card> playerCards, BoardCards boardCards)
        {
            if (playerCards == null || boardCards == null || playerCards.Count() != 2 || boardCards.Count() == 0)
            {
                return(false);
            }

            var allCards = HandAnalyzerHelpers.CombineCardLists(boardCards, playerCards);

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

            if (playerCards.Any(c => c.RankNumericValue == boardCards.Min(x => x.RankNumericValue)))
            {
                return(true);
            }

            return(false);
        }
Esempio n. 16
0
        public virtual bool Analyze(IEnumerable <HandHistories.Objects.Cards.Card> playerCards, BoardCards boardCards)
        {
            if (playerCards == null || boardCards == null)
            {
                return(false);
            }

            var allCards = boardCards.ToList();

            allCards.AddRange(playerCards);

            if (!HandAnalyzerHelpers.IsPair(allCards, 1) && !HandAnalyzerHelpers.IsPair(allCards, 2) && !HandAnalyzerHelpers.IsNofKind(allCards, 3) && !HandAnalyzerHelpers.IsNofKind(allCards, 4))
            {
                if (!allCards.GroupBy(x => x.Suit).Any(x => x.Count() >= 5))
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 17
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.IsPair(playerCards, 1))
            {
                return(false);
            }

            var trips = boardCards.GroupBy(x => x.Rank).FirstOrDefault(x => x.Count() == 3);

            if (trips != null)
            {
                return(playerCards.Any(x => x.Rank == trips.Key));
            }


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

            if (HandAnalyzerHelpers.IsPair(playerCards, 1))
            {
                return(false);
            }

            var allCards = HandAnalyzerHelpers.CombineCardLists(boardCards, playerCards);

            if (HandAnalyzerHelpers.IsNofKind(allCards, 3) || HandAnalyzerHelpers.IsNofKind(allCards, 4))
            {
                return(false);
            }

            var pairs       = allCards.GroupBy(x => x.RankNumericValue).OrderByDescending(x => x.Key).Where(x => x.Count() == 2);
            var sortedBoard = boardCards.OrderBy(x => x.RankNumericValue);

            if (pairs != null && pairs.Count() > 1 && sortedBoard != null && sortedBoard.Count() >= 2)
            {
                pairs = pairs.Take(2);
                var bottomTwo = boardCards.OrderBy(x => x.RankNumericValue).Take(2).Distinct();

                if (bottomTwo != null && bottomTwo.Count() == 2)
                {
                    return(pairs.Any(x => x.Key == sortedBoard.First().RankNumericValue) &&
                           pairs.Any(x => x.Key == sortedBoard.Last().RankNumericValue) &&
                           playerCards.Any(x => x.RankNumericValue == sortedBoard.First().RankNumericValue) &&
                           playerCards.Any(x => x.RankNumericValue == sortedBoard.Last().RankNumericValue));
                }
            }

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

            var allCards = HandAnalyzerHelpers.CombineCardLists(boardCards, playerCards);

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

            var thirdCardRank = boardCards.OrderByDescending(x => x.RankNumericValue).ElementAt(2).RankNumericValue;

            if (playerCards.Any(c => c.RankNumericValue == thirdCardRank))
            {
                return(true);
            }

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

            if (playerCards.Any(p => boardCards.Any(b => b.RankNumericValue == p.RankNumericValue)) || HandAnalyzerHelpers.IsPair(playerCards, 1))
            {
                return(false);
            }

            var sortedBoard = boardCards.OrderBy(x => x.RankNumericValue);

            for (int i = sortedBoard.Count() - 1; i >= 2; i--)
            {
                var curCards = sortedBoard.Skip(i - 2);
                if (curCards.Count() >= 3)
                {
                    curCards = curCards.Take(3);
                    var nutStraight = GetNutStraightForCards(curCards);
                    if (nutStraight != null)
                    {
                        var requiredPocketCards = nutStraight.Where(x => !curCards.Any(c => c.RankNumericValue == x));
                        if (playerCards.All(x => requiredPocketCards.Contains(x.RankNumericValue)))
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
            }

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

            if (HandAnalyzerHelpers.IsPair(playerCards, 1))
            {
                return(false);
            }

            if (playerCards.Any(p => boardCards.Any(b => b.RankNumericValue == p.RankNumericValue)))
            {
                return(false);
            }

            var allCards = HandAnalyzerHelpers.CombineCardLists(playerCards, boardCards);
            var rankList = allCards.Select(x => x.RankNumericValue).Distinct().ToList();

            if (allCards.Any(x => x.Rank == Cards.Card.PossibleRanksHighCardFirst.First()))
            {
                rankList.Add(1);
            }
            rankList.Sort();

            List <int> currentSequence  = new List <int>();
            List <int> previousSequence = new List <int>();

            for (int i = 0; i < rankList.Count; i++)
            {
                if (!currentSequence.Any() || (rankList[i] == currentSequence.Last() + 1))
                {
                    currentSequence.Add(rankList[i]);
                    continue;
                }

                if (currentSequence.Count >= 1 && currentSequence.Count <= 3)
                {
                    if (!previousSequence.Any())
                    {
                        previousSequence = new List <int>(currentSequence);
                    }
                    else if (currentSequence.Min() - previousSequence.Max() > 3)
                    {
                        if (previousSequence.Count() == 3)
                        {
                            if (previousSequence.Contains(1))
                            {
                                previousSequence[previousSequence.IndexOf(1)] = Cards.Card.GetRankNumericValue(Cards.Card.PossibleRanksHighCardFirst.First());
                            }

                            if (playerCards.All(x => previousSequence.Contains(x.RankNumericValue)))
                            {
                                return(true);
                            }
                        }
                    }
                    else if ((previousSequence.Count + currentSequence.Count) == 3)
                    {
                        if (HandAnalyzerHelpers.IsStraight(currentSequence) &&
                            HandAnalyzerHelpers.IsStraight(previousSequence))
                        {
                            if (previousSequence.Contains(1))
                            {
                                previousSequence[previousSequence.IndexOf(1)] = Cards.Card.GetRankNumericValue(Cards.Card.PossibleRanksHighCardFirst.First());
                            }

                            if (playerCards.All(p => currentSequence.Contains(p.RankNumericValue) || previousSequence.Contains(p.RankNumericValue)))
                            {
                                return(true);
                            }
                        }
                    }
                }

                previousSequence = new List <int>(currentSequence);
                currentSequence.Clear();
                currentSequence.Add(rankList[i]);
            }

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

            if (playerCards.Any(p => boardCards.Any(b => b.RankNumericValue == p.RankNumericValue)) || HandAnalyzerHelpers.IsPair(playerCards, 1))
            {
                return(false);
            }

            var sortedBoard = boardCards.OrderBy(x => x.RankNumericValue).ToList();

            if (sortedBoard.Any(x => x.Rank == Cards.Card.PossibleRanksHighCardFirst.First()) &&
                sortedBoard.Any(x => x.Rank == Cards.Card.PossibleRanksHighCardFirst.Last()))
            {
                sortedBoard.Insert(0, new Cards.Card("A", "c"));
            }

            for (int i = sortedBoard.Count() - 1; i >= 2; i--)
            {
                var curCards = sortedBoard.Skip(i - 2).ToList();
                if (curCards.Count() >= 3)
                {
                    curCards.AddRange(playerCards);
                    curCards = curCards.OrderByDescending(x => x.RankNumericValue).Take(5).ToList();
                    if (HandAnalyzerHelpers.IsStraight(curCards, true))
                    {
                        return(playerCards.All(p => curCards.Any(c => c.RankNumericValue == p.RankNumericValue)));
                    }
                }
            }

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

            if (!HandAnalyzerHelpers.IsStraight(playerCards, true) || playerCards.Any(p => boardCards.Any(b => b.RankNumericValue == p.RankNumericValue)) || HandAnalyzerHelpers.IsPair(playerCards, 1))
            {
                return(false);
            }


            var sortedCards = boardCards.OrderBy(x => x.RankNumericValue).Distinct().ToList();

            if (sortedCards.Min(x => x.RankNumericValue) == Cards.Card.GetRankNumericValue("3"))
            {
                if (HandAnalyzerHelpers.IsStraight(sortedCards.Take(3)) &&
                    (boardCards.Count == 3 || (boardCards.Count > 3 && !HandAnalyzerHelpers.IsStraight(sortedCards.Take(4)))))
                {
                    if (sortedCards.Any(x => x.Rank == Cards.Card.PossibleRanksHighCardFirst.First()))
                    {
                        return(false);
                    }

                    return(playerCards.Any(x => x.Rank == Cards.Card.PossibleRanksHighCardFirst.First()) &&
                           playerCards.Any(x => x.Rank == Cards.Card.PossibleRanksHighCardFirst.Last()));
                }
            }

            List <int> sequence = new List <int>();

            for (int i = sortedCards.Count - 1; i >= 0; i--)
            {
                if (!sequence.Any() || sequence.Min() - sortedCards.ElementAt(i).RankNumericValue == 1)
                {
                    sequence.Add(sortedCards.ElementAt(i).RankNumericValue);
                    if (i != 0)
                    {
                        continue;
                    }
                }

                if (sequence.Count == 3 && (sequence.Min() > playerCards.Max(x => x.RankNumericValue)))
                {
                    if (HandAnalyzerHelpers.IsStraight(sequence.Union(playerCards.Select(x => x.RankNumericValue))))
                    {
                        return(true);
                    }
                }

                sequence.Clear();
                sequence.Add(sortedCards.ElementAt(i).RankNumericValue);
            }

            return(false);
        }