Ejemplo n.º 1
0
        public bool IsHandOfThisType(Hand hand)
        {
            if (hand.HasAllTheSameSuit)
                return false;

            return hand.NumberOfPairs == 1;
        }
Ejemplo n.º 2
0
 public bool IsHandOfThisType(Hand hand)
 {
     string hand1 = hand.ValuesThenSuitsDescription;
     var straightFlushIdentifier = new TexasHoldemStraightFlushIdentifier();
     if (straightFlushIdentifier.IsHandOfThisType(hand))
         return false;
     return new Regex("(2345A|23456|34567|45678|56789|6789T|789TJ|89TJQ|9TJQK)").IsMatch(hand1);
 }
Ejemplo n.º 3
0
        public bool IsHandOfThisType(Hand hand)
        {
            var straighFlushIdentier = new TexasHoldemStraightFlushIdentifier();
            if (straighFlushIdentier.IsHandOfThisType(hand))
                return false;

            return new Regex("(TJQKA)(DDDDD|SSSSS|CCCCC|HHHHH)").IsMatch(hand.ValuesThenSuitsDescription);
        }
Ejemplo n.º 4
0
        public bool IsHandOfThisType(Hand hand)
        {
            var royalFlushIdentifier = new TexasHoldemRoyalFlushIdentifier();
            if (royalFlushIdentifier.IsHandOfThisType(hand))
                return false;

            var fourOfAKindIdentifier = new TexasHoldemFourOfAKindIdentifier();
            if (fourOfAKindIdentifier.IsHandOfThisType(hand))
                return false;

            return hand.HasAllTheSameSuit;
        }
Ejemplo n.º 5
0
        public virtual Hand DealHand(int numberOfCardsToDeal)
        {
            var hand = new Hand();

            if(Cards.Count < numberOfCardsToDeal)
                throw new NeedToRefillTheShoeException();

            for (var i = 0; i < numberOfCardsToDeal; i++)
            {
                var randomCard = DealCard();
                hand.AddCard(randomCard);
            }

            return hand;
        }
Ejemplo n.º 6
0
        public virtual TexasHoldemHand Identify(Hand hand)
        {
            if(hand == null)
                throw new ArgumentNullException("hand");

            if (HandIndentifiers == null)
                throw new ArgumentNullException("HandIdentifiers");

            if(hand.Cards.Count != 5)
                throw new Exception(string.Format("Not a valid texas holdem hand. Expected 5 cards but got {0}", hand.Cards.Count));

            var identifiedHand = TexasHoldemHand.HighCard;

            foreach (var identifier in HandIndentifiers)
            {
                if (identifier.IsHandOfThisType(hand))
                {
                    identifiedHand = identifier.IdentifiedHand;
                    break;
                }
            }
            return identifiedHand;
        }
 public bool IsHandOfThisType(Hand hand)
 {
     var desc = hand.ValuesThenSuitsDescription;
     return new Regex("(2222|3333|4444|5555|6666|7777|8888|9999|TTTT|JJJJ|QQQQ|KKKK|AAAA)").IsMatch(desc);
 }
Ejemplo n.º 8
0
 public virtual TexasHoldemHand IdentifyHand(Hand hand)
 {
     return _identifier.Identify(hand);
 }
 public bool IsHandOfThisType(Hand hand)
 {
     return hand.HasTriples && hand.NumberOfPairs == 0 && !hand.HasAllTheSameSuit;
 }
Ejemplo n.º 10
0
 public bool IsHandOfThisType(Hand hand)
 {
     return hand.NumberOfPairs == 1 && hand.HasTriples;
 }
 public bool IsHandOfThisType(Hand hand)
 {
     return new Regex("(2345A|23456|34567|45678|56789|6789T|789TJ|89TJQ|9TJQK)(DDDDD|SSSSS|CCCCC|HHHHH)").IsMatch(hand.ValuesThenSuitsDescription);
 }
