public static int GetScore(PokerCard firstCard, PokerCard secondCard, IList <PokerCard> boardCards) { var hand = CurrentHandService.GetHand(firstCard, secondCard, boardCards); switch (hand) { case Hand.RoyalFlush: return(RoyalFlush); case Hand.StraightFlush: return(StraightFlush); case Hand.FourOfKind: return(Foursome); case Hand.FullHouse: return(FullHouse); case Hand.Flush: return(Flush); case Hand.Straight: return(Straight); case Hand.ThreeOfAKind: return(Threesome); case Hand.TwoPair: return(TwoPair); case Hand.OnePair: return(OnePair); case Hand.HighCard: return(SumCardRanks(firstCard, secondCard)); default: return(SumCardRanks(firstCard, secondCard)); } }
public static int GetScore(IList <PokerCard> cards) { var hand = CurrentHandService.GetHand(cards); switch (hand) { case Hand.RoyalFlush: return(RoyalFlush); case Hand.StraightFlush: return(StraightFlush); case Hand.FourOfKind: return(Foursome); case Hand.FullHouse: return(FullHouse); case Hand.Flush: return(Flush); case Hand.Straight: return(Straight); case Hand.ThreeOfAKind: return(Threesome); case Hand.TwoPair: return(TwoPair); case Hand.OnePair: return(OnePair); case Hand.HighCard: return(cards.Sum(c => c.Rank)); default: return(cards.Sum(c => c.Rank)); } }
public void GetHand_OnePair() { var setup = new Setup() .WithCards(Suit.clubs, 2) .WithCards(Suit.diamonds, 2, 3, 4, 5); var actual = CurrentHandService.GetHand(setup.cards); Assert.That(actual, Is.EqualTo(Hand.OnePair)); }
public void GetHand_Straight() { var setup = new Setup() .WithCards(Suit.clubs, 2, 3, Ace) .WithCards(Suit.diamonds, 3, 4, 5, 6); var actual = CurrentHandService.GetHand(setup.cards); Assert.That(actual, Is.EqualTo(Hand.Straight)); }
public void GetHand_ThreeOfAKind() { var setup = new Setup() .WithCards(Suit.clubs, 2, 8) .WithCards(Suit.spades, 2) .WithCards(Suit.diamonds, 2, 3, 4, 5); var actual = CurrentHandService.GetHand(setup.cards); Assert.That(actual, Is.EqualTo(Hand.ThreeOfAKind)); }
public void GetHand_FullHouse() { var setup = new Setup() .WithCards(Suit.clubs, 2, 3, Ace) .WithCards(Suit.hearts, 2, 3) .WithCards(Suit.diamonds, 2, 4, 5, 6); var actual = CurrentHandService.GetHand(setup.cards); Assert.That(actual, Is.EqualTo(Hand.FullHouse)); }
public void GetHand_FourOfKind() { var setup = new Setup() .WithCards(Suit.clubs, 2, Ace) .WithCards(Suit.hearts, 2, 4) .WithCards(Suit.spades, 2) .WithCards(Suit.diamonds, 2, 4, 5, 6); var actual = CurrentHandService.GetHand(setup.cards); Assert.That(actual, Is.EqualTo(Hand.FourOfKind)); }