Example #1
0
 def test_straight(self):
     d = self.d
     hand = Hand.get_straight([d.hk, d.sa, d.dj, d.dt, d.dq])
     assert(hand is not None and hand.category == Hand.STRAIGHT)
     hand = Hand.get_straight([d.hk, d.sa, d.d9, d.dt, d.dq])
     assert(hand is None)
     hand = Hand.get_straight([d.ha, d.d3, d.d2, d.d4, d.c5])
     assert(hand is not None and hand.category == Hand.STRAIGHT)
Example #2
0
    def test_straight_compare(self):
        d = self.d
        # c7 hj d5 dt c3 : h6 d4 : c9 s8
        straight1 = Hand.get_straight([d.h6, d.d4, d.c7, d.d5, d.c3])
        straight2 = Hand.get_straight([d.c9, d.s8, d.c7, d.hj, d.dt])
        assert(straight1 is not None)
        assert(straight1 < straight2 and straight2 > straight1)

        # d2 c8 d4 c5 s8 : h6 h7 : sa c3 : d6 s3
        straight1 = Hand.get_straight([d.h6, d.h7, d.c8, d.d4, d.c5])
        straight2 = Hand.get_straight([d.sa, d.c3, d.d2, d.d4, d.c5])
        straight3 = Hand.get_straight([d.d6, d.s3, d.d2, d.d4, d.c5])
        assert(straight1 is not None)
        assert(straight1 > straight2 and straight2 < straight1)
        assert(straight2 < straight3 and straight3 > straight2)
        assert(straight3 < straight1 and straight1 > straight3)
Example #3
0
 def test_different_categories_compare(self):
     d = self.d
     hands = [Hand.get_highcard([d.h6, d.c9, d.d2, d.ck, d.cj]),
              Hand.get_pair([d.cj, d.sq, d.d2, d.c2, d.s4]),
              Hand.get_twopair([d.sj, d.cq, d.da, d.dq, d.hj]),
              Hand.get_threeofakind([d.d3, d.h8, d.c4, d.d8, d.s8]),
              Hand.get_straight([d.d7, d.h4, d.c5, d.c3, d.d6]),
              Hand.get_flush([d.h4, d.h8, d.h5, d.hq, d.h2]),
              Hand.get_fullhouse([d.d8, d.c8, d.s6, d.s8, d.c6]),
              Hand.get_fourofakind([d.h9, d.c7, d.d9, d.c9, d.s9]),
              Hand.get_straightflush([d.c3, d.c5, d.c4, d.c2, d.c6])]
     for hand in hands:
         assert(hand is not None)
     for hand1, hand2 in combinations(hands, 2):
         assert(hand1 < hand2)
     hands.reverse()
     for hand1, hand2 in combinations(hands, 2):
         assert(hand1 > hand2)