typy vole
This commit is contained in:
parent
c83499393a
commit
6d276939b0
2
game.py
2
game.py
@ -8,7 +8,7 @@ class Game:
|
|||||||
@Author: zbyv
|
@Author: zbyv
|
||||||
@Date: 22.11.2023
|
@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.__world = world
|
||||||
self.__hero = hero
|
self.__hero = hero
|
||||||
self.__home = home
|
self.__home = home
|
||||||
|
|||||||
@ -16,7 +16,7 @@ class GameObject:
|
|||||||
Pozice objektu
|
Pozice objektu
|
||||||
"""
|
"""
|
||||||
@property
|
@property
|
||||||
def position(self):
|
def position(self) -> Vector2:
|
||||||
return self.__position
|
return self.__position
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -25,7 +25,7 @@ class GameObject:
|
|||||||
Args:
|
Args:
|
||||||
direction: Vektor, o ktery se ma objekt posunout
|
direction: Vektor, o ktery se ma objekt posunout
|
||||||
"""
|
"""
|
||||||
def move(self, direction: Vector2):
|
def move(self, direction: Vector2) -> None:
|
||||||
self.__position += direction
|
self.__position += direction
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -34,5 +34,5 @@ class GameObject:
|
|||||||
Args:
|
Args:
|
||||||
gui: Gui, na ktere se ma objekt vykreslit
|
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)
|
gui.draw(self.__position.x, self.__position.y, self.__symbol)
|
||||||
2
gui.py
2
gui.py
@ -37,7 +37,7 @@ class Gui:
|
|||||||
"""
|
"""
|
||||||
Vycisti cele herni pole
|
Vycisti cele herni pole
|
||||||
"""
|
"""
|
||||||
def clear(self):
|
def clear(self) -> None:
|
||||||
self.__data = [" " for _ in range(self.__width * self.__height)]
|
self.__data = [" " for _ in range(self.__width * self.__height)]
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|||||||
11
vector2.py
11
vector2.py
@ -7,7 +7,7 @@ class Vector2:
|
|||||||
@Author: zbyv
|
@Author: zbyv
|
||||||
@Date: 22.11.2023
|
@Date: 22.11.2023
|
||||||
"""
|
"""
|
||||||
def __init__(self, x, y) -> None:
|
def __init__(self, x: int, y: int) -> None:
|
||||||
self.__x = x
|
self.__x = x
|
||||||
self.__y = y
|
self.__y = y
|
||||||
|
|
||||||
@ -15,14 +15,14 @@ class Vector2:
|
|||||||
`x` souradnice tohoto vektoru
|
`x` souradnice tohoto vektoru
|
||||||
"""
|
"""
|
||||||
@property
|
@property
|
||||||
def x(self):
|
def x(self) -> int:
|
||||||
return self.__x
|
return self.__x
|
||||||
|
|
||||||
"""
|
"""
|
||||||
`y` souradnice tohoto vektoru
|
`y` souradnice tohoto vektoru
|
||||||
"""
|
"""
|
||||||
@property
|
@property
|
||||||
def y(self):
|
def y(self) -> int:
|
||||||
return self.__y
|
return self.__y
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -34,7 +34,10 @@ class Vector2:
|
|||||||
"""
|
"""
|
||||||
Kouzelna metoda pro porovnani vektoru
|
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
|
return self.x == other.x and self.y == other.y
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|||||||
6
world.py
6
world.py
@ -18,14 +18,14 @@ class World:
|
|||||||
Sirka sveta
|
Sirka sveta
|
||||||
"""
|
"""
|
||||||
@property
|
@property
|
||||||
def width(self):
|
def width(self) -> int:
|
||||||
return self.__width
|
return self.__width
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Vyska sveta
|
Vyska sveta
|
||||||
"""
|
"""
|
||||||
@property
|
@property
|
||||||
def height(self):
|
def height(self) -> int:
|
||||||
return self.__height
|
return self.__height
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -37,7 +37,7 @@ class World:
|
|||||||
Returns:
|
Returns:
|
||||||
True pokud je policko prazdne, jinak False
|
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
|
return self.__data[position.y][position.x] == 0
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user