def test_element_rotation_o():
    # blue I
    element = Element('O')
    # anchor - точка вращения
    anchor = Point(8, 17)
    expected = [Point(8, 17), Point(9, 17), Point(8, 16), Point(9, 16)]
    assert expected == element.get_all_coords(anchor, rotation=0)
    expected = [Point(8, 17), Point(8, 16), Point(7, 17), Point(7, 16)]
    assert expected == element.get_all_coords(anchor, rotation=1)
def test_element_rotation_i():
    # blue I
    element = Element('I')
    # точка вращения
    anchor = Point(8, 16)
    expected = [Point(8, 17), Point(8, 16), Point(8, 15), Point(8, 14)]
    assert expected == element.get_all_coords_after_rotation(anchor,
                                                             rotation=0)
    expected = [Point(9, 16), Point(8, 16), Point(7, 16), Point(6, 16)]
    assert expected == element.get_all_coords_after_rotation(anchor,
                                                             rotation=1)
Exemple #3
0
    def predict_figure_points_after_rotation(self,
                                             x: int = None,
                                             y: int = None,
                                             figure: Union[Element,
                                                           Text] = None,
                                             rotation: int = 0):
        # x, y - координата приходящая с сервера в 'currentFigurePoint' содержит координату новой фигурки.
        # [0, 0] - левый нижний угол фигуры
        # be aware: this method is experemental and can cause issues in edge cases
        # метод возвращает все точки Фигуры при rotation (1 == 90 градусам)
        # подробнее про rotation в методе get_shift_after_rotation
        if not x or not y or not figure:
            anchor: Point = self.get_current_figure_point()
            figure: Element = self.get_current_element()
        else:
            anchor: Point = Point(x, y)
            figure: Element = prepare_element(type_)

        return figure.get_all_coords_after_rotation(anchor, rotation)
Exemple #4
0
 def get_current_figure_point(self) -> Point:
     return Point(
         int(self._json["currentFigurePoint"]["x"]),
         int(self._json["currentFigurePoint"]["y"]),
     )
Exemple #5
0
 def get_point_by_shift(self, shift: int) -> Point:
     return Point(shift % self._size, shift / self._size)
Exemple #6
0
 def _strpos2pt(self, strpos: int) -> Point:
     return Point(*self._strpos2xy(strpos))