def __init__(self, card: Card, color=None): if color and not card.is_rainbow(): raise ValueError('Action color can be set on actions concerning ' + 'rainbow cards only.' + f'Card color: {card.color}') if not color and card.is_rainbow(): raise ValueError( 'Action color must be set on actions concerning ' + 'rainbow cards') self.card = card self.color = color
def is_move_with_card_possible(self, card: Card): if not self.turtles: return False if card.is_rainbow(): return self._is_move_with_rainbow_card_possible(card) else: return self._is_move_with_regular_card_possible(card)
def test_is_rainbow_should_return_false_for_regular_card(): card = Card(0, 'RED', 'PLUS') assert card.is_rainbow() is False
def test_is_rainbow_should_return_true_for_rainbow_card(): card = Card(0, 'RAINBOW', 'PLUS') assert card.is_rainbow()