public override IEnumerable <CardCombination> DetectCombinations(ISet <Card> cards) { var onePairDetector = new OnePairCombinationDetector(); var setDetector = new SetCombinationDetector(); var onePairCombinations = onePairDetector.DetectCombinations(cards).OfType <OnePairCombination>(); var setCombinations = setDetector.DetectCombinations(cards).OfType <SetCombination>(); foreach (var onePair in onePairCombinations) { foreach (var set in setCombinations) { if (!AllCardsAreUnique(onePair, set)) { continue; } yield return(new FullHouseCombination(setCards: set.Cards, pairCards: onePair.Cards)); } } }
public override IEnumerable <CardCombination> DetectCombinations(ISet <Card> cards) { var onePairDetector = new OnePairCombinationDetector(); var onePairCombinations = onePairDetector.DetectCombinations(cards).OfType <OnePairCombination>().ToList(); foreach (var pair1 in onePairCombinations) { foreach (var pair2 in onePairCombinations) { if (ReferenceEquals(pair1, pair2)) { continue; } bool allCardsAreUnique = AllCardsAreUnique(pair1, pair2); if (allCardsAreUnique) { yield return(new TwoPairsCombination(pair1.Cards.Concat(pair2.Cards))); } } } }