diff --git a/dungeonbattle/interfaces.py b/dungeonbattle/interfaces.py index 1674427..838cbec 100644 --- a/dungeonbattle/interfaces.py +++ b/dungeonbattle/interfaces.py @@ -26,6 +26,9 @@ class Map: for x, c in enumerate(line)] for y, line in enumerate(lines)] return Map(width, height, chars) + def draw_string(self) -> str: + return "\n".join("".join(tile.char for tile in line) for line in self.tiles) + class Tile: x: int diff --git a/dungeonbattle/interfaces_test.py b/dungeonbattle/interfaces_test.py index a987b37..479a9ac 100644 --- a/dungeonbattle/interfaces_test.py +++ b/dungeonbattle/interfaces_test.py @@ -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")