public Hand GetRandomStraightOrStraightFlush5(int numCardsDealt, int numCardsInFinalHand, bool doRequireFlush) { Ranker ranker = new Ranker(numCardsInFinalHand, false); Hand hand; FullRank fRank; TSuit flushSuit = GetRandomSuit(); HandCard[] hcsRank; HandCard[] hcsFill; do { TValue maxValue = (TValue)random.Next((int)TValue.Six, (int)TValue.Ace); TValue minValue = maxValue.Prev(4); Card[] chosen = Enumerable.Range((int)minValue, ((int)maxValue - (int)minValue) + 1) .Select(k => doRequireFlush ? (new Card((TValue)k, flushSuit)) : GetRandomCardWithValue((TValue)k)) .Reverse().ToArray(); Card[] fill = GetRandomCards(numCardsDealt - 5).ToArray(); hand = new Hand(fill.Concat(chosen)); ranker.GetFullRank(hand, null, out fRank, out hcsRank, out hcsFill); } while (fRank.SRank > (doRequireFlush ? SimpleRank.StraightFlush5 : SimpleRank.Straight5)); return(hand); }