public override Maybe <Hand> IsMatch(IEnumerable <Card> cards) { ThrowIfDuplicate(cards); if (cards.Count() == 0) { return(Maybe <Hand> .None); } List <Card> highCards = HandHelper.GetHighCards(cards); return(CreateCopy <Hand>(highCards)); }
public override Maybe <Hand> IsMatch(IEnumerable <Card> cards) { ThrowIfDuplicate(cards); if (cards.Count() < 2) { return(Maybe <Hand> .None); } List <Card> pair = HandHelper.GetOfAKind(cards, 2); if (pair.Count != 2) { return(Maybe <Hand> .None); } List <Card> highCards = HandHelper.GetHighCards(cards, pair); List <Card> finalCards = new List <Card>(pair); finalCards.AddRange(highCards); return(CreateCopy <Hand>(finalCards)); }
public override Maybe <Hand> IsMatch(IEnumerable <Card> cards) { ThrowIfDuplicate(cards); if (cards.Count() < 5) { return(Maybe <Hand> .None); } List <Card> fourOfAKind = HandHelper.GetOfAKind(cards, 4); if (fourOfAKind.Count != 4) { return(Maybe <Hand> .None); } List <Card> highCards = HandHelper.GetHighCards(cards, fourOfAKind); List <Card> finalCards = new List <Card>(fourOfAKind); finalCards.Add(highCards.First()); return(CreateCopy <Hand>(finalCards)); }
public override Maybe <Hand> IsMatch(IEnumerable <Card> cards) { ThrowIfDuplicate(cards); if (cards.Count() < 5) { return(Maybe <Hand> .None); } List <Card> threeOfAKind = HandHelper.GetOfAKind(cards, 3); if (threeOfAKind.Count != 3) { return(Maybe <Hand> .None); } List <Card> highCards = HandHelper.GetHighCards(cards, threeOfAKind); List <Card> finalCards = new List <Card>(threeOfAKind); finalCards.AddRange(highCards); return(CreateCopy <Hand>(finalCards)); }