Grid.count(); Grid.print() not handles Enums
This commit is contained in:
parent
00de38a277
commit
642a32b884
@ -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()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user