public override bool Analyze(IEnumerable <HandHistories.Objects.Cards.Card> playerCards, BoardCards boardCards) { if (base.Analyze(playerCards, boardCards)) { var unpairedCard = HandAnalyzerHelpers.GetUnpairedCard(playerCards, boardCards); if (unpairedCard != null) { return(HandAnalyzerHelpers.IsWeakKicker(unpairedCard)); } } 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 <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 <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)); }
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() == 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 <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.Any(x => straightDraw.Contains(x.RankNumericValue)) && playerCards.Any(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() == 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 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); }
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 <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() < 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 <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) { return(false); } var pair = groupedCards.Where(x => x.Key != trips.Key).FirstOrDefault(x => x.Count() >= 2); if (pair != null) { return(playerCards.Any(x => x.RankNumericValue == trips.Key || x.RankNumericValue == pair.Key) && !playerCards.Any(x => x.RankNumericValue == trips.Key || x.RankNumericValue == pair.Key)); } 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 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); }
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); }
/// <summary> /// Tries to find royal flush in hand /// </summary> /// <param name="hand">Collection of card to find royal flush in</param> /// <returns>Roayl flush hand, or null if input collection doesn't contain it</returns> internal static IEnumerable <HandHistories.Objects.Cards.Card> GetRoyalFlushCards(IEnumerable <HandHistories.Objects.Cards.Card> hand) { var flushCards = hand.GroupBy(x => x.Suit).FirstOrDefault(x => x.Count() >= 5); string aceRank = HandHistories.Objects.Cards.Card.PossibleRanksHighCardFirst.First(); if (flushCards == null || !flushCards.Any(x => x.Rank == aceRank)) { return(null); } var flushCardsList = new List <HandHistories.Objects.Cards.Card>(flushCards); flushCardsList = flushCardsList.OrderByDescending(x => x.RankNumericValue).ToList(); var streetCards = flushCardsList.Take(5); if (HandAnalyzerHelpers.IsStraight(streetCards)) { return(streetCards); } return(null); }
public bool Analyze(IEnumerable <HandHistories.Objects.Cards.Card> playerCards, BoardCards boardCards) { if (playerCards == null || boardCards == null || playerCards.Count() != 2 || boardCards.Count() < 4) { return(false); } if (!HandAnalyzerHelpers.IsFlush(playerCards)) { return(false); } var sortedBoard = boardCards.OrderBy(x => x.RankNumericValue); for (int i = 0; i < sortedBoard.Count() - 4; i++) { var cards = sortedBoard.Take(4).ToList(); if (!HandAnalyzerHelpers.IsFlush(cards)) { return(false); } foreach (var card in playerCards) { var straightFlushCards = new List <Cards.Card>(cards); straightFlushCards.Add(card); if (HandAnalyzerHelpers.IsFlush(straightFlushCards) && HandAnalyzerHelpers.IsStraight(straightFlushCards, true)) { 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); } 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); }
/// <summary> /// Determines if it's possible to create straight using specified card /// </summary> /// <param name="playerCard"></param> /// <param name="boardCards"></param> /// <returns></returns> internal static bool IsOneCardStraight(Cards.Card playerCard, IEnumerable <Cards.Card> boardCards) { if (boardCards == null || boardCards.Count() < 4) { return(false); } var sortedBoardRanks = boardCards.Select(x => x.RankNumericValue).Distinct().ToList(); sortedBoardRanks.Sort(); if (sortedBoardRanks.Contains(Cards.Card.GetRankNumericValue(Cards.Card.PossibleRanksHighCardFirst.First()))) { sortedBoardRanks.Insert(0, 1); } if (sortedBoardRanks.Count < 4) { return(false); } for (int i = 0; i <= sortedBoardRanks.Count - 4; i++) { var curCards = sortedBoardRanks.Skip(i); if (curCards.Count() >= 4) { var list = new List <int>(curCards.Take(4)); list.Add(playerCard.RankNumericValue); if (HandAnalyzerHelpers.IsStraight(list) && !boardCards.Any(x => x.RankNumericValue == playerCard.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() == 0) { return(false); } 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)) && playerCards.Any(c => !royalFlushCards.Contains(c))) { return(true); } } return(false); }
public bool Analyze(IEnumerable <HandHistories.Objects.Cards.Card> playerCards, BoardCards boardCards) { return(HandAnalyzerHelpers.IsFlushDraw(playerCards, boardCards, 1, isBackdoor: true)); }
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() < 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() < 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() < 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 <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() < 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); }
public bool Analyze(IEnumerable <HandHistories.Objects.Cards.Card> playerCards, BoardCards boardCards) { return(!HandAnalyzerHelpers.IsFlushDraw(playerCards, boardCards, 0) && !HandAnalyzerHelpers.IsFlushDraw(playerCards, boardCards, 1) && !HandAnalyzerHelpers.IsFlushDraw(playerCards, boardCards, 2)); }