Exemple #1
0
    def test_trips(self):
        a = PokerHand()

        #case 1: make sure the empty hand doesn't contain trips
        self.assertFalse(a.is_trips())

        #case 2: make sure we sense trips in three cards
        a.add_cards('9s9h9c', None)
        self.assertFalse(a.is_quads())
        self.assertFalse(a.is_straight())
        self.assertFalse(a.is_flush())
        out = a.is_trips()
        self.assertTrue(out.type == HandValue.HV_TRIPS)
        self.assertTrue(out.primary == Card.CV_NINE)

        #case 3: add a kicker
        a.add_cards(['Ah'], None)
        self.assertFalse(a.is_quads())
        self.assertFalse(a.is_straight())
        self.assertFalse(a.is_flush())
        out = a.is_trips()
        self.assertTrue(out.type == HandValue.HV_TRIPS)
        self.assertTrue(out.primary == Card.CV_NINE)

        #case 4: make the same trips, but with worse kicker
        b = PokerHand()
        b.add_cards('9s9h9cKd', None)
        out2 = b.is_trips()
        self.assertTrue(out2.type == HandValue.HV_TRIPS)
        self.assertTrue(out2.primary == Card.CV_NINE)
        self.assertTrue(out.tertiary > out2.tertiary)

        #case 5: check subkicker...make and b have the same kicker, but smaller subkick
        a.add_cards(['Qd'], None)
        b.add_cards(['Ah'], None)
        out = a.is_trips()
        out2 = b.is_trips()
        self.assertTrue(out2.type == HandValue.HV_TRIPS)
        self.assertTrue(out2.primary == Card.CV_NINE)
        self.assertTrue(out2.tertiary > out.tertiary)
Exemple #2
0
    def test_pairs(self):
        a = PokerHand()

        #case 1: make sure the empty hand doesn't contain two pair
        self.assertFalse(a.has_pairs())

        #case 2: sense two pair in four cards
        a.add_cards(['Ad', 'As', '4h', '4c'], None)
        self.assertFalse(a.is_trips())
        self.assertFalse(a.is_quads())
        self.assertFalse(a.is_straight())
        self.assertFalse(a.is_flush())
        out = a.has_pairs()
        self.assertTrue(out.type == HandValue.HV_TWO_PAIR)
        self.assertTrue(out.primary == Card.CV_ACE)
        self.assertTrue(out.secondary == Card.CV_FOUR)

        #case 3: add a kicker
        a.add_cards(['3d'], None)
        self.assertFalse(a.is_trips())
        self.assertFalse(a.is_quads())
        self.assertFalse(a.is_straight())
        self.assertFalse(a.is_flush())        
        out = a.has_pairs()
        self.assertTrue(out.type == HandValue.HV_TWO_PAIR)
        self.assertTrue(out.primary == Card.CV_ACE)
        self.assertTrue(out.secondary == Card.CV_FOUR)
        
        #case 4: add a better kicker, make sure comparison works
        a.add_cards(['Kd'], None)
        self.assertFalse(a.is_trips())
        self.assertFalse(a.is_quads())
        self.assertFalse(a.is_straight())
        self.assertFalse(a.is_flush())        
        out2 = a.has_pairs()
        self.assertTrue(out2.type == HandValue.HV_TWO_PAIR)
        self.assertTrue(out2.primary == Card.CV_ACE)
        self.assertTrue(out2.secondary == Card.CV_FOUR)
        self.assertTrue(out2.tertiary > out.tertiary)

        a = PokerHand()

        #case 5: sense a pair in two cards
        a.add_cards(['6d', '6s'], None)
        self.assertFalse(a.is_trips())
        self.assertFalse(a.is_quads())
        self.assertFalse(a.is_straight())
        self.assertFalse(a.is_flush())        
        out2 = a.has_pairs()
        self.assertTrue(out2.type == HandValue.HV_PAIR)
        self.assertTrue(out2.primary == Card.CV_SIX)

        #case 6: add cards, make sure outcome is the same
        a.add_cards(['8d'], None)
        self.assertFalse(a.is_trips())
        self.assertFalse(a.is_quads())
        self.assertFalse(a.is_straight())
        self.assertFalse(a.is_flush())        
        out = a.has_pairs()
        self.assertTrue(out.type == HandValue.HV_PAIR)
        self.assertTrue(out.primary == Card.CV_SIX)

        #case 7: improve the kicker, make sure hand improves
        a.add_cards(['9d'], None)
        self.assertFalse(a.is_trips())
        self.assertFalse(a.is_quads())
        self.assertFalse(a.is_straight())
        self.assertFalse(a.is_flush())        
        out2 = a.has_pairs()
        self.assertTrue(out2.type == HandValue.HV_PAIR)
        self.assertTrue(out2.primary == Card.CV_SIX)
        self.assertTrue(out2.tertiary > out.tertiary)