Better usage of enumerations
This commit is contained in:
		
				
					committed by
					
						
						Nicolas Margulies
					
				
			
			
				
	
			
			
			
						parent
						
							ce0d5d8ffd
						
					
				
				
					commit
					9c6f22ccf8
				
			@@ -26,7 +26,7 @@ class Map:
 | 
				
			|||||||
        lines = [line for line in lines if line]
 | 
					        lines = [line for line in lines if line]
 | 
				
			||||||
        height = len(lines)
 | 
					        height = len(lines)
 | 
				
			||||||
        width = len(lines[0])
 | 
					        width = len(lines[0])
 | 
				
			||||||
        tiles = [[Tile.from_char(c)
 | 
					        tiles = [[Tile(c)
 | 
				
			||||||
                  for x, c in enumerate(line)] for y, line in enumerate(lines)]
 | 
					                  for x, c in enumerate(line)] for y, line in enumerate(lines)]
 | 
				
			||||||
        return Map(width, height, tiles)
 | 
					        return Map(width, height, tiles)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -40,13 +40,6 @@ class Tile(Enum):
 | 
				
			|||||||
    WALL = '#'
 | 
					    WALL = '#'
 | 
				
			||||||
    FLOOR = '.'
 | 
					    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:
 | 
					class Entity:
 | 
				
			||||||
    x: int
 | 
					    x: int
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user