# 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)
# 
# class CompositeMessage(object):
#     """
#     Enumerator defining class. Defines all messages that may be sent.
#     """
#     DUNGEON_LEVEL_CHANGED = 0
#     POSITION_CHANGED = 1
# 
#     def __init__(self):
#         """
#         Should not be initiated.
#         """
#         raise
# 
# Path: console.py
# class ConsoleVisual(object):
#     def __init__(self, width, height):
#     def get_color_fg(self, position):
#     def get_color_bg(self, position):
#     def get_symbol(self, position):
#     def get_default_color_fg(self):
#     def get_default_color_bg(self):
#     def set_default_color_fg(self, color, console=0):
#     def set_default_color_bg(self, color, console=0):
#     def set_symbol(self, position, icon, console=0):
#     def set_color_fg(self, position, color, console=0):
#     def set_color_bg(self, position, color, effect=libtcod.BKGND_SET, console=0):
#     def print_text(self, position, text):
#     def print_text_vertical(self, position, text):
#     def set_colors_and_symbol(self, position, color_fg, color_bg, icon, console=0):
#     def print_char_big(self, icon_position, destination, console=0):
#     def flush(self):
#     def print_screen(self):


import random
import time
import colors
import direction
import geometry
import icon
import libtcodpy as libtcod
import turn
from compositecore import Leaf, CompositeMessage
from console import console
        x, y = libtcod.path_walk(self.path, True)
        while not x is None:
            self.position_list.insert(0, (x, y))
            x, y = libtcod.path_walk(self.path, True)

    def set_line_path(self, destination):
        sx, sy = self.parent.position.value
        dx, dy = destination
        libtcod.line_init(sx, sy, dx, dy)
        self.clear()
        x, y = libtcod.line_step()
        while not x is None:
            self.position_list.insert(0, (x, y))
            x, y = libtcod.line_step()

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

    def draw(self, camera):
        points = list(self.position_list)
        points.reverse()
        point = None
        for point in points:
            if not self.parent.mover.can_pass_terrain(
                    self.parent.dungeon_level.value.get_tile_or_unknown(point).get_terrain()):
                break
            console.set_symbol(camera.dungeon_to_screen_position(point), icon.FOOT_STEPS)
            console.set_color_fg(camera.dungeon_to_screen_position(point), colors.GRAY)
        if point:
            console.set_symbol(camera.dungeon_to_screen_position(point), "X")

# 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)
# 
# class CompositeMessage(object):
#     """
#     Enumerator defining class. Defines all messages that may be sent.
#     """
#     DUNGEON_LEVEL_CHANGED = 0
#     POSITION_CHANGED = 1
# 
#     def __init__(self):
#         """
#         Should not be initiated.
#         """
#         raise
# 
# Path: console.py
# class ConsoleVisual(object):
#     def __init__(self, width, height):
#     def get_color_fg(self, position):
#     def get_color_bg(self, position):
#     def get_symbol(self, position):
#     def get_default_color_fg(self):
#     def get_default_color_bg(self):
#     def set_default_color_fg(self, color, console=0):
#     def set_default_color_bg(self, color, console=0):
#     def set_symbol(self, position, icon, console=0):
#     def set_color_fg(self, position, color, console=0):
#     def set_color_bg(self, position, color, effect=libtcod.BKGND_SET, console=0):
#     def print_text(self, position, text):
#     def print_text_vertical(self, position, text):
#     def set_colors_and_symbol(self, position, color_fg, color_bg, icon, console=0):
#     def print_char_big(self, icon_position, destination, console=0):
#     def flush(self):
#     def print_screen(self):


# Path: dungeonmask.py
import random
import time
import colors
import direction
import geometry
import icon
import libtcodpy as libtcod
import turn
from compositecore import Leaf, CompositeMessage
from console import console

        x, y = libtcod.path_walk(self.path, True)
        while not x is None:
            self.position_list.insert(0, (x, y))
            x, y = libtcod.path_walk(self.path, True)

    def set_line_path(self, destination):
        sx, sy = self.parent.position.value
        dx, dy = destination
        libtcod.line_init(sx, sy, dx, dy)
        self.clear()
        x, y = libtcod.line_step()
        while not x is None:
            self.position_list.insert(0, (x, y))
            x, y = libtcod.line_step()

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

    def draw(self, camera):
        points = list(self.position_list)
        points.reverse()
        point = None
        for point in points:
            if not self.parent.mover.can_pass_terrain(
                    self.parent.dungeon_level.value.get_tile_or_unknown(point).get_terrain()):
                break
            console.set_symbol(camera.dungeon_to_screen_position(point), icon.FOOT_STEPS)
            console.set_color_fg(camera.dungeon_to_screen_position(point), colors.GRAY)
        if point:
            console.set_symbol(camera.dungeon_to_screen_position(point), "X")

            console.set_color_fg(camera.dungeon_to_screen_position(point), colors.LIGHT_ORANGE)