# 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: graphic.py
# class GraphicChar(Leaf):
#     """
#     Composites holding this has a graphical representation as a char.
#     """
# 
#     def __init__(self, color_bg, color_fg, icon):
#         super(GraphicChar, self).__init__()
#         self.component_type = "graphic_char"
#         self._color_bg = color_bg
#         self._color_fg = color_fg
#         self._icon = icon
# 
#     @property
#     def color_bg(self):
#         if self._color_bg:
#             return self._color_bg
#         elif self.next:
#             return self.next.color_bg
#         return None
# 
# 
#     @color_bg.setter
#     def color_bg(self, value):
#         self._color_bg = value
# 
#     @property
#     def color_fg(self):
#         if self._color_fg:
#             return self._color_fg
#         elif self.next:
#             return self.next.color_fg
#         return None
# 
#     @color_fg.setter
#     def color_fg(self, value):
#         self._color_fg = value
# 
#     @property
#     def icon(self):
#         if self._icon:
#             return self._icon
#         elif self.next:
#             return self.next.icon
#         return None
# 
#     @icon.setter
#     def icon(self, value):
#         self._icon = value
# 
#     def copy(self):
#         """
#         Makes a copy of this component.
#         """
#         return GraphicChar(self.color_bg, self.color_fg, self.icon)


import colors
import icon
from compositecore import Leaf
from graphic import GraphicChar


class StatusDescription(object):
    def __init__(self, name, graphic_char, description):
        self.graphic_char = graphic_char
        self.name = name
        self.description = description


class StatusDescriptionBar(Leaf):
    def __init__(self):
        super(StatusDescriptionBar, self).__init__()
        self.component_type = "status_bar"
        self.statuses = []

    def clear(self):
        self.statuses = []

    def add(self, status_icon):
        self.statuses.append(status_icon)

    def first_tick(self, time):
        self.clear()

FIRE_STATUS_DESCRIPTION = StatusDescription("Fire", GraphicChar(None, colors.RED, icon.FIRE), "You are standing in flames, taking heavy fire damage each turn spent in the flames.")
POISON_STATUS_DESCRIPTION = StatusDescription("Poisoned", GraphicChar(None, colors.GREEN, icon.DROP_ICON), "Poisoned, while poisoned you will take poison damage, the poison will wear off after a while.")
STUNNED_STATUS_DESCRIPTION = StatusDescription("Stunned", GraphicChar(None, colors.CHAMPAGNE, icon.STUNNED_ICON), "You are stunned and will skip your next turn.")
DAMAGE_REFLECT_STATUS_DESCRIPTION = StatusDescription("Damage Reflect", GraphicChar(None, colors.CYAN, icon.ARMOR_STAT), "When you take damage there is a chance that each enemy you see will take one point of damage.")

# 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: graphic.py
# class GraphicChar(Leaf):
#     """
#     Composites holding this has a graphical representation as a char.
#     """
# 
#     def __init__(self, color_bg, color_fg, icon):
#         super(GraphicChar, self).__init__()
#         self.component_type = "graphic_char"
#         self._color_bg = color_bg
#         self._color_fg = color_fg
#         self._icon = icon
# 
#     @property
#     def color_bg(self):
#         if self._color_bg:
#             return self._color_bg
#         elif self.next:
#             return self.next.color_bg
#         return None
# 
# 
#     @color_bg.setter
#     def color_bg(self, value):
#         self._color_bg = value
# 
#     @property
#     def color_fg(self):
#         if self._color_fg:
#             return self._color_fg
#         elif self.next:
#             return self.next.color_fg
#         return None
# 
#     @color_fg.setter
#     def color_fg(self, value):
#         self._color_fg = value
# 
#     @property
#     def icon(self):
#         if self._icon:
#             return self._icon
#         elif self.next:
#             return self.next.icon
#         return None
# 
#     @icon.setter
#     def icon(self, value):
#         self._icon = value
# 
#     def copy(self):
#         """
#         Makes a copy of this component.
#         """
#         return GraphicChar(self.color_bg, self.color_fg, self.icon)


# Path: Status.py
import colors
import icon
from compositecore import Leaf
from graphic import GraphicChar



class StatusDescription(object):
    def __init__(self, name, graphic_char, description):
        self.graphic_char = graphic_char
        self.name = name
        self.description = description


class StatusDescriptionBar(Leaf):
    def __init__(self):
        super(StatusDescriptionBar, self).__init__()
        self.component_type = "status_bar"
        self.statuses = []

    def clear(self):
        self.statuses = []

    def add(self, status_icon):
        self.statuses.append(status_icon)

    def first_tick(self, time):
        self.clear()

FIRE_STATUS_DESCRIPTION = StatusDescription("Fire", GraphicChar(None, colors.RED, icon.FIRE), "You are standing in flames, taking heavy fire damage each turn spent in the flames.")
POISON_STATUS_DESCRIPTION = StatusDescription("Poisoned", GraphicChar(None, colors.GREEN, icon.DROP_ICON), "Poisoned, while poisoned you will take poison damage, the poison will wear off after a while.")
STUNNED_STATUS_DESCRIPTION = StatusDescription("Stunned", GraphicChar(None, colors.CHAMPAGNE, icon.STUNNED_ICON), "You are stunned and will skip your next turn.")
DAMAGE_REFLECT_STATUS_DESCRIPTION = StatusDescription("Damage Reflect", GraphicChar(None, colors.CYAN, icon.ARMOR_STAT), "When you take damage there is a chance that each enemy you see will take one point of damage.")

LIFE_STEAL_STATUS_DESCRIPTION = StatusDescription("Life Steal", GraphicChar(None, colors.RED, icon.LIFE_STEAL_ICON), "When an enemy dies within sight you will heal one point of health.")