Fix broken tests
This commit is contained in:
parent
ac22aef860
commit
8db00bcaa6
|
@ -47,11 +47,9 @@ class Game:
|
|||
"""
|
||||
# TODO generate a new map procedurally
|
||||
self.map = Map.load("resources/example_map_2.txt")
|
||||
self.map.currenty = 1
|
||||
self.map.currentx = 6
|
||||
self.player = Player()
|
||||
self.map.add_entity(self.player)
|
||||
self.player.move(1, 14)
|
||||
self.player.move(self.map.start_y, self.map.start_x)
|
||||
self.map.spawn_random_entities(randint(3, 10))
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -12,6 +12,9 @@ class TestEntities(unittest.TestCase):
|
|||
Load example map that can be used in tests.
|
||||
"""
|
||||
self.map = Map.load("resources/example_map.txt")
|
||||
self.player = Player()
|
||||
self.map.add_entity(self.player)
|
||||
self.player.move(self.map.start_y, self.map.start_x)
|
||||
|
||||
def test_basic_entities(self) -> None:
|
||||
"""
|
||||
|
@ -48,21 +51,29 @@ class TestEntities(unittest.TestCase):
|
|||
|
||||
entity = Hedgehog()
|
||||
self.map.add_entity(entity)
|
||||
entity.move(2, 6)
|
||||
entity.move(3, 6)
|
||||
self.map.tick()
|
||||
self.assertFalse(entity.y == 2 and entity.x == 6)
|
||||
self.assertTrue(entity.y == 2 and entity.x == 6)
|
||||
|
||||
def test_items(self) -> None:
|
||||
"""
|
||||
Test some random stuff with items.
|
||||
"""
|
||||
item = Item()
|
||||
self.map.add_entity(item)
|
||||
self.assertFalse(item.held)
|
||||
item.hold()
|
||||
item.hold(self.player)
|
||||
self.assertTrue(item.held)
|
||||
item.drop(42, 42)
|
||||
self.assertEqual(item.y, 42)
|
||||
self.assertEqual(item.x, 42)
|
||||
item.drop(2, 6)
|
||||
self.assertEqual(item.y, 2)
|
||||
self.assertEqual(item.x, 6)
|
||||
|
||||
# Pick up item
|
||||
self.player.move_down()
|
||||
self.assertTrue(item.held)
|
||||
self.assertEqual(item.held_by, self.player)
|
||||
self.assertIn(item, self.player.inventory)
|
||||
self.assertNotIn(item, self.map.entities)
|
||||
|
||||
def test_bombs(self) -> None:
|
||||
"""
|
||||
|
|
|
@ -19,7 +19,7 @@ class TestInterfaces(unittest.TestCase):
|
|||
Try to load a map from a file.
|
||||
"""
|
||||
m = Map.load("resources/example_map.txt")
|
||||
self.assertEqual(m.width, 52)
|
||||
self.assertEqual(m.width, 44)
|
||||
self.assertEqual(m.height, 17)
|
||||
|
||||
def test_tiles(self) -> None:
|
||||
|
|
Loading…
Reference in New Issue