Test entity movements and fights with players

This commit is contained in:
Yohann D'ANELLO 2020-11-11 17:23:31 +01:00
parent e88b4ee775
commit af39a305b1
1 changed files with 23 additions and 0 deletions

View File

@ -51,10 +51,33 @@ class TestEntities(unittest.TestCase):
entity = Hedgehog()
self.map.add_entity(entity)
entity.move(15, 44)
# Move randomly
self.map.tick()
self.assertFalse(entity.y == 15 and entity.x == 44)
# Move to the player
entity.move(3, 6)
self.map.tick()
self.assertTrue(entity.y == 2 and entity.x == 6)
# Hedgehog should fight
old_health = self.player.health
self.map.tick()
self.assertTrue(entity.y == 2 and entity.x == 6)
self.assertEqual(old_health - entity.strength, self.player.health)
# Fight the hedgehog
old_health = entity.health
self.player.move_down()
self.assertEqual(entity.health, old_health - self.player.strength)
self.assertFalse(entity.dead)
old_health = entity.health
self.player.move_down()
self.assertEqual(entity.health, old_health - self.player.strength)
self.assertTrue(entity.dead)
self.assertGreaterEqual(self.player.current_xp, 3)
def test_items(self) -> None:
"""
Test some random stuff with items.