Пример #1
0
        public void OnePairTest()
        {
            PlayerHand threeOfAKind = new PlayerHand();
            threeOfAKind.AddCard(new Card(Suits.Spades, Faces.Ten));
            threeOfAKind.AddCard(new Card(Suits.Clubs, Faces.Ten));
            threeOfAKind.AddCard(new Card(Suits.Hearts, Faces.Ten));
            threeOfAKind.AddCard(new Card(Suits.Spades, Faces.King));
            threeOfAKind.AddCard(new Card(Suits.Spades, Faces.Ace));

            PlayerHand twoPairs = new PlayerHand();
            twoPairs.AddCard(new Card(Suits.Spades, Faces.Ten));
            twoPairs.AddCard(new Card(Suits.Clubs, Faces.Ten));
            twoPairs.AddCard(new Card(Suits.Hearts, Faces.King));
            twoPairs.AddCard(new Card(Suits.Spades, Faces.King));
            twoPairs.AddCard(new Card(Suits.Spades, Faces.Ace));

            PlayerHand onePair = new PlayerHand();
            onePair.AddCard(new Card(Suits.Spades, Faces.Ten));
            onePair.AddCard(new Card(Suits.Clubs, Faces.Ten));
            onePair.AddCard(new Card(Suits.Hearts, Faces.Eight));
            onePair.AddCard(new Card(Suits.Spades, Faces.King));
            onePair.AddCard(new Card(Suits.Spades, Faces.Ace));

            IHand handModel = new OnePair();

            Assert.IsTrue(handModel.HasThisHand(onePair));
            Assert.IsFalse(handModel.HasThisHand(threeOfAKind));
            Assert.IsFalse(handModel.HasThisHand(twoPairs));
        }
Пример #2
0
        public bool HasThisHand(PlayerHand hand)
        {
            if (5 > hand.Cards.Count)
            {
                return false;
            }

            ThreeOfAKind threeOfAKind = new ThreeOfAKind();
            OnePair onePair = new OnePair();

            return threeOfAKind.HasThisHand(hand) && onePair.HasThisHand(hand);
        }
Пример #3
0
        public bool HasThisHand(PlayerHand hand)
        {
            if(5 > hand.Cards.Count)
            {
                return false;
            }

            var x = from c in hand.Cards where c.Suit != hand.Cards[0].Suit select c;

            if (x.Count() > 0)
                return false;

            return true;
        }
Пример #4
0
        public bool HasThisHand(PlayerHand hand)
        {
            if (2 > hand.Cards.Count)
            {
                return false;
            }

            int pairCount = 0;
            foreach (Faces face in hand.Histogram.Keys)
            {
                if (hand.Histogram[face] == 2)
                    pairCount++;
            }

            return 1 == pairCount;
        }
Пример #5
0
        public void StraightFlushTest()
        {
            PlayerHand straightFlush = new PlayerHand();
            straightFlush.AddCard(new Card(Suits.Spades, Faces.Ten));
            straightFlush.AddCard(new Card(Suits.Spades, Faces.Jack));
            straightFlush.AddCard(new Card(Suits.Spades, Faces.Queen));
            straightFlush.AddCard(new Card(Suits.Spades, Faces.King));
            straightFlush.AddCard(new Card(Suits.Spades, Faces.Ace));

            PlayerHand straightNotFlush = new PlayerHand();
            straightNotFlush.AddCard(new Card(Suits.Spades, Faces.Ten));
            straightNotFlush.AddCard(new Card(Suits.Spades, Faces.Jack));
            straightNotFlush.AddCard(new Card(Suits.Diamonds, Faces.Queen));
            straightNotFlush.AddCard(new Card(Suits.Spades, Faces.King));
            straightNotFlush.AddCard(new Card(Suits.Spades, Faces.Ace));

            PlayerHand flushNotStraight = new PlayerHand();
            flushNotStraight.AddCard(new Card(Suits.Spades, Faces.Ten));
            flushNotStraight.AddCard(new Card(Suits.Spades, Faces.Jack));
            flushNotStraight.AddCard(new Card(Suits.Spades, Faces.Four));
            flushNotStraight.AddCard(new Card(Suits.Spades, Faces.King));
            flushNotStraight.AddCard(new Card(Suits.Spades, Faces.Ace));

            IHand handModel = new StraightFlush();

            Assert.IsTrue(handModel.HasThisHand(straightFlush));
            Assert.IsFalse(handModel.HasThisHand(straightNotFlush));
            Assert.IsFalse(handModel.HasThisHand(flushNotStraight));
        }
Пример #6
0
        public bool HasThisHand(PlayerHand hand)
        {
            if (5 > hand.Cards.Count)
            {
                return false;
            }

            if (hand.Cards[0].Face == hand.Cards[1].Face - 1
                && hand.Cards[1].Face == hand.Cards[2].Face - 1
                && hand.Cards[2].Face == hand.Cards[3].Face - 1
                && hand.Cards[3].Face == hand.Cards[4].Face - 1)
            {
                return true;
            }

            return false;
        }
Пример #7
0
        public bool HasThisHand(PlayerHand hand)
        {
            if (3 > hand.Cards.Count)
            {
                return false;
            }

            foreach (Faces face in hand.Histogram.Keys)
            {
                if (hand.Histogram[face] == 3)
                    return true;
            }

            return false;
        }
Пример #8
0
        public bool HasThisHand(PlayerHand hand)
        {
            if (5 > hand.Cards.Count)
            {
                return false;
            }

            Flush flush = new Flush();
            Straight straight = new Straight();

            return flush.HasThisHand(hand) && straight.HasThisHand(hand);
        }