From c9d136929b563f87da6010a4728e38bce9acdec9 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Fri, 16 Oct 2020 17:41:37 +0200 Subject: [PATCH] Better usage of enumerations --- dungeonbattle/interfaces.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/dungeonbattle/interfaces.py b/dungeonbattle/interfaces.py index b7229a8..5fc6843 100644 --- a/dungeonbattle/interfaces.py +++ b/dungeonbattle/interfaces.py @@ -24,7 +24,7 @@ class Map: lines = [line for line in lines if line] height = len(lines) width = len(lines[0]) - tiles = [[Tile.from_char(c) + tiles = [[Tile(c) for x, c in enumerate(line)] for y, line in enumerate(lines)] return Map(width, height, tiles) @@ -38,13 +38,6 @@ class Tile(Enum): WALL = '#' FLOOR = '.' - @staticmethod - def from_char(c: str): - for t in Tile: - if t.value == c: - return t - raise ValueError(f"Tile not found : {c}") - class Entity: x: int