public static bool isStraight(List <Card> availableCards) { Suit suit = StraightHelpers.getRelevantSuit(availableCards); HashSet <Card> cards = StraightHelpers.removePairs(availableCards, suit); if (cards.Count < 5) { return(false); } int highDist = cards.Max(c => c.highValue) - cards.Min(c => c.highValue); int lowDist = cards.Max(c => c.lowValue) - cards.Min(c => c.lowValue); return(highDist == 4 || lowDist == 4 ? true : false); }
private void analyzeStraights(bool checkDraws = false) { Suit suit = StraightHelpers.getRelevantSuit(this.availableCards); HashSet <Card> cards = StraightHelpers.removePairs(this.availableCards, suit); HashSet <CardType> types = new HashSet <CardType>(); foreach (Card c in cards) { types.Add(c.type); } var straightOuts = new List <Card>(); var backdoorOuts = new List <Card>(); foreach (Straight s in Data.getStraights().Values) { HashSet <CardType> valueTypes = new HashSet <CardType>(); foreach (Card c in s.cards) { valueTypes.Add(c.type); } ; valueTypes.IntersectWith(types); if (valueTypes.Count == 5) { var straightCards = Enumerable.Where(cards, c => types.Contains(c.type)).ToList(); var straight = new Straight(straightCards); if (this.bestStraight is null || straight.value > this.bestStraight.value) { this.bestStraight = straight; this.straights.Add(straight); } else { if (!this.straights.Contains(straight)) { this.straights.Add(straight); } } }