Added tests for familiars
This commit is contained in:
parent
8e0b8d4fee
commit
73952a42f3
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user