From ae505166b7815ef4acc4fb5d552f7367643492ef Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Wed, 6 Jan 2021 17:39:13 +0100 Subject: [PATCH] Disable critical hits during tests --- squirrelbattle/interfaces.py | 4 ++-- squirrelbattle/tests/entities_test.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/squirrelbattle/interfaces.py b/squirrelbattle/interfaces.py index b6a3a51..e4557d1 100644 --- a/squirrelbattle/interfaces.py +++ b/squirrelbattle/interfaces.py @@ -444,10 +444,10 @@ class FightingEntity(Entity): """ Deals damage to the opponent, based on the stats """ - diceroll = randint(0, 100) + diceroll = randint(1, 100) damage = self.strength string = " " - if diceroll <= self.critical: # It is a critical hit + if diceroll <= self.critical: # It is a critical hit damage *= 4 string = _(" It's a critical hit! ") return _("{name} hits {opponent}.")\ diff --git a/squirrelbattle/tests/entities_test.py b/squirrelbattle/tests/entities_test.py index 1d7a7a9..97f0ef8 100644 --- a/squirrelbattle/tests/entities_test.py +++ b/squirrelbattle/tests/entities_test.py @@ -77,6 +77,7 @@ class TestEntities(unittest.TestCase): {self.player.name.capitalize()} takes {entity.strength} damage.") # Fight the rabbit + self.player.critical = 0 old_health = entity.health self.player.move_down() self.assertEqual(entity.health, old_health - self.player.strength)