Example #1
0
 def test_fourofakind(self):
     d = self.d
     hand = Hand.get_fourofakind([d.sj, d.hj, d.dj, d.cj, d.h9])
     assert(hand is not None and hand.category == Hand.FOUROFAKIND)
     hand = Hand.get_fourofakind([d.cj, d.dj, d.d9, d.h9, d.s9])
     assert(hand is None)
     hand = Hand.get_fourofakind([d.c9, d.d9, d.hj, d.h9, d.s9])
     assert(hand is not None and hand.category == Hand.FOUROFAKIND)
     hand = Hand.get_fourofakind([d.cj, d.dj, d.hj, d.h9, d.sj])
     assert(hand is not None and hand.category == Hand.FOUROFAKIND)
     hand = Hand.get_fourofakind([d.s9, d.hj, d.h8, d.h6, d.hq])
     assert(hand is None)
Example #2
0
    def test_fourofakind_compare(self):
        d = self.d
        # d8 d7 h7 sj c8 : s8 h8 : s7 c7
        quad1 = Hand.get_fourofakind([d.s8, d.h8, d.d8, d.sj, d.c8])
        quad2 = Hand.get_fourofakind([d.s7, d.c7, d.d7, d.h7, d.sj])
        assert(quad1 is not None)
        assert(quad1 > quad2 and quad2 < quad1)

        # h5 s5 d3 d5 c5 : s2 s8 : sa ca : da d9
        quad1 = Hand.get_fourofakind([d.s8, d.h5, d.s5, d.d5, d.c5])
        quad2 = Hand.get_fourofakind([d.sa, d.h5, d.s5, d.d5, d.c5])
        quad3 = Hand.get_fourofakind([d.da, d.h5, d.s5, d.d5, d.c5])
        assert(quad1 is not None)
        assert(quad1 < quad2 and quad2 > quad1)
        assert(quad2 == quad3 and quad3 == quad2)
        assert(quad1 < quad3 and quad3 > quad1)
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)