# Path: roglick/engine/ecs/exceptions.py
# class NoComponentForEntityError(Exception):
# class NotAComponentError(Exception):
#     def __init__(self, entity, component_type):
#     def __init__(self, obj):
# 
# Path: roglick/engine/ecs/base.py
# class SystemBase(object):
#     """Systems are the workhorses of the ECS architecture.
# 
#     A System takes care of the actual execution of game logic, each one being
#     responsible for implementing a concrete subset of the game's overall rules.
#     """
#     def __init__(self):
#         self._entity_manager = None
#         self._world = None
# 
#     def set_entity_manager(self, entity_manager):
#         self._entity_manager = entity_manager
# 
#     def set_world_manager(self, world_manager):
#         self._world = world_manager
# 
#     def execute(self):
#         """Execute this system on its EntityManager."""
#         pass
# 
# Path: roglick/engine/event.py
# class Event(object):
#     def __init__(self, entity=None):
#     def stop(self):
#     def propagate(self):
#     def __repr__(self):
# def register(handler, event_class=None):
# def dispatch(event):
# def event_handler(*events):
#     def decorator(meth):
# 
# Path: roglick/engine/random.py
# class Random(object):
#     def __init__(self, seed=None, generator=None):
#     def generator(self):
#     def get_int(self, min=None, max=None):
#     def flip_coin(self):
#     def roll_dice(self, num=1, sides=6):
#     def one_in(self, odds):
#     def probability(self, prob):
#     def choice(self, choices):
#     def shuffle(self, deck):
# def get_int(*args, **kwargs):
# def flip_coin():
# def roll_dice(*args, **kwargs):
# def one_in(*args, **kwargs):
# def probability(*args, **kwargs):
# def choice(*args, **kwargs):
# def shuffle(*args, **kwargs):
# 
# Path: roglick.py



from roglick.engine.ecs import SystemBase, exceptions
from roglick.engine import event, random
from roglick import events


class CombatSystem(SystemBase):
    @event.event_handler(events.AttackEvent)
    def attack_handler(self, atk_event):
        atk_check = events.SkillCheckEvent(
                atk_event.entity, 'melee.swords.short_sword')
        event.dispatch(atk_check)

        if atk_check.result.success:
            hit_event = events.HitEvent(**atk_event.kwargs)
            hit_event.def_mod = atk_check.result.dos

            event.dispatch(hit_event)
        else:
            event.dispatch(events.MessageEvent("You missed!"))

    @event.event_handler(events.HitEvent)
    def hit_handler(self, hit_event):
        def_check = events.SkillCheckEvent(
                hit_event.defender, 'melee.shield')
        event.dispatch(def_check)

        if def_check.result.success:

# Path: roglick/engine/ecs/exceptions.py
# class NoComponentForEntityError(Exception):
# class NotAComponentError(Exception):
#     def __init__(self, entity, component_type):
#     def __init__(self, obj):
# 
# Path: roglick/engine/ecs/base.py
# class SystemBase(object):
#     """Systems are the workhorses of the ECS architecture.
# 
#     A System takes care of the actual execution of game logic, each one being
#     responsible for implementing a concrete subset of the game's overall rules.
#     """
#     def __init__(self):
#         self._entity_manager = None
#         self._world = None
# 
#     def set_entity_manager(self, entity_manager):
#         self._entity_manager = entity_manager
# 
#     def set_world_manager(self, world_manager):
#         self._world = world_manager
# 
#     def execute(self):
#         """Execute this system on its EntityManager."""
#         pass
# 
# Path: roglick/engine/event.py
# class Event(object):
#     def __init__(self, entity=None):
#     def stop(self):
#     def propagate(self):
#     def __repr__(self):
# def register(handler, event_class=None):
# def dispatch(event):
# def event_handler(*events):
#     def decorator(meth):
# 
# Path: roglick/engine/random.py
# class Random(object):
#     def __init__(self, seed=None, generator=None):
#     def generator(self):
#     def get_int(self, min=None, max=None):
#     def flip_coin(self):
#     def roll_dice(self, num=1, sides=6):
#     def one_in(self, odds):
#     def probability(self, prob):
#     def choice(self, choices):
#     def shuffle(self, deck):
# def get_int(*args, **kwargs):
# def flip_coin():
# def roll_dice(*args, **kwargs):
# def one_in(*args, **kwargs):
# def probability(*args, **kwargs):
# def choice(*args, **kwargs):
# def shuffle(*args, **kwargs):
# 
# Path: roglick.py



# Path: roglick/systems/combat.py
from roglick.engine.ecs import SystemBase, exceptions
from roglick.engine import event, random
from roglick import events



class CombatSystem(SystemBase):
    @event.event_handler(events.AttackEvent)
    def attack_handler(self, atk_event):
        atk_check = events.SkillCheckEvent(
                atk_event.entity, 'melee.swords.short_sword')
        event.dispatch(atk_check)

        if atk_check.result.success:
            hit_event = events.HitEvent(**atk_event.kwargs)
            hit_event.def_mod = atk_check.result.dos

            event.dispatch(hit_event)
        else:
            event.dispatch(events.MessageEvent("You missed!"))

    @event.event_handler(events.HitEvent)
    def hit_handler(self, hit_event):
        def_check = events.SkillCheckEvent(
                hit_event.defender, 'melee.shield')
        event.dispatch(def_check)

        if def_check.result.success:

            event.dispatch(events.MessageEvent("It blocked your attack!"))