class TestHighCard(TestCase):
    def setUp(self):
        self.high_card_hand: Hand = Hand(
            Card(rank=Ranks.A.value, suit=Suits.DIAMONDS.value),
            Card(rank=Ranks.SEVEN.value, suit=Suits.HEARTS.value),
            Card(rank=Ranks.FIVE.value, suit=Suits.CLUBS.value),
            Card(rank=Ranks.THREE.value, suit=Suits.DIAMONDS.value),
            Card(rank=Ranks.TWO.value, suit=Suits.SPADES.value))

        self.not_high_card_hand: Hand = Hand(
            Card(rank=Ranks.A.value, suit=Suits.CLUBS.value),
            Card(rank=Ranks.A.value, suit=Suits.DIAMONDS.value),
            Card(rank=Ranks.NINE.value, suit=Suits.HEARTS.value),
            Card(rank=Ranks.SIX.value, suit=Suits.SPADES.value),
            Card(rank=Ranks.FOUR.value, suit=Suits.DIAMONDS.value))

        self.hand_strength = HandStrength(self.high_card_hand)

        self.not_valid_one_pair_hand_strength = HandStrength(
            self.not_high_card_hand)

    def test_is_high_hand_returns_true_for_valid_high_card_hand(self):
        self.assertTrue(self.hand_strength.is_high_card())

    def test_is_high_hand_returns_false_for_invalid_high_card_hand(self):
        self.assertFalse(self.not_valid_one_pair_hand_strength.is_high_card())
Пример #2
0
 def get_hand_strength(self):
     hand_strength = HandStrength(self.hand)
     if hand_strength.is_royal_flush():
         return HandsName.ROYAL_FLUSH.value
     if hand_strength.is_straight_flush():
         return HandsName.STRAIGHT_FLUSH.value
     if hand_strength.is_four_of_a_kind():
         return HandsName.FOUR_OF_A_KIND.value
     if hand_strength.is_full_house():
         return HandsName.FULL_HOUSE.value
     if hand_strength.is_flush():
         return HandsName.FLUSH.value
     if hand_strength.is_straight():
         return HandsName.STRAIGHT.value
     if hand_strength.is_three_of_a_kind():
         return HandsName.THREE_OF_A_KIND.value
     if hand_strength.is_two_pair():
         return HandsName.TWO_OF_A_KIND.value
     if hand_strength.is_one_pair():
         return HandsName.ONE_OF_A_PAIR.value
     if hand_strength.is_high_card():
         return HandsName.HIGH_CARD.value
     else:
         raise Exception('Unknown Kind')