Test entity movements and fights with players
This commit is contained in:
parent
e88b4ee775
commit
af39a305b1
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue