

def takes_damage(self, damages, attacker=None):
    total = 0
    absorb = self.absorb.calculate()
    for (damage_type, damage) in damages.items():
        d = (damage - absorb.get(damage_type, 0))
        if (d > 0):
            total += d
    self.world.log.debug(('%s hit for %s damage' % (self.fancy_name(), str(total))))
    self.hp -= total
    if attacker:
        self.update_output(('%s hit you for %s damage.' % (attacker, str(total))))
    else:
        self.update_output(('You were hit for %s damage.' % str(total)))
    if (self.hp <= 0):
        self.battle.remove_character(self)
        self.battle = None
        self.set_mode('normal')
        self.death()
    return total

dataset/ETHPy150Open shinymud/ShinyMUD/src/shinymud/models/character.py Character.takes_damage/original