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); }
internal static bool IsFlushDraw(IEnumerable <Cards.Card> playerCards, BoardCards boardCards, int amountOfPlayersCardsInDraw, bool isBackdoor = false) { if (playerCards == null || boardCards == null || playerCards.Count() != 2 || boardCards.Count() < 3) { return(false); } var allCards = HandAnalyzerHelpers.CombineCardLists(playerCards, boardCards); var suitGroups = allCards.GroupBy(x => x.Suit); var drawGroup = suitGroups.FirstOrDefault(x => x.Count() == (isBackdoor ? 3 : 4)); if (drawGroup == null || suitGroups.Any(x => x.Count() > drawGroup.Count()) || playerCards.Count(x => drawGroup.Any(d => d.CardStringValue == x.CardStringValue)) != amountOfPlayersCardsInDraw) { return(false); } return(true); }
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 = 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); var nutCardSuit = flushBoardCards.First().Suit; var nutCardRank = Cards.Card.PossibleRanksHighCardFirst.First(); return(flushBoardCards.Any(x => x.Rank == nutCardRank && x.Suit == nutCardSuit)); } 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); } 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> straightDraw = new List <int>(); for (int i = 0; i < rankList.Count; i++) { if (!straightDraw.Any() || (rankList[i] == straightDraw.Last() + 1)) { straightDraw.Add(rankList[i]); continue; } if (straightDraw.Count == 3) { if (HandAnalyzerHelpers.IsStraight(straightDraw)) { if (rankList.Any(x => x == straightDraw.Max() + 2) && rankList.Any(x => x == straightDraw.Min() - 2)) { straightDraw.Add(straightDraw.Max() + 2); straightDraw.Add(straightDraw.Min() - 2); if (straightDraw.Contains(1)) { straightDraw[straightDraw.IndexOf(1)] = Cards.Card.GetRankNumericValue(Cards.Card.PossibleRanksHighCardFirst.First()); } if (playerCards.All(x => straightDraw.Contains(x.RankNumericValue))) { return(true); } } } } straightDraw.Clear(); straightDraw.Add(rankList[i]); } return(false); }
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); }
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); }
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); }
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); }
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); }
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 sortedCards = boardCards.OrderBy(x => x.RankNumericValue).Distinct().ToList(); if (sortedCards.Min(x => x.RankNumericValue) == Cards.Card.GetRankNumericValue("2")) { if (HandAnalyzerHelpers.IsStraight(sortedCards.Take(4)) && (sortedCards.Count == 4 || (sortedCards.Count > 4 && !HandAnalyzerHelpers.IsStraight(sortedCards.Take(5))))) { if (playerCards.Any(x => x.RankNumericValue == Cards.Card.GetRankNumericValue("6")) || sortedCards.Any(x => x.Rank == Cards.Card.PossibleRanksHighCardFirst.First())) { return(false); } return(playerCards.Any(x => x.Rank == Cards.Card.PossibleRanksHighCardFirst.First())); } } 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 == 4 && playerCards.Any(x => (sequence.Min() - x.RankNumericValue) == 1) && !playerCards.Any(x => (x.RankNumericValue - sequence.Max()) == 1)) { return(true); } sequence.Clear(); sequence.Add(sortedCards.ElementAt(i).RankNumericValue); } return(false); }
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))); }
public bool Analyze(IEnumerable <Cards.Card> playerCards, BoardCards boardCards) { if (playerCards == null || boardCards == null || playerCards.Count() != 2 || boardCards.Count() < 4) { return(false); } return(playerCards.Any(x => HandAnalyzerHelpers.IsOneCardStraight(x, boardCards) && HandAnalyzerHelpers.IsWeakKicker(x))); }
public bool Analyze(IEnumerable <HandHistories.Objects.Cards.Card> playerCards, BoardCards boardCards) { if (playerCards == null || boardCards == null || playerCards.Count() != 2 || boardCards.Count() < 4) { return(false); } return(playerCards.Any(x => HandAnalyzerHelpers.IsOneCardStraight(x, boardCards))); }
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 ten = Cards.Card.GetRankNumericValue("T"); var ace = Cards.Card.GetRankNumericValue("A"); var sortedBoardRanks = boardCards.Select(x => x.RankNumericValue).Where(x => x >= ten && x <= ace).Distinct().ToList(); sortedBoardRanks.Sort(); if (sortedBoardRanks.Count() == 4) { for (int i = ten; i <= ace; i++) { if (sortedBoardRanks.Contains(i)) { continue; } if (playerCards.Any(x => x.RankNumericValue == i)) { return(true); } else { return(false); } } } return(false); }
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); }
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() < 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) || 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); } if (playerCards.Any(p => boardCards.Any(b => b.RankNumericValue == p.RankNumericValue))) { return(false); } var rankList = HandAnalyzerHelpers.CombineCardLists(playerCards, boardCards).Where(x => x.Rank != Cards.Card.PossibleRanksHighCardFirst.First()).Select(x => x.RankNumericValue).Distinct().ToList(); rankList.Sort(); List <int> straightDraw = new List <int>(); for (int i = 0; i < rankList.Count; i++) { if (!straightDraw.Any() || (rankList[i] == straightDraw.Last() + 1)) { straightDraw.Add(rankList[i]); continue; } if (straightDraw.Count == 4) { if (HandAnalyzerHelpers.IsStraight(straightDraw) && playerCards.All(x => straightDraw.Contains(x.RankNumericValue))) { return(true); } } straightDraw.Clear(); straightDraw.Add(rankList[i]); } 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 <Cards.Card> playerCards, BoardCards boardCards) { if (playerCards == null || boardCards == null || playerCards.Count() != 2 || boardCards.Count() < 3) { return(true); } var result = !Hand.IsStraightDraw(string.Join("", playerCards), boardCards.ToString(), string.Empty); return(result); }
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); }
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); }
public 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.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) { return(boardCards.Any(x => x.RankNumericValue > pairs.Max(p => p.Max(m => m.RankNumericValue)))); } return(false); }
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); }
public 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.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); if (pairs != null && pairs.Count() > 1) { var bottomTwo = boardCards.OrderBy(x => x.RankNumericValue).Take(2).Distinct(); if (bottomTwo != null && bottomTwo.Count() == 2) { return(pairs.Take(2).All(p => bottomTwo.Any(t => t.RankNumericValue == p.Key)) && playerCards.All(x => bottomTwo.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() < 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) && HandAnalyzerHelpers.IsWeakKicker(x)) && playerCards.Any(x => !flushBoardCards.Any(f => f.CardStringValue == x.CardStringValue))) { 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() < 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); }
public bool Analyze(IEnumerable <Cards.Card> playerCards, BoardCards boardCards) { if (playerCards == null || boardCards == null || playerCards.Count() != 2 || boardCards.Count() < 3) { 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); return(HandAnalyzerHelpers.IsWeakKicker(flushBoardCards.OrderByDescending(x => x.RankNumericValue).First())); } return(false); }
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); }