Draw a map in a string to make the render in the screen easier
This commit is contained in:
		@@ -26,6 +26,9 @@ class Map:
 | 
				
			|||||||
                  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, chars)
 | 
					        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:
 | 
					class Tile:
 | 
				
			||||||
    x: int
 | 
					    x: int
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,3 +8,4 @@ class TestInterfaces(unittest.TestCase):
 | 
				
			|||||||
        m = Map.load_from_string("ab\ncd\n")
 | 
					        m = Map.load_from_string("ab\ncd\n")
 | 
				
			||||||
        self.assertEqual(m.width, 2)
 | 
					        self.assertEqual(m.width, 2)
 | 
				
			||||||
        self.assertEqual(m.height, 2)
 | 
					        self.assertEqual(m.height, 2)
 | 
				
			||||||
 | 
					        self.assertEqual(m.draw_string(), "ab\ncd")
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user