2020-10-09 16:17:41 +00:00
|
|
|
import unittest
|
|
|
|
|
2020-11-06 19:26:10 +00:00
|
|
|
from dungeonbattle.display.texturepack import TexturePack
|
2020-11-06 15:13:28 +00:00
|
|
|
from dungeonbattle.interfaces import Map, Tile
|
2020-10-09 16:17:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestInterfaces(unittest.TestCase):
|
2020-10-09 16:24:13 +00:00
|
|
|
def test_map(self) -> None:
|
2020-10-16 16:05:49 +00:00
|
|
|
"""
|
|
|
|
Create a map and check that it is well parsed.
|
|
|
|
"""
|
2020-11-06 19:26:10 +00:00
|
|
|
m = Map.load_from_string(".#\n#.\n")
|
2020-10-09 16:17:41 +00:00
|
|
|
self.assertEqual(m.width, 2)
|
|
|
|
self.assertEqual(m.height, 2)
|
2020-11-06 19:26:10 +00:00
|
|
|
self.assertEqual(m.draw_string(TexturePack.ASCII_PACK), ".#\n#.")
|
2020-11-06 15:13:28 +00:00
|
|
|
|
|
|
|
def test_load_map(self) -> None:
|
|
|
|
"""
|
|
|
|
Try to load a map from a file.
|
|
|
|
"""
|
|
|
|
m = Map.load("example_map.txt")
|
|
|
|
self.assertEqual(m.width, 52)
|
|
|
|
self.assertEqual(m.height, 17)
|
|
|
|
|
|
|
|
def test_tiles(self) -> None:
|
|
|
|
"""
|
|
|
|
Test some things about tiles.
|
|
|
|
"""
|
|
|
|
self.assertFalse(Tile.FLOOR.is_wall())
|
|
|
|
self.assertTrue(Tile.WALL.is_wall())
|
|
|
|
self.assertFalse(Tile.EMPTY.is_wall())
|
|
|
|
self.assertTrue(Tile.FLOOR.can_walk())
|
|
|
|
self.assertFalse(Tile.WALL.can_walk())
|
|
|
|
self.assertTrue(Tile.EMPTY.can_walk())
|