def is_valid(self):
        straight_flush_validator = StraightFlushValidator(cards=self.cards)
        if straight_flush_validator.is_valid():
            straight_flush_cards = straight_flush_validator.valid_cards()
            return straight_flush_cards[-1].rank == "Ace"

        return False
Пример #2
0
    def test_determines_that_there_are_five_consecutive_cards_with_same_suit(self):
        three = Card(rank="3", suit="Clubs")
        four = Card(rank="4", suit="Clubs")
        five = Card(rank="5", suit="Clubs")
        six = Card(rank="6", suit="Clubs")
        seven = Card(rank="7", suit="Clubs")

        cards = [
            three,
            four,
            five,
            six,
            seven,
            Card(rank="King", suit="Clubs"),
            Card(rank="Ace", suit="Diamonds")
        ]

        validator = StraightFlushValidator(cards=cards)

        self.assertEqual(
            validator.valid_cards(),
            [
                three,
                four,
                five,
                six,
                seven
            ]
        )
    def is_valid(self):
        straight_flush = StraightFlushValidator(cards=self.cards)
        if straight_flush.is_valid():
            cards = straight_flush.valid_cards()
            if cards[-1].rank == "Ace":
                return True

        return False
    def is_valid(self):
        straight_flash_validator = StraightFlushValidator(cards=self.cards)
        if straight_flash_validator.is_valid():
            straight_flash_cards = straight_flash_validator.valid_cards()
            is_royal = straight_flash_cards[-1].rank == 'Ace'
            return is_royal

        return False
 def test_returns_a_straight_flush_from_card_collection(self):
     validator = StraightFlushValidator(cards = self.cards)
     self.assertEqual(
         validator.valid_cards(),
         [
             self.eight_of_spades,
             self.nine_of_spades,
             self.ten_of_spades,
             self.jack_of_spades,
             self.queen_of_spades,
         ]
     )
 def test_valid_cards(self):
     cards = [
         Card(rank="4", suite="hearts"),
         Card(rank="5", suite="hearts"),
         Card(rank="6", suite="hearts"),
         Card(rank="7", suite="hearts"),
         Card(rank="8", suite="hearts"),
         Card(rank="King", suite="hearts")
     ]
     validator = StraightFlushValidator(cards=cards)
     self.assertEqual(validator.valid_cards(), [
         Card(rank="4", suite="hearts"),
         Card(rank="5", suite="hearts"),
         Card(rank="6", suite="hearts"),
         Card(rank="7", suite="hearts"),
         Card(rank="8", suite="hearts"),
     ])
    def test_determines_that_there_are_five_consecutive_cards_with_the_same_suit(
            self):
        seven_of_diamonds = Card(rank='7', suit='Diamonds')
        eight_of_diamonds = Card(rank='8', suit='Diamonds')
        nine_of_diamonds = Card(rank='9', suit='Diamonds')
        ten_of_diamonds = Card(rank='10', suit='Diamonds')
        jack_of_diamonds = Card(rank='Jack', suit='Diamonds')

        cards = [
            seven_of_diamonds,
            eight_of_diamonds,
            nine_of_diamonds,
            ten_of_diamonds,
            jack_of_diamonds,
            Card(rank='King', suit='Diamonds'),
            Card(rank='Ace', suit='Clubs'),
        ]

        validator = StraightFlushValidator(cards=cards)

        self.assertEqual(validator.valid_cards(), [
            seven_of_diamonds, eight_of_diamonds, nine_of_diamonds,
            ten_of_diamonds, jack_of_diamonds
        ])