Grid.count(); Grid.print() not handles Enums

This commit is contained in:
Stefan Harmuth 2022-12-14 06:51:55 +01:00
parent 00de38a277
commit 642a32b884

View File

@ -143,6 +143,9 @@ class Grid:
def getOnCount(self) -> int:
return len(self.__grid)
def count(self, value: Any) -> int:
return len([x for x in self.values() if x == value])
def isSet(self, pos: Coordinate) -> bool:
return pos in self.__grid
@ -364,7 +367,11 @@ class Grid:
elif true_char:
print(true_char if self.get(Coordinate(x, y)) else false_char, end="")
else:
print(self.get(Coordinate(x, y)), end="")
value = self.get(Coordinate(x, y))
if isinstance(value, Enum):
print(value.value, end="")
else:
print(value, end="")
print(spacer, end="")
print()