public static Flush TryGetFlush(Card[] cards)
 {
     var first = cards.First();
     return cards.Skip(1).All(c => c.Suit == first.Suit)
             ? new Flush(cards.Select(c => c.CardNomination).ToArray())
             : null;
 }
 public static Flush TryGetFlush(Card[] cards)
 {
     return cards.Skip(1).Aggregate(
         new {Flush = true, cards.First().Suit},
         (acc, card) => new { Flush = acc.Flush && acc.Suit == card.Suit, card.Suit }
         ).Flush
             ? new Flush(cards.Select(c => c.CardNomination).ToArray())
             : null;
 }
 public static Straight TryGetStraight(Card[] cards)
 {
     var first = cards.First();
     return cards.Skip(1).Aggregate(new {IsStraight = true, Card = first}, (acc, card) => new
         {
             IsStraight = acc.IsStraight && acc.Card.CardNomination.Value - card.CardNomination.Value == 1, Card = card
         }).IsStraight
                 ? new Straight(first.CardNomination)
                 // A,5,4,3,2
                 : cards.Select(c => c.CardNomination)
                     .Except(new CardNomination[] { new MajorCardNomination(MajorCardType.Ace), new MinorCardNomination(5), new MinorCardNomination(4), new MinorCardNomination(3), new MinorCardNomination(2) }).Any()
                         ? null
                         : new Straight(new MinorCardNomination(5));
 }
 private static Hand GetHand(Card[] cardSet)
 {
     return
         new Hand(CombinationFactory.TryGetRoyalFlush(cardSet))
             .Or(() => new Hand(CombinationFactory.TryGetStraightFlush(cardSet)))
             .Or(()=> CreateHand(CombinationFactory.TryGetFourOfAKind(cardSet)))
             .Or(() => new Hand(CombinationFactory.TryGetFullHouse(cardSet)))
             .Or(() => new Hand(CombinationFactory.TryGetFlush(cardSet)))
             .Or(() => new Hand(CombinationFactory.TryGetStraight(cardSet)))
             .Or(() => CreateHand(CombinationFactory.TryGetThreeOfAKind(cardSet)))
             .Or(() => CreateHand(CombinationFactory.TryGetTwoPairs(cardSet)))
             .Or(() => CreateHand(CombinationFactory.TryGetPair(cardSet)))
             .Or(() => new Hand(null, new OddCards(cardSet.Select(c => c.CardNomination).ToArray())));
 }