# Path: compositecore.py
# class Leaf(Component):
#     """
#     Abstract leaf class of composite design pattern.
# 
#     Component classes of leaf type should inherit from this class.
#     """
# 
#     def __init__(self):
#         super(Leaf, self).__init__()
# 
#     def get_relative_of_type(self, component_type):
#         return self.parent.get_child_or_ancestor(component_type)
# 
#     def has_relative_of_type(self, component_type):
#         return self.parent.has_child_or_ancestor(component_type)
# 
# Path: messenger.py
# EQUIP_MESSAGE = "%(source_entity)s equips %(item)s."
# UNEQUIP_MESSAGE = "%(source_entity)s puts away %(item)s."
# HEAL_MESSAGE = "%(source_entity)s heals %(target_entity)s for %(health)s health."
# HEALTH_POTION_MESSAGE = "The health potion heals %(target_entity)s for %(health)s health."
# DISSOLVE_MESSAGE = "%(source_entity)s dissolves %(target_entity)s for %(damage)s damage."
# HIT_MESSAGE = "%(source_entity)s hits %(target_entity)s for %(damage)s damage."
# MISS_MESSAGE = "%(source_entity)s misses %(target_entity)s."
# CRIT_MESSAGE = "%(source_entity)s critically hits %(target_entity)s for %(damage)s damage."
# HAUNT_MESSAGE = "%(source_entity)s haunts the %(target_entity)s!"
# HEART_STOP_MESSAGE = "%(target_entity)s clutches its heart."
# DARKNESS_MESSAGE = "An unnatural darkness fills the dungeon."
# PICK_UP_MESSAGE = "You pick up %(item)s."
# POISON_MESSAGE = "%(target_entity)s takes %(damage)s in poison damage."
# BLEED_MESSAGE = "%(target_entity)s is bleeding out %(damage)s damage."
# DOWN_STAIRS_HEAL_MESSAGE = "Your feel vitalized by your progress, you regain %(health)s health."
# FALL_DOWN_MESSAGE = "You take a damage of %(damage)s from the fall."
# DRINK_FOUNTAIN_MESSAGE = "You drink from the fountain, your max health increases by %(health)s."
# HURT_BY_EXPLOSION = "The explosion blasts %(target_entity)s for %(damage)s damage."
# HURT_BY_FIRE = "The fire burns %(target_entity)s for %(damage)s damage."
# WONT_BREAK_OUT_OF_WEB_MESSAGE = "%(target_entity)s is stuck in the spider web."
# BREAKS_OUT_OF_WEB_MESSAGE = "%(target_entity)s breaks free."
# WANT_TO_JUMP_DOWN_CHASM = "Are you sure you want to drop down the chasm?"
# PRESS_ENTER_TO_ACCEPT = "Press ENTER to accept, another key to reject."
# PLAYER_TELEPORT_MESSAGE = "Your surroundings seem different."
# PLAYER_SWITCH_MESSAGE = "Your surrounding is replaced."
# PLAYER_MAP_MESSAGE = "You surroundings suddenly seem familiar."
# PLAYER_PUSH_SCROLL_MESSAGE = "You as you form the words of the scroll your voice turns into a strong wind."
# GLASS_TURNING_MESSAGE = "You surroundings suddenly seem more transparent."
# SWAP_DEVICE_MESSAGE = "Your surroundings has changed."
# ZAP_DEVICE_MESSAGE = "%(source_entity)s zaps %(target_entity)s for %(damage)s damage!"
# HEALTH_DEVICE_MESSAGE = "%(target_entity)s is healed by the device for %(health)s health."
# STARE_PARALYZE_MESSAGE = "%(source_entity)s stares at %(target_entity)s, it's paralyzed!."
# NO_LONGER_PARALYZED_MESSAGE = "%(source_entity)s is no longer paralyzed."
# FROST_POTION_DRINK_MESSAGE = "That potion was cold as ice! You feel yourself slow down."
# FROST_POTION_BREAKS_MESSAGE = "The potion smashes to the ground and creates a freezing cloud of mist!"
# POTION_SMASHES_AGAINST_FLOOR_MESSAGE = "The potion smashes to the ground and breaks into pieces."
# FLAME_POTION_DRINK_MESSAGE = "As you drink the potion the liquid ignites!"
# FLAME_POTION_BREAKS_MESSAGE = "The potion smashes to the ground and creates a roaring fire!"
# POISON_POTION_DRINK_MESSAGE = "The potion tastes really nasty, you feel sick!"
# POISON_POTION_BREAK_MESSAGE = "The potion smashes to the ground and creates a poisonous cloud of gas!"
# POTION_SMASH_TO_GROUND = "The %(target_entity)s smashes to the ground and breaks into pieces."
# ITEM_HITS_THE_GROUND_HEAVY = "The %(target_entity)s hits the ground with a thud."
# ITEM_HITS_THE_GROUND_LIGHT = "The %(target_entity)s falls to the ground."
# ITEM_FALLS_DOWN_CHASM = "The %(target_entity)s falls into the chasm and disappears."
# ENTITY_EXPLODES = "%(target_entity)s explodes!"
# class Messenger(object):
# class Message(object):
#     def __init__(self):
#     def has_new_message(self):
#     def has_new_message(self, value):
#     def send_visual_message(self, new_message, position):
#     def send_global_message(self, new_message):
#     def _message(self, new_message):
#     def tail(self, length):
#     def clear(self):
#     def __init__(self, message):
#     def increase(self):
#     def tick(self):
#     def __str__(self):


