summaryrefslogtreecommitdiff
path: root/Walls.py
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.kronqvist@iki.fi>2025-11-03 23:10:04 +0200
committerJoel Kronqvist <joel.kronqvist@iki.fi>2025-11-03 23:10:04 +0200
commitd1c404fe8eac3c743004a9a48a683e9361c8f7b3 (patch)
treef5df16492fd5cfc3a2915c678306b53c212edb5e /Walls.py
parentef6abc27cec35e32acef66c5077ffcc6bedde983 (diff)
downloadSnakePuzzle-d1c404fe8eac3c743004a9a48a683e9361c8f7b3.tar.gz
SnakePuzzle-d1c404fe8eac3c743004a9a48a683e9361c8f7b3.zip
fix: added typing
Diffstat (limited to 'Walls.py')
-rw-r--r--Walls.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/Walls.py b/Walls.py
index d591291..a365b89 100644
--- a/Walls.py
+++ b/Walls.py
@@ -8,11 +8,11 @@ class Walls:
Useful as a wrapper to later increase performance of these operations."""
- def __init__(self, walls):
- _walls = []
+ def __init__(self, walls: list[Vec2]) -> None:
self._walls = walls
- def fromString(wallString):
+ @staticmethod
+ def fromString(wallString: str) -> 'Walls':
walls = []
y = 0
for line in wallString.split('\n'):
@@ -24,15 +24,19 @@ class Walls:
y += 1
return Walls(walls)
- def walls(self):
+ @staticmethod
+ def empty() -> 'Walls':
+ return Walls([])
+
+ def walls(self) -> list[Vec2]:
return self._walls
- def wallAt(self, pos):
+ def wallAt(self, pos: Vec2) -> bool:
return (pos in self._walls)
- def width(self):
+ def width(self) -> int:
return max(self._walls, key=lambda p: p.x).x + 1
- def height(self):
+ def height(self) -> int:
return max(self._walls, key=lambda p: p.y).y + 1