Test monocles
This commit is contained in:
@ -1,11 +1,12 @@
|
||||
# Copyright (C) 2020 by ÿnérant, eichhornchen, nicomarg, charlse
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import random
|
||||
import unittest
|
||||
|
||||
from squirrelbattle.entities.items import BodySnatchPotion, Bomb, Heart, Item, \
|
||||
Explosion
|
||||
from squirrelbattle.entities.monsters import Tiger, Hedgehog, Rabbit, TeddyBear
|
||||
from squirrelbattle.entities.monsters import Tiger, Hedgehog, Rabbit,\
|
||||
TeddyBear, GiantSeaEagle
|
||||
from squirrelbattle.entities.friendly import Trumpet
|
||||
from squirrelbattle.entities.player import Player
|
||||
from squirrelbattle.interfaces import Entity, Map
|
||||
@ -264,3 +265,17 @@ class TestEntities(unittest.TestCase):
|
||||
|
||||
player_state = player.save_state()
|
||||
self.assertEqual(player_state["current_xp"], 10)
|
||||
|
||||
def test_critical_hit(self) -> None:
|
||||
"""
|
||||
Ensure that critical hits are working.
|
||||
"""
|
||||
random.seed(2) # Next random.randint(1, 100) will output 8
|
||||
self.player.critical = 10
|
||||
sea_eagle = GiantSeaEagle()
|
||||
self.map.add_entity(sea_eagle)
|
||||
sea_eagle.move(2, 6)
|
||||
old_health = sea_eagle.health
|
||||
self.player.hit(sea_eagle)
|
||||
self.assertEqual(sea_eagle.health,
|
||||
old_health - self.player.strength * 4)
|
||||
|
Reference in New Issue
Block a user