Beispiel #1
0
    def best_poker_hand(self, cards=[]):
        '''
        Returns the highest poker hand in hand by going thorough all possible
        hands and see if they exist in the current hand.

        :param cards: the current hand.
        :return: the best poker hand.
        '''
        total_cards = self.cards + cards
        pokerhands = [
            ph.check_multiples(total_cards, 5),  # Five of a kind
            ph.check_straight_flush(total_cards),  # Straight flush
            ph.check_multiples(total_cards, 4),  # Four of a kind
            ph.check_full_house(total_cards),  # Full house
            ph.check_flush(total_cards),  # Flush
            ph.check_straight(total_cards),  # Straight
            ph.check_multiples(total_cards, 3),  # Three of a kind
            ph.check_two_pair(total_cards),  # Two pair
            ph.check_multiples(total_cards, 2),  # Two of a kind
            ph.check_multiples(total_cards, 1),  # Highest single
        ]
        for ptype, values in zip(ph.PokerHandType, pokerhands):
            if values is not None:
                return PokerHand(values, ptype)
 def test_give_four_of_kind_shoud_false(self):
     cards = ["TC", "TD", "TH", "TS", "AH"]
     answer = pk.check_full_house(cards)
     self.assertEqual(False, answer)
 def test_give_three_of_kind_should_false(self):
     cards = ["AC", "AD", "4C", "5H", "AH"]
     answer = pk.check_full_house(cards)
     self.assertEqual(False, answer)
 def test_give_A_T_T_T_A_shoud_true(self):
     cards = ["AC", "TD", "TH", "TC", "AH"]
     answer = pk.check_full_house(cards)
     self.assertEqual(True, answer)
 def test_give_T_T_T_J_Q_should_false(self):
     cards = ["TC", "TD", "TH", "JC", "QH"]
     answer = pk.check_full_house(cards)
     self.assertEqual(False, answer)