def playable(self, card_to_play: Card) -> bool: """Checks whether a card can be played. Args: card_to_play (Card): card to try to play Returns: bool: whether the card can be played or not """ top_card = self.discard[-1] tc_suit = self.get_top_card_suit() # suit might be set differently # Check the conditions to be met for the card to be playable. return (card_to_play.get_rank() == top_card.get_rank() or card_to_play.get_suit() == tc_suit or card_to_play.get_rank() == Rank.EIGHT)
def test_get_suit(self): card1 = Card(Rank.ACE, Suit.SPADES) self.assertEqual(card1.get_suit(), Suit.SPADES)