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); } 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 override bool Analyze(IEnumerable <HandHistories.Objects.Cards.Card> playerCards, BoardCards boardCards) { if (base.Analyze(playerCards, boardCards)) { return(!boardCards.Any(x => x.RankNumericValue <= playerCards.First().RankNumericValue)); } return(false); }
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)); }
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)); }
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)) { if (boardCards.Any(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 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); }
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 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); }
public bool Analyze(IEnumerable <HandHistories.Objects.Cards.Card> playerCards, BoardCards boardCards) { if (boardCards == null || boardCards.Count() == 0) { return(false); } if (HandAnalyzerHelpers.IsFlush(boardCards) && HandAnalyzerHelpers.IsStraight(boardCards) && boardCards.Any(x => x.Rank == HandHistories.Objects.Cards.Card.PossibleRanksHighCardFirst.First())) { 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 (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); }