示例#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
示例#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)
示例#3
0
 def test_arrow_py_is_not_number(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, "Tests")
示例#4
0
 def test_arrow_py_negative(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, -1)
示例#5
0
 def test_arrow_px_negative(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, -1, tuple_ones)
示例#6
0
 def test_arrow_px_decimal(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, 3.5, tuple_ones)
示例#7
0
 def test_arrow_color_r_decimal(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, one, color=(3.5, 1, 1))
示例#8
0
 def test_arrow_polygone_is_none(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, one).polygone = None
示例#9
0
 def test_arrow_color_not_tuple(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, one, color="Tests")
示例#10
0
 def test_arrow_color_r_negative(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, one, color=(-1, 1, 1))
示例#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]]
示例#12
0
 def test_arrow_py_decimal(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, 3.5)
示例#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"]]
示例#14
0
 def test_arrow_polygone_3_incorect_length(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, one).polygone = [[one, one], [one, one], [one]]
示例#15
0
 def test_arrow_polygone_3_not_list(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, one).polygone = [[one, one], [one, one], "Tests"]
示例#16
0
 def test_arrow_direction_negative(self):
     with pytest.raises(ArrowParameterException):
         Arrow(-1, one, one)
示例#17
0
 def test_arrow_direction_is_not_number(self):
     with pytest.raises(ArrowParameterException):
         Arrow("Tests", one, one)
示例#18
0
 def test_arrow_color_is_none(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, one, color=None)
示例#19
0
 def test_arrow_direction_too_high(self):
     with pytest.raises(ArrowParameterException):
         Arrow(1000, one, one)
示例#20
0
 def test_arrow_color_size_too_high(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, one, color=(1, 1, 1, 1))
示例#21
0
 def test_arrow_bool_value(self):
     assert Arrow(one, one, one)
示例#22
0
 def test_arrow_color_r_to_big(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, one, color=(300, 1, 1))
示例#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
示例#24
0
 def test_arrow_color_g_not_number(self):
     with pytest.raises(ArrowParameterException):
         Arrow(one, one, one, color=(1, "Tests", 1))
示例#25
0
 def test_arrow_direction_decimal(self):
     with pytest.raises(ArrowParameterException):
         Arrow(3.5, one, one)