Example #1
0
        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));
            }
        }
Example #2
0
        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 IsStraight_StraightInMiddle_Yes()
        {
            var setup = new Setup(3, 3, 5, 6, 7, 7, 8, 9, 11, 11);

            var actual = CurrentHandService.IsStraight(setup.cards);

            Assert.That(actual, Is.True);
        }
        public void IsStraight_SingleCard_No()
        {
            var setup = new Setup(5);

            var actual = CurrentHandService.IsStraight(setup.cards);

            Assert.That(actual, Is.False);
        }
        public void IsStraight_2To5AndGap_No()
        {
            var setup = new Setup(2, 3, 4, 5, 8);

            var actual = CurrentHandService.IsStraight(setup.cards);

            Assert.That(actual, Is.False);
        }
        public void IsStraight_AceTo5_Yes()
        {
            var setup = new Setup(2, 3, 4, 5, Ace);

            var actual = CurrentHandService.IsStraight(setup.cards);

            Assert.That(actual, Is.True);
        }
        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));
        }