Grid.move()

This commit is contained in:
Stefan Harmuth 2023-09-17 04:08:00 +02:00
parent cc9a6bcbc5
commit 75013fbcdd

View File

@ -120,6 +120,12 @@ class Grid:
return value
def move(self, pos: Coordinate, vec: Coordinate,):
target = pos + vec
self.set(target, self.get(pos))
if pos in self.__grid:
del self.__grid[pos]
def add(self, pos: Coordinate, value: Numeric = 1) -> Numeric:
return self.set(pos, self.get(pos) + value)
@ -448,7 +454,7 @@ class Grid:
put_y = y
put_x += 1
def print(self, spacer: str = "", true_char: str = '#', false_char: str = " ", translate: dict = None, mark: list = None, z_level: int = None):
def print(self, spacer: str = "", true_char: str = '#', false_char: str = " ", translate: dict = None, mark: list = None, z_level: int = None, bool_mode: bool = False):
if translate is None:
translate = {}
@ -463,6 +469,8 @@ class Grid:
if mark and pos in mark:
print("X", end="")
elif bool_mode:
print(true_char if self.get(pos) else false_char, end="")
else:
value = self.get(pos)
if isinstance(value, list):