def test_isub(self): heal_amount = 5 heal = Heal(heal_amount=heal_amount) sub_amount = 3 expected_heal = Heal(heal_amount=heal_amount - sub_amount) heal -= sub_amount self.assertEqual(heal, expected_heal)
def test_iadd(self): heal_amount = 5 heal = Heal(heal_amount=heal_amount) add_amount = 10 expected_heal = Heal(heal_amount=heal_amount + add_amount) heal += add_amount self.assertEqual(heal, expected_heal)
def test_isub_negative_amount(self): """ Should reset it to 0 rather than have it stay negative""" heal_amount = 5 heal = Heal(heal_amount=heal_amount) sub_amount = 10 expected_heal = Heal(heal_amount=0) heal -= sub_amount self.assertEqual(heal, expected_heal)
def castSpell(self): if self._attackCounter > 0: return if self.stats['mana'] < 7: return self.stats['mana'] -= 7 # Każdy czar kosztuje 7 many self._attackCounter = 40 _modifier = (self.stats['intelligence'] * 67 + self.stats['agility'] * 33) / 10000.0 if self._spell & MAGIC_ICE: _id = 'hero_iceblast_' + str(random.randint(0, 1048576)) _layer = self._map.getLayer('Missiles') _layer.add( _id, Iceblast(self._map, _layer, _id, self._direction, self._pos, _modifier)) elif self._spell & MAGIC_FIRE: _id = 'hero_fireball_' + str(random.randint(0, 1048576)) _layer = self._map.getLayer('Missiles') _layer.add( _id, Fireball(self._map, _layer, _id, self._direction, self._pos, _modifier)) elif self._spell & MAGIC_HEAL: _id = 'hero_heal_' + str(random.randint(0, 1048576)) _layer = self._map.getLayer('Missiles') _layer.add( _id, Heal(self._map, _layer, _id, self._direction, self._pos, _modifier))
def __init__(self, screen): # bool pour jeu self.is_playing = 1 # charger le joueur self.all_player = pygame.sprite.Group() self.player = Player(self) self.all_player.add(self.player) # charger les monstres self.all_monsters = pygame.sprite.Group() # charger les heal self.all_heal = pygame.sprite.Group() self.heal = Heal(self) # charger le lance flamme self.all_fireblast = pygame.sprite.Group() self.fireblast = FireBlast(self) # charger le boss self.all_boss = pygame.sprite.Group() # charger le dico vide self.pressed = {} # mettre le boss sur False self.percent = 0 self.maxpercent = 200 self.percent_speed = 1 self.boss_is_coming = False # récupérer l'écran self.screen = screen
def test_rsub(self): heal_amount = 5 heal = Heal(heal_amount=heal_amount) amount = 10 expected_result = amount - heal_amount self.assertEqual(amount - heal, expected_result)
def test_sub(self): heal_amount = 5 heal = Heal(heal_amount=heal_amount) sub_amount = 3 expected_amount = 2 self.assertEqual(heal - sub_amount, expected_amount)
def test_radd(self): heal_amount = 5 heal = Heal(heal_amount=heal_amount) add_amount = 10 expected_amount = heal_amount + add_amount add_amount += heal self.assertEqual(add_amount, expected_amount)
def test_add(self): """ __add__ takes a numeric type (int/float) """ heal_amount = 5 heal = Heal(heal_amount=heal_amount) add_amount = 10 expected_amount = heal_amount + add_amount self.assertEqual(heal + add_amount, expected_amount)
def update(self): if random.randint(1, 3000) == 1 and self.getLife( True) < 1: # raz na jakiś czas możne się uleczyć self._attackCounter = 0 _id = 'mage_heal_' + str(random.randint(0, 1048576)) _layer = self._map.getLayer('Missiles') _layer.add( _id, Heal(self._map, _layer, _id, self._direction, self._pos)) return False return super(Mage, self).update()
def test_eq(self): """ __eq__ checks for the heal_amount being equal""" heal_1 = Heal(heal_amount=5) heal_2 = Heal(heal_amount=5) self.assertEqual(heal_1, heal_2)
def test_str(self): heal_amount = 5.111 heal = Heal(heal_amount=heal_amount) expected_str = f'{heal_amount:.2f}' self.assertEqual(str(heal), expected_str)