Added tests for familiars

This commit is contained in:
eichhornchen 2020-12-31 15:43:38 +01:00
parent 8e0b8d4fee
commit 73952a42f3
1 changed files with 27 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import unittest
from squirrelbattle.entities.items import BodySnatchPotion, Bomb, Heart, Item, \ from squirrelbattle.entities.items import BodySnatchPotion, Bomb, Heart, Item, \
Explosion Explosion
from squirrelbattle.entities.monsters import Tiger, Hedgehog, Rabbit, TeddyBear from squirrelbattle.entities.monsters import Tiger, Hedgehog, Rabbit, TeddyBear
from squirrelbattle.entities.friendly import Trumpet
from squirrelbattle.entities.player import Player from squirrelbattle.entities.player import Player
from squirrelbattle.interfaces import Entity, Map from squirrelbattle.interfaces import Entity, Map
from squirrelbattle.resources import ResourceManager from squirrelbattle.resources import ResourceManager
@ -89,6 +90,31 @@ class TestEntities(unittest.TestCase):
self.assertTrue(entity.dead) self.assertTrue(entity.dead)
self.assertGreaterEqual(self.player.current_xp, 3) 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: def test_items(self) -> None:
""" """
Tests some random stuff with items. Tests some random stuff with items.
@ -219,3 +245,4 @@ class TestEntities(unittest.TestCase):
player_state = player.save_state() player_state = player.save_state()
self.assertEqual(player_state["current_xp"], 10) self.assertEqual(player_state["current_xp"], 10)