Draw a map in a string to make the render in the screen easier

This commit is contained in:
Yohann D'ANELLO 2020-10-16 14:00:38 +02:00 committed by Nicolas Margulies
parent 1e7ca6026f
commit a0530b67fb
2 changed files with 4 additions and 0 deletions

View File

@ -28,6 +28,9 @@ class Map:
for x, c in enumerate(line)] for y, line in enumerate(lines)]
return Map(width, height, tiles)
def draw_string(self) -> str:
return "\n".join("".join(tile.char for tile in line) for line in self.tiles)
class Tile(Enum):
EMPTY = auto()

View File

@ -8,3 +8,4 @@ class TestInterfaces(unittest.TestCase):
m = Map.load_from_string("ab\ncd\n")
self.assertEqual(m.width, 2)
self.assertEqual(m.height, 2)
self.assertEqual(m.draw_string(), "ab\ncd")