import random
import spawner
from compositecore import Leaf
from messenger import msg


class RemoveEntityOnDeath(Leaf):
    """
    Will remove the parent from the dungeon when parent Entity dies.
    """
    def __init__(self):
        super(RemoveEntityOnDeath, self).__init__()
        self.component_type = "remove_on_death"

    def after_tick(self, time):
        if self.parent.health.is_dead():
            self.parent.dungeon_level.value
            self.parent.mover.try_remove_from_dungeon()


class PrintDeathMessageOnDeath(Leaf):
    """
    Will print death message when parent Entity dies.
    """
    def __init__(self):
        super(PrintDeathMessageOnDeath, self).__init__()
        self.component_type = "print_death_message_on_death"

    def on_tick(self, time):
        if self.parent.health.is_dead():
            msg.send_visual_message(self.parent.entity_messages.death, self.parent.position.value)



# Path: compositecore.py
# class Leaf(Component):
#     """
#     Abstract leaf class of composite design pattern.
# 
#     Component classes of leaf type should inherit from this class.
#     """
# 
#     def __init__(self):
#         super(Leaf, self).__init__()
# 
#     def get_relative_of_type(self, component_type):
#         return self.parent.get_child_or_ancestor(component_type)
# 
#     def has_relative_of_type(self, component_type):
#         return self.parent.has_child_or_ancestor(component_type)
# 
# Path: messenger.py
# EQUIP_MESSAGE = "%(source_entity)s equips %(item)s."
# UNEQUIP_MESSAGE = "%(source_entity)s puts away %(item)s."
# HEAL_MESSAGE = "%(source_entity)s heals %(target_entity)s for %(health)s health."
# HEALTH_POTION_MESSAGE = "The health potion heals %(target_entity)s for %(health)s health."
# DISSOLVE_MESSAGE = "%(source_entity)s dissolves %(target_entity)s for %(damage)s damage."
# HIT_MESSAGE = "%(source_entity)s hits %(target_entity)s for %(damage)s damage."
# MISS_MESSAGE = "%(source_entity)s misses %(target_entity)s."
# CRIT_MESSAGE = "%(source_entity)s critically hits %(target_entity)s for %(damage)s damage."
# HAUNT_MESSAGE = "%(source_entity)s haunts the %(target_entity)s!"
# HEART_STOP_MESSAGE = "%(target_entity)s clutches its heart."
# DARKNESS_MESSAGE = "An unnatural darkness fills the dungeon."
# PICK_UP_MESSAGE = "You pick up %(item)s."
# POISON_MESSAGE = "%(target_entity)s takes %(damage)s in poison damage."
# BLEED_MESSAGE = "%(target_entity)s is bleeding out %(damage)s damage."
# DOWN_STAIRS_HEAL_MESSAGE = "Your feel vitalized by your progress, you regain %(health)s health."
# FALL_DOWN_MESSAGE = "You take a damage of %(damage)s from the fall."
# DRINK_FOUNTAIN_MESSAGE = "You drink from the fountain, your max health increases by %(health)s."
# HURT_BY_EXPLOSION = "The explosion blasts %(target_entity)s for %(damage)s damage."
# HURT_BY_FIRE = "The fire burns %(target_entity)s for %(damage)s damage."
# WONT_BREAK_OUT_OF_WEB_MESSAGE = "%(target_entity)s is stuck in the spider web."
# BREAKS_OUT_OF_WEB_MESSAGE = "%(target_entity)s breaks free."
# WANT_TO_JUMP_DOWN_CHASM = "Are you sure you want to drop down the chasm?"
# PRESS_ENTER_TO_ACCEPT = "Press ENTER to accept, another key to reject."
# PLAYER_TELEPORT_MESSAGE = "Your surroundings seem different."
# PLAYER_SWITCH_MESSAGE = "Your surrounding is replaced."
# PLAYER_MAP_MESSAGE = "You surroundings suddenly seem familiar."
# PLAYER_PUSH_SCROLL_MESSAGE = "You as you form the words of the scroll your voice turns into a strong wind."
# GLASS_TURNING_MESSAGE = "You surroundings suddenly seem more transparent."
# SWAP_DEVICE_MESSAGE = "Your surroundings has changed."
# ZAP_DEVICE_MESSAGE = "%(source_entity)s zaps %(target_entity)s for %(damage)s damage!"
# HEALTH_DEVICE_MESSAGE = "%(target_entity)s is healed by the device for %(health)s health."
# STARE_PARALYZE_MESSAGE = "%(source_entity)s stares at %(target_entity)s, it's paralyzed!."
# NO_LONGER_PARALYZED_MESSAGE = "%(source_entity)s is no longer paralyzed."
# FROST_POTION_DRINK_MESSAGE = "That potion was cold as ice! You feel yourself slow down."
# FROST_POTION_BREAKS_MESSAGE = "The potion smashes to the ground and creates a freezing cloud of mist!"
# POTION_SMASHES_AGAINST_FLOOR_MESSAGE = "The potion smashes to the ground and breaks into pieces."
# FLAME_POTION_DRINK_MESSAGE = "As you drink the potion the liquid ignites!"
# FLAME_POTION_BREAKS_MESSAGE = "The potion smashes to the ground and creates a roaring fire!"
# POISON_POTION_DRINK_MESSAGE = "The potion tastes really nasty, you feel sick!"
# POISON_POTION_BREAK_MESSAGE = "The potion smashes to the ground and creates a poisonous cloud of gas!"
# POTION_SMASH_TO_GROUND = "The %(target_entity)s smashes to the ground and breaks into pieces."
# ITEM_HITS_THE_GROUND_HEAVY = "The %(target_entity)s hits the ground with a thud."
# ITEM_HITS_THE_GROUND_LIGHT = "The %(target_entity)s falls to the ground."
# ITEM_FALLS_DOWN_CHASM = "The %(target_entity)s falls into the chasm and disappears."
# ENTITY_EXPLODES = "%(target_entity)s explodes!"
# class Messenger(object):
# class Message(object):
#     def __init__(self):
#     def has_new_message(self):
#     def has_new_message(self, value):
#     def send_visual_message(self, new_message, position):
#     def send_global_message(self, new_message):
#     def _message(self, new_message):
#     def tail(self, length):
#     def clear(self):
#     def __init__(self, message):
#     def increase(self):
#     def tick(self):
#     def __str__(self):


# Path: ondeath.py
import random
import spawner
from compositecore import Leaf
from messenger import msg



class RemoveEntityOnDeath(Leaf):
    """
    Will remove the parent from the dungeon when parent Entity dies.
    """
    def __init__(self):
        super(RemoveEntityOnDeath, self).__init__()
        self.component_type = "remove_on_death"

    def after_tick(self, time):
        if self.parent.health.is_dead():
            self.parent.dungeon_level.value
            self.parent.mover.try_remove_from_dungeon()


class PrintDeathMessageOnDeath(Leaf):
    """
    Will print death message when parent Entity dies.
    """
    def __init__(self):
        super(PrintDeathMessageOnDeath, self).__init__()
        self.component_type = "print_death_message_on_death"

    def on_tick(self, time):
        if self.parent.health.is_dead():
            msg.send_visual_message(self.parent.entity_messages.death, self.parent.position.value)



class LeaveCorpseOnDeath(Leaf):