From f821fef43017346a159208208ccb9acfa9ca4f6c Mon Sep 17 00:00:00 2001 From: eichhornchen Date: Tue, 5 Jan 2021 09:38:49 +0100 Subject: [PATCH] added tests --- squirrelbattle/tests/entities_test.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/squirrelbattle/tests/entities_test.py b/squirrelbattle/tests/entities_test.py index 341461f..7d4981f 100644 --- a/squirrelbattle/tests/entities_test.py +++ b/squirrelbattle/tests/entities_test.py @@ -100,6 +100,7 @@ class TestEntities(unittest.TestCase): entity.move(2, 6) fam.move(2, 7) + #test fighting entity.health = 2 entity.paths = [] entity.recalculate_paths() @@ -107,14 +108,30 @@ class TestEntities(unittest.TestCase): self.map.tick(self.player) self.assertTrue(entity.dead) + #test finding a new target + entity2 = Rabbit() + self.map.add_entity(entity2) + entity2.move(2, 6) + self.map.tick(self.player) + self.assertTrue(fam.target==entity2) + self.map.remove_entity(entity2) + + #test following the player and finding the player as target self.player.move(5, 5) fam.move(4, 5) - fam.target = self.player + fam.target = None self.player.move_down() self.map.tick(self.player) + self.assertTrue(fam.target==self.player) self.assertEqual(fam.y, 5) self.assertEqual(fam.x, 5) + #test random move + fam.move(13, 20) + fam.target=self.player + self.map.tick(self.player) + self.assertTrue(fam.x!=20 or fam.y!=13) + def test_items(self) -> None: """ Tests some random stuff with items.