From 73952a42f32893b1a27494d3c28d58ccac6ef3be Mon Sep 17 00:00:00 2001 From: eichhornchen Date: Thu, 31 Dec 2020 15:43:38 +0100 Subject: [PATCH] Added tests for familiars --- squirrelbattle/tests/entities_test.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/squirrelbattle/tests/entities_test.py b/squirrelbattle/tests/entities_test.py index 221fa5f..5f9d298 100644 --- a/squirrelbattle/tests/entities_test.py +++ b/squirrelbattle/tests/entities_test.py @@ -6,6 +6,7 @@ import unittest from squirrelbattle.entities.items import BodySnatchPotion, Bomb, Heart, Item, \ Explosion from squirrelbattle.entities.monsters import Tiger, Hedgehog, Rabbit, TeddyBear +from squirrelbattle.entities.friendly import Trumpet from squirrelbattle.entities.player import Player from squirrelbattle.interfaces import Entity, Map from squirrelbattle.resources import ResourceManager @@ -89,6 +90,31 @@ class TestEntities(unittest.TestCase): self.assertTrue(entity.dead) self.assertGreaterEqual(self.player.current_xp, 3) + # Test the familiars + fam = Trumpet() + entity = Rabbit() + self.map.add_entity(entity) + self.map.add_entity(fam) + + self.player.move(1,6) + entity.move(2,6) + fam.move(2,7) + + entity.health = 2 + entity.paths = [] + entity.recalculate_paths() + fam.target = entity + self.map.tick(self.player) + self.assertTrue(entity.dead) + + self.player.move(5,5) + fam.move(4,5) + fam.target = self.player + self.player.move_down() + self.map.tick(self.player) + self.assertEqual(fam.y, 5) + self.assertEqual(fam.x, 5) + def test_items(self) -> None: """ Tests some random stuff with items. @@ -219,3 +245,4 @@ class TestEntities(unittest.TestCase): player_state = player.save_state() self.assertEqual(player_state["current_xp"], 10) +