Files
dungeon-sheets/dungeonsheets/encounter/events.py
T
2021-05-23 14:52:18 -04:00

29 lines
930 B
Python

class Event:
"""An event between one and possibly more entities"""
def __init__(self, action, *args, **kwargs):
self.action = action
self.subj_hp = action.subj.current_hp
class AttackEvent(Event):
"""An attack action completed"""
def __init__(self, action, result, damage, is_hit):
super(AttackEvent, self).__init__(action)
if hasattr(self.action, "obj"):
self.obj_hp = self.action.obj.current_hp
self.result = result
self.damage = damage
self.is_hit = is_hit
def __str__(self):
if self.is_hit:
return f"{self.action.subj.name} Hit! with a {self.result} for {self.damage} damage, leaving {self.action.obj.name} with {self.obj_hp} hitpoints"
else:
return f"{self.action.subj.name} Missed! with a {self.result}. {self.action.obj.name} has {self.obj_hp} hp remaining."
# TODO: Support more events