예제 #1
0
 def test_is_royal_flush_should_return_false(self):
     card1 = Card(DeckSuite.TILES, DeckValue.TEN)
     card2 = Card(DeckSuite.TILES, DeckValue.JACK)
     card3 = Card(DeckSuite.TILES, DeckValue.TWO)
     card4 = Card(DeckSuite.TILES, DeckValue.KING)
     card5 = Card(DeckSuite.TILES, DeckValue.ACE)
     self.assertFalse(
         HandsHelper.is_royal_flush(card1, card2, card3, card4, card5))
예제 #2
0
 def test_is_royal_flush_should_return_true_if_deck_is_flush_and_straight_flush(
         self):
     card1 = Card(DeckSuite.TILES, DeckValue.TEN)
     card2 = Card(DeckSuite.TILES, DeckValue.JACK)
     card3 = Card(DeckSuite.TILES, DeckValue.QUEEN)
     card4 = Card(DeckSuite.TILES, DeckValue.KING)
     card5 = Card(DeckSuite.TILES, DeckValue.ACE)
     self.assertTrue(
         HandsHelper.is_royal_flush(card1, card2, card3, card4, card5))
def select_strongest_hand(*hands: Hand) -> Hand:
    royal_flush = any(
        HandsHelper.is_royal_flush(*hand.cards) for hand in hands)
    if royal_flush:
        return next(x for x in hands if royal_flush)
    four_of_kind = any(
        HandsHelper.is_four_of_kind(*hand.cards) for hand in hands)
    if four_of_kind:
        return next(x for x in hands if four_of_kind)
    full_house = any(HandsHelper.is_full_house(*hand.cards) for hand in hands)
    if full_house:
        return next(x for x in hands if full_house)
    three_of_kind = any(
        HandsHelper.is_three_of_kind(*hand.cards) for hand in hands)
    if three_of_kind:
        return next(x for x in hands if three_of_kind)
    two_pair = any(HandsHelper.is_two_pair(*hand.cards) for hand in hands)
    if two_pair:
        return next(x for x in hands if two_pair)
    one_pair = any(HandsHelper.is_one_pair(*hand.cards) for hand in hands)
    if one_pair:
        return next(x for x in hands if one_pair)