diff --git a/dungeonbattle/interfaces.py b/dungeonbattle/interfaces.py index a87825f..507ebde 100644 --- a/dungeonbattle/interfaces.py +++ b/dungeonbattle/interfaces.py @@ -1,4 +1,6 @@ #!/usr/bin/env python +from enum import Enum, auto + class Map: @@ -24,18 +26,24 @@ class Map: lines = [line for line in lines if line] height = len(lines) width = len(lines[0]) - return Map(width, height, lines, []) + tiles = [[Tile.from_char(c) + for x, c in enumerate(line)] for y, line in enumerate(lines)] + return Map(width, height, tiles) + + +class Tile(Enum): + EMPTY = auto() + WALL = auto() + FLOOR = auto() + + @staticmethod + def from_char(c: str): + return {'#': Tile.WALL, '.': Tile.FLOOR, ' ': Tile.EMPTY}[c] class Entity: - y: int x: int - img: str - - def __init__(self, y: int, x: int, img: str): - self.y = y - self.x = x - self.img = img + y: int def move(self, x: int, y: int) -> None: self.x = x