diff --git a/game.py b/game.py index 1f74039..a048402 100644 --- a/game.py +++ b/game.py @@ -8,7 +8,7 @@ class Game: @Author: zbyv @Date: 22.11.2023 """ - def __init__(self, world: World, hero: GameObject, home: GameObject): + def __init__(self, world: World, hero: GameObject, home: GameObject) -> None: self.__world = world self.__hero = hero self.__home = home diff --git a/gameobject.py b/gameobject.py index 45e2275..c05a972 100644 --- a/gameobject.py +++ b/gameobject.py @@ -16,7 +16,7 @@ class GameObject: Pozice objektu """ @property - def position(self): + def position(self) -> Vector2: return self.__position """ @@ -25,7 +25,7 @@ class GameObject: Args: direction: Vektor, o ktery se ma objekt posunout """ - def move(self, direction: Vector2): + def move(self, direction: Vector2) -> None: self.__position += direction """ @@ -34,5 +34,5 @@ class GameObject: Args: gui: Gui, na ktere se ma objekt vykreslit """ - def draw(self, gui: Gui): + def draw(self, gui: Gui) -> None: gui.draw(self.__position.x, self.__position.y, self.__symbol) \ No newline at end of file diff --git a/gui.py b/gui.py index 6489632..c5c90b7 100644 --- a/gui.py +++ b/gui.py @@ -37,7 +37,7 @@ class Gui: """ Vycisti cele herni pole """ - def clear(self): + def clear(self) -> None: self.__data = [" " for _ in range(self.__width * self.__height)] """ diff --git a/vector2.py b/vector2.py index fee7617..1efe4e7 100644 --- a/vector2.py +++ b/vector2.py @@ -7,7 +7,7 @@ class Vector2: @Author: zbyv @Date: 22.11.2023 """ - def __init__(self, x, y) -> None: + def __init__(self, x: int, y: int) -> None: self.__x = x self.__y = y @@ -15,14 +15,14 @@ class Vector2: `x` souradnice tohoto vektoru """ @property - def x(self): + def x(self) -> int: return self.__x """ `y` souradnice tohoto vektoru """ @property - def y(self): + def y(self) -> int: return self.__y """ @@ -34,7 +34,10 @@ class Vector2: """ Kouzelna metoda pro porovnani vektoru """ - def __eq__(self, other) -> bool: + def __eq__(self, other: object) -> bool: + if not isinstance(other, Vector2): + return NotImplemented + return self.x == other.x and self.y == other.y """ diff --git a/world.py b/world.py index e8b4e58..6ba7b05 100644 --- a/world.py +++ b/world.py @@ -18,14 +18,14 @@ class World: Sirka sveta """ @property - def width(self): + def width(self) -> int: return self.__width """ Vyska sveta """ @property - def height(self): + def height(self) -> int: return self.__height """ @@ -37,7 +37,7 @@ class World: Returns: True pokud je policko prazdne, jinak False """ - def is_empty(self, position: Vector2): + def is_empty(self, position: Vector2) -> bool: return self.__data[position.y][position.x] == 0 """