Ejemplo n.º 12
0
 //static so we don't change the order of the cards in the program
 //returns a string representing the hand that is passed in
 //pair of two;s, three aces, king high......
 public static string getHandValue(Hand t_h)
 {
     //sort and calc total so that total and totalValue are assigned
     Hand h = new Hand(t_h.hand);
     h.sort();
     h.calcTotal();
     //check to see what hand the hand contains
     //3 high, 4 high.....etc....
     if (h.handTotal == 0)
     {
         if (h.highestCardValue >= 2 && h.highestCardValue <= 10)
             return h.highestCardValue.ToString() + " High";
         else if (h.highestCardValue == 11)
             return "Jack High";
         else if (h.highestCardValue == 12)
             return "Queen High";
         else if (h.highestCardValue == 13)
             return "King High";
         else if (h.highestCardValue == 14)
             return "Ace High";
     }
     //pair of two's, pair of king's......
     else if (h.handTotal == 1)
     {
         if (h.highestCardValue >= 2 && h.highestCardValue <= 10)
             return "Pair of " + h.highestCardValue.ToString() + "'s";
         if (h.highestCardValue == 11)
             return "Pair of Jacks";
         if (h.highestCardValue == 12)
             return "Pair of Jacks";
         if (h.highestCardValue == 13)
             return "Pair of Jacks";
         if (h.highestCardValue == 14)
             return "Pair of Jacks";
     }
     //just do two pair
     else if (h.handTotal == 2)
         return "Two Pair";
     //Three 9's...etc....
     else if (h.handTotal == 3)
     {
         if (h.highestCardValue >= 2 && h.highestCardValue <= 10)
             return "Three " + h.highestCardValue.ToString() + "'s";
         else if (h.highestCardValue == 11)
             return "Three Jacks";
         else if (h.highestCardValue == 12)
             return "Three Queens";
         else if (h.highestCardValue == 13)
             return "Three Kings";
         else if (h.highestCardValue == 14)
             return "Three Aces";
     }
     //Straight, 8 high.....etc....
     else if (h.handTotal == 4)
     {
         if (h.highestCardValue >= 2 && h.highestCardValue <= 10)
             return "Straight, " + h.highestCardValue.ToString() + " High";
         else if (h.highestCardValue == 11)
             return "Straight, Jack High";
         else if (h.highestCardValue == 12)
             return "Straight, Queen High";
         else if (h.highestCardValue == 13)
             return "Straight, King High";
         else if (h.highestCardValue == 14)
             return "Straight, Ace High";
     }
     else if (h.handTotal == 5)
     {
         if (h.highestCardValue >= 2 && h.highestCardValue <= 10)
             return "Flush, " + h.highestCardValue.ToString() + " High";
         else if (h.highestCardValue == 11)
             return "Flush, Jack High";
         else if (h.highestCardValue == 12)
             return "Flush, Queen High";
         else if (h.highestCardValue == 13)
             return "Flush, King High";
         else if (h.highestCardValue == 14)
             return "Flush, Ace High";
     }
     else if (h.handTotal == 6)
         return "Full House";
     //Four 6's.
     else if (h.handTotal == 7)
     {
         if (h.highestCardValue >= 2 && h.highestCardValue <= 10)
             return "Four " + h.highestCardValue.ToString() + "'s";
         else if (h.highestCardValue == 11)
             return "Four Jacks";
         else if (h.highestCardValue == 12)
             return "Four Queens";
         else if (h.highestCardValue == 13)
             return "Four Kings";
         else if (h.highestCardValue == 14)
             return "Four Aces";
     }
     else if (h.handTotal == 8)
         return "Has Straight Flush";
     else if (h.handTotal == 9)
         return "HOLY F*****G SHIT ROYAL FLUSH";
     //we won't make it this far
     return "Something went wrong...";
 }
Ejemplo n.º 13
0
        //returns true if lhs won
        //else return false
        public static bool won(Hand t_lhs,Hand t_rhs)
        {
            //We don't want to chage the order of the cards in the program,
            //so we need some temp hands.
            Hand lhs = new Hand(t_lhs.hand);
            lhs.sort();
            lhs.calcTotal();
            Hand rhs = new Hand(t_rhs.hand);
            rhs.sort();
            rhs.calcTotal();

            if(lhs.handTotal != rhs.handTotal)
                return lhs.handTotal > rhs.handTotal;
            //else, they are the same, check total value first
            if (lhs.highestCardValue != rhs.highestCardValue)
                return lhs.highestCardValue > rhs.highestCardValue;
            //else they are the same, and just check for the highest card
            for(int i = 0; i < 5; ++i)
            {
                if(lhs.hand[i].value != rhs.hand[i].value)
                    return lhs.hand[i].value > rhs.hand[i].value;
            }
            //we shouldn't make it this far....
            return false;
        }