示例#1
0
 def test_card_is_cursor_on_function_work(self):
     card = Card(one, one, tuple_ones)
     for x in range(0, card_width + 100):
         for y in range(0, card_height + 100):
             if x < card_width and y < card_height:
                 assert card.is_cursor_on(x, y)
             else:
                 assert not card.is_cursor_on(x, y)
示例#2
0
    def test_card_reborn_function(self):

        for number_of_arrows in range(1, 2):

            card = Card(one, one, tuple_ones)

            maxlp = card.max_life_point

            card.reborn()

            assert card.life_point == int(maxlp / 2)
示例#3
0
    def test_card_init_values(self):

        card = Card(1, 2, (20, 60, 100))

        assert card.player == 2
        assert card.number == 1
        assert card.color == (20, 60, 100)

        assert card.px == 0
        assert card.py == 0

        assert card.combo_percent == 0
        assert card.combo_color is None
        assert card.combo_direction is None

        assert card.life_point in [16, 18]
        assert card.max_life_point in [16, 18]

        assert not card.is_selected

        assert len(card.arrows) == len(Directions.all_directions)
        for direction in Directions.all_directions:
            assert card.arrows.get(direction) is None or isinstance(
                card.arrows.get(direction), Arrow)

        assert card.rect.x == 0
        assert card.rect.y == 0
        assert card.rect.w == card_width
        assert card.rect.h == card_height

        assert card.name == "12"
示例#4
0
    def reset_hand(self):

        # definir 5 cases ?

        card1 = Card(1, self.number, self.color, self.screen)
        card2 = Card(2, self.number, self.color, self.screen)
        card3 = Card(3, self.number, self.color, self.screen)
        card4 = Card(4, self.number, self.color, self.screen)
        number = 18 - (card1.number_of_arrows + card2.number_of_arrows +
                       card3.number_of_arrows + card4.number_of_arrows)
        card5 = Card(5,
                     self.number,
                     self.color,
                     self.screen,
                     number_of_arrows=number)
        self.hand = [card1, card2, card3, card4, card5]
        self.reset_hand_positions()
示例#5
0
def build_player_from_json(json_data):
    player = Player(json_data['name'], json_data['color'], None)
    player.number = json_data['number']
    for number in range(1, 6):
        card = Card(0, player.number, number, player.color)

        player.hand.append(card)
    player.reset_hand_positions()
    return player
示例#6
0
    def test_card_3_invalid_number_of_arrows(self):
        card = Card(3, one, tuple_ones)

        for number_of_arrows in range(1, 9):

            if number_of_arrows in range(3, 7):
                assert not self.invalid_number_of_arrows(
                    card, number_of_arrows)
            else:
                assert self.invalid_number_of_arrows(card, number_of_arrows)
示例#7
0
 def test_card_reset_combo_function(self):
     card = Card(one, one, tuple_ones)
     card.combo_percent = 2
     card.combo_color = (0, 0, 0)
     card.combo_direction = 2
     card.reset_combo()
     assert card.combo_percent == 0
     assert card.combo_color is None
     assert card.combo_direction is None
示例#8
0
 def test_card_is_cursor_on_function_first_argument_is_negative(self):
     with pytest.raises(CardFunctionParameterException):
         card = Card(one, one, tuple_ones)
         card.is_cursor_on(-1, one)
示例#9
0
 def test_card_is_cursor_on_function_second_argument_is_not_number(self):
     with pytest.raises(CardFunctionParameterException):
         card = Card(one, one, tuple_ones)
         card.is_cursor_on(one, "Tests")
示例#10
0
 def test_card_rect_is_h_is_incorrect(self):
     with pytest.raises(CardParameterException):
         card = Card(one, one, tuple_ones)
         card.rect = pygame.Rect(card.px, card.py, card_width, 4)
