Exemple #1
0
    def execute(self, player: IPlayer, foes: List[IPlayer],
                dice_norm_result: float) -> None:
        successful_skill = False
        kill = False

        player.spend_mana(self.cost)
        self.communicator.informer.spent_mana(player.name, self.cost,
                                              self.name)
        foe = foes[0]
        damage = int(self.calculate_damage(player, dice_norm_result))
        defense = self.calculate_defense(foe)
        foe.suffer_damage(damage - defense)
        self.communicator.informer.suffer_damage(player, foe, damage)
        player.heal('health_points', damage)
        self.communicator.informer.heal(player, player, damage)

        if damage - defense > 0:
            successful_skill = True
        if not foe.is_alive():
            kill = True

        self.check_experience(player, successful_skill, kill)
Exemple #2
0
 def execute(self, player: IPlayer, foes: List[IPlayer],
             dice_norm_result: float) -> None:
     kill = False
     successful_skill = False
     player.spend_mana(self.cost)
     self.communicator.informer.spent_mana(player.name, self.cost,
                                           self.name)
     for foe in foes:
         if self.kind == 'inflict':
             damage = self.calculate_damage(player, dice_norm_result)
             defense = self.calculate_defense(foe)
             damage = math.ceil(damage - defense)
             if damage > 0:
                 successful_skill = True
                 foe.suffer_damage(damage)
                 self.communicator.informer.suffer_damage(
                     player, foe, damage)
             else:
                 self.communicator.informer.missed(player, foe)
         elif self.kind == 'recover':
             recover_result = self.calculate_recover(
                 player, dice_norm_result)
             foe.heal('health_points', recover_result)
             self.communicator.informer.heal(player, foe, recover_result)
         for side_effect in self.side_effects:
             if successful_skill:
                 foe.add_side_effect(side_effect)
                 self.communicator.informer.add_side_effect(
                     foe.name, side_effect)
         for side_effect in self.punishment_side_effects:
             player.add_side_effect(side_effect)
             self.communicator.informer.add_side_effect(
                 player.name, side_effect)
         if not foe.is_alive():
             kill = True
         print('\n')
     self.check_experience(player, successful_skill, kill)