Ejemplo n.º 1
0
    def test_arrow_init_values(self):

        arrow = Arrow(1, 2, 3, color=red)
        assert arrow.direction == 1
        assert arrow.px == 2
        assert arrow.py == 3
        assert arrow.color == red
        assert arrow.polygone is not None
Ejemplo n.º 2
0
    def __init__(self,
                 card_number,
                 player_number,
                 color,
                 screen,
                 number_of_arrows=None):

        self.player = player_number
        self.number = card_number
        self.color = color
        self.screen = screen

        if self.number == 1:
            self.number_of_arrows = randint(1, 2)
            self.image_key = golem_image_key
        elif self.number == 2:
            self.number_of_arrows = randint(2, 4)
            self.image_key = golem_image_key
        elif self.number == 3:
            self.number_of_arrows = randint(3, 6)
            self.image_key = golem_image_key
        elif self.number == 4:
            self.number_of_arrows = 4
            self.image_key = golem_image_key
        elif self.number == 5:
            self.number_of_arrows = number_of_arrows
            self.image_key = golem_image_key

        self.is_selected = False

        self.combo_percent = 0
        self.combo_color = None
        self.combo_direction = None

        self.rect = pygame.Rect(0, 0, card_width, card_height)

        self.name = str(self.number) + str(self.player)[0]

        self.life_point = 20 - 2 * self.number_of_arrows
        self.max_life_point = self.life_point

        self.arrows = {
            direction: None
            for direction in Directions.all_directions
        }

        while len(self.get_arrows_directions()) != self.number_of_arrows:
            direction = Directions.all_directions[randint(
                0,
                len(Directions.all_directions) - 1)]
            if not self.arrows.get(direction):
                self.arrows[direction] = Arrow(direction, self.rect.x,
                                               self.rect.y, self.screen)
Ejemplo n.º 3
0
 def test_arrow_py_is_not_number(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, "Tests")
Ejemplo n.º 4
0
 def test_arrow_py_negative(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, -1)
Ejemplo n.º 5
0
 def test_arrow_px_negative(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, -1, tuple_ones)
Ejemplo n.º 6
0
 def test_arrow_px_decimal(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, 3.5, tuple_ones)
Ejemplo n.º 7
0
 def test_arrow_color_r_decimal(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, one, color=(3.5, 1, 1))
Ejemplo n.º 8
0
 def test_arrow_polygone_is_none(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, one).polygone = None
Ejemplo n.º 9
0
 def test_arrow_color_not_tuple(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, one, color="Tests")
Ejemplo n.º 10
0
 def test_arrow_color_r_negative(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, one, color=(-1, 1, 1))
Ejemplo n.º 11
0
 def test_arrow_polygone_3_coor_2_negative(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, one).polygone = [[one, one], [one, one], [one, -1]]
Ejemplo n.º 12
0
 def test_arrow_py_decimal(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, 3.5)
Ejemplo n.º 13
0
 def test_arrow_polygone_3_coor_2_not_number(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, one).polygone = [[one, one], [one, one], [one, "Tests"]]
Ejemplo n.º 14
0
 def test_arrow_polygone_3_incorect_length(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, one).polygone = [[one, one], [one, one], [one]]
Ejemplo n.º 15
0
 def test_arrow_polygone_3_not_list(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, one).polygone = [[one, one], [one, one], "Tests"]
Ejemplo n.º 16
0
 def test_arrow_direction_negative(self):
     with pytest.raises(ArrowParameterException):
         Arrow(-1, one, one)
Ejemplo n.º 17
0
 def test_arrow_direction_is_not_number(self):
     with pytest.raises(ArrowParameterException):
         Arrow("Tests", one, one)
Ejemplo n.º 18
0
 def test_arrow_color_is_none(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, one, color=None)
Ejemplo n.º 19
0
 def test_arrow_direction_too_high(self):
     with pytest.raises(ArrowParameterException):
         Arrow(1000, one, one)
Ejemplo n.º 20
0
 def test_arrow_color_size_too_high(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, one, color=(1, 1, 1, 1))
Ejemplo n.º 21
0
 def test_arrow_bool_value(self):
     assert Arrow(one, one, one)
Ejemplo n.º 22
0
 def test_arrow_color_r_to_big(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, one, color=(300, 1, 1))
Ejemplo n.º 23
0
    def test_arrow_set_position_function(self):

        arrow = Arrow(one, one, one)
        arrow.set_position(2, 3)
        assert arrow.px == 2
        assert arrow.py == 3
Ejemplo n.º 24
0
 def test_arrow_color_g_not_number(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, one, color=(1, "Tests", 1))
Ejemplo n.º 25
0
 def test_arrow_direction_decimal(self):
     with pytest.raises(ArrowParameterException):
         Arrow(3.5, one, one)