示例#11
0
 def test_card_change_player_function_work(self):
     card = Card(one, one, tuple_ones)
     card.change_player(4, (20, 40, 60))
     assert card.player == 4
     assert card.color == (20, 40, 60)
示例#12
0
 def test_card_number_of_arrows_is_none(self, number_of_arrow):
     with pytest.raises(CardParameterException):
         Card(one, one, tuple_ones).number_of_arrows = number_of_arrow
示例#13
0
 def test_card_combo_percent(self, percent):
     with pytest.raises(CardParameterException):
         Card(one, one, tuple_ones).combo_percent = percent
示例#14
0
 def test_card_color_r(self, r):
     with pytest.raises(CardParameterException):
         Card(one, one, (r, one, one))
示例#15
0
 def test_card_color_b(self, b):
     with pytest.raises(CardParameterException):
         Card(one, one, (one, one, b))
示例#16
0
 def test_card_get_arrow_directions_function_result_contains_only_directions(
         self):
     card = Card(one, one, tuple_ones)
     arrows_direction = card.get_arrows_directions()
     for direction in arrows_direction:
         assert direction in Directions.all_directions
示例#17
0
 def test_card_combo_direction(self, direction):
     with pytest.raises(CardParameterException):
         Card(one, one, tuple_ones).combo_direction = direction
示例#18
0
 def test_card_get_arrow_directions_function_result_length(self):
     card = Card(one, one, tuple_ones, number_of_arrows=2)
     arrows_direction = card.get_arrows_directions()
     assert len(arrows_direction) == card.number_of_arrows
示例#19
0
 def test_card_get_arrow_directions_function_result_is_a_list(self):
     card = Card(one, one, tuple_ones)
     arrows_direction = card.get_arrows_directions()
     assert isinstance(arrows_direction, list)
示例#20
0
 def test_card_name_is_none(self, card_name):
     with pytest.raises(CardParameterException):
         Card(one, one, tuple_ones).name = card_name
示例#21
0
 def test_card_is_cursor_on_function_second_argument_is_decimal(self):
     with pytest.raises(CardFunctionParameterException):
         card = Card(one, one, tuple_ones)
         card.is_cursor_on(one, 3.5)
示例#22
0
 def test_card_arrows_value_not_bool(self):
     with pytest.raises(CardParameterException):
         Card(one, one, tuple_ones).arrows = \
             {0: False, 1: "Tests", 2: False, 3: False, 4: False, 5: False, 6: False, 7: False}
示例#23
0
 def test_card_combo_color_b(self, b):
     with pytest.raises(CardParameterException):
         Card(one, one, tuple_ones).combo_color = (one, one, b)
示例#24
0
 def test_card_card_change_player_function_player(self, card_player):
     with pytest.raises(CardParameterException):
         card = Card(one, one, tuple_ones)
         card.change_player(card_player, tuple_ones)
示例#25
0
 def card_5_invalid_number_of_arrows(number_of_arrows):
     try:
         Card(5, one, tuple_ones, number_of_arrows=number_of_arrows)
         return False
     except CardParameterException:
         return True
示例#26
0
 def test_card_card_change_player_function_color_b(self, b):
     with pytest.raises(CardParameterException):
         card = Card(one, one, tuple_ones)
         card.change_player(one, (one, b, one))
示例#27
0
 def test_card_player(self, card_player):
     with pytest.raises(CardParameterException):
         Card(one, card_player, tuple_ones)
示例#28
0
 def test_card_color_g(self, g):
     with pytest.raises(CardParameterException):
         Card(one, one, (one, g, one))
示例#29
0
 def test_card_arrows_key_not_direction(self):
     with pytest.raises(CardParameterException):
         Card(one, one, tuple_ones).arrows = \
             {0: False, 1: False, 2: False, "Tests": False, 4: False, 5: False, 6: False, 7: False}
示例#30
0
 def test_card_rect_is_not_rect(self):
     with pytest.raises(CardParameterException):
         Card(one, one, tuple_ones).rect = "Tests"