Beispiel #1
0
def render_dungeon_level(console: Console, dungeon_level: int,
                         location: Tuple[int, int]) -> None:
    """
    Render the level the player is currently on, at the given location.
    """
    x, y = location

    console.print(x=x, y=y, string=f"Dungeon level: {dungeon_level}")
Beispiel #2
0
def render_names_at_mouse_location(console: Console, x: int, y: int,
                                   engine: Engine) -> None:
    map_x, map_y = engine.game_map.viewport_to_map_coord(engine.mouse_location)

    names_at_mouse_location = get_names_at_location(x=map_x,
                                                    y=map_y,
                                                    game_map=engine.game_map)

    console.print(x=x, y=y, string=names_at_mouse_location)
Beispiel #3
0
    def render(self, console: tcod.Console) -> None:
        y_offset: int = self.y

        for message in self.messages:
            console.print(x=self.x,
                          y=y_offset,
                          string=message.text,
                          fg=message.color)
            y_offset += 1
Beispiel #4
0
def render_dungeon_level(
        console: Console, dungeon_level: int, location: Tuple[int, int]
) -> None:
    """
    Render the current level's number to the given location
    """

    x, y = location
    console.print(x=x, y=y, string=f"Dungeon level: {dungeon_level}")
Beispiel #5
0
def render_dungeon_level(
    console: Console, dungeon_level: int, location: Tuple[int, int]
) -> None:
    """
    Renders any necessary level info for current level the player is on
    """
    x, y = location

    console.print(x=x, y=y, string=f"Dungeon Level: {dungeon_level}")
Beispiel #6
0
def render_names_at_mouse_location(console: Console, x: int, y: int,
                                   engine: Engine) -> None:
    mouse_x, mouse_y = engine.mouse_location

    names_at_mouse_location = get_names_at_location(x=mouse_x,
                                                    y=mouse_y,
                                                    game_map=engine.game_map)

    console.print(x=x, y=y, string=names_at_mouse_location)
Beispiel #7
0
def render_gameinfo(
    console: Console,
    x: int,
    y: int,
    depth: int,
    game_turn: int,
) -> None:
    """print dungeon depth, game turn, etc."""
    console.print(x=x, y=y, string=f"Depth: {depth}", fg=color.white)
    console.print(x=x + 11, y=y, string=f"Turn: {game_turn}", fg=color.gray)
Beispiel #8
0
    def render_messages(cls, console: tcod.Console, x: int, y: int, width: int,
                        height: int, messages: Reversible[Message]) -> None:
        y_offset = height - 1

        for message in reversed(messages):
            for line in reversed(list(cls.wrap(message.full_text, width))):
                console.print(x=x, y=y + y_offset, string=line, fg=message.fg)
                y_offset -= 1
                if y_offset < 0:
                    return
def render_names_at_mouse_location(
        console: Console, x: int, y: int, engine: Engine
) -> None:
    """Shows the name of entities on the pointed/chosen tile"""
    mouse_x, mouse_y = engine.mouse_location

    names_at_mouse_location = get_names_at_location(
        x=mouse_x, y=mouse_y, game_map=engine.game_map
    )

    console.print(x=x, y=y, string=names_at_mouse_location)
Beispiel #10
0
def render_graphics_debug(console: Console, player: Entity, game_map: GameMap,
                          location: Tuple[int, int]) -> None:
    x, y = location

    console.print(x=x, y=y, string=f"Player @: {player.x}, {player.y}")
    console.print(
        x=x,
        y=y + 1,
        string=
        f"VP anchor: {game_map.viewport_anchor_x}, {game_map.viewport_anchor_y}",
    )
Beispiel #11
0
    def on_render(self, console: tcod.Console) -> None:
        self.parent.on_render(console)
        console.tiles_rgb["fg"] //= 8
        console.tiles_rgb["bg"] //= 8

        console.print(console.width // 2,
                      console.height // 2,
                      self.text,
                      fg=color.white,
                      bg=color.black,
                      alignment=tcod.CENTER)
Beispiel #12
0
def render_bar(
        console: Console, current_value: int, maximum_value: int, total_width: int
) -> None:
    bar_width = int(float(current_value) / maximum_value * total_width)
    console.draw_rect(x=0, y=45, width=20, height=1, ch=1, bg=color.bar_empty)
    if bar_width > 0:
        console.draw_rect(x=0, y=45, width=bar_width, height=1, ch=1, bg=color.bar_filled)

    console.print(
        x=1, y=45, string=f"HP: {current_value} / {maximum_value}", fg=color.bar_text
    )
Beispiel #13
0
    def print_text_to_screen(self, console:tcod.Console, x:int, y:int, 
    fg:Optional[Tuple[int,int,int]]=None, bg:Optional[Tuple[int,int,int]]=None) -> None:

        s = self.text_to_print if 0 < self.number_of_chars else " "
        try:
            s2 = s[self.cursor]
        except IndexError:
            s2 = " "

        console.print(x=x,y=y, string=s, fg=fg, bg=bg, bg_blend=constants.BKGND_SET)

        console.print(x=x+self.cursor, y=y, string=s2, fg=bg, bg=fg)
Beispiel #14
0
    def on_render(self, console: Console) -> None:
        super().on_render(console)

        if self.engine.player.x <= 30:
            x = 40
        else:
            x = 30

        y = 0

        width = len(self.TITLE) + 4

        console.draw_frame(
            x=x,
            y=y,
            width=width,
            height=7,
            title=self.TITLE,
            clear=True,
            fg=(255, 255, 255),
            bg=(0, 0, 0),
        )

        console.print(
            x=x + 1,
            y=y + 1,
            string=f"Level: {self.engine.player.level.current_level}",
        )

        console.print(
            x=x + 1,
            y=y + 2,
            string=f"XP: {self.engine.player.level.current_xp}",
        )

        console.print(
            x=x + 1,
            y=y + 3,
            string=
            f"XP to next level: {self.engine.player.level.experience_to_next_level}",
        )

        console.print(
            x=x + 1,
            y=y + 4,
            string=f"Attack: {self.engine.player.fighter.power}",
        )

        console.print(
            x=x + 1,
            y=y + 5,
            string=f"Defense: {self.engine.player.fighter.defense}",
        )
Beispiel #15
0
    def render_messages(cls, console: tcod.Console, x: int, y: int, width: int,
                        height: int, messages: Reversible[Message]) -> None:
        """Render the messages provided.
        The 'messages' are rendered starting at the last message and working backwards.
        """

        y_offset = height - 1
        for message in reversed(messages):
            for line in reversed(list(cls.wrap(message.full_text, width))):
                console.print(x=x, y=y + y_offset, string=line, fg=message.fg)
                y_offset -= 1
                if y_offset < 0:
                    return  # No more space to print messages.
Beispiel #16
0
    def on_render(self, console: Console) -> None:
        """
        Render an inventory menu, which displays the items in the inventory,
        and the letter to select them.
        Will move to a different position based on where the player is
        located, so the player can always see where they are.
        """
        super().on_render(console)
        number_of_items_in_inventory = len(self.engine.player.inventory.items)

        height = number_of_items_in_inventory + 2

        if height <= 3:
            height = 3

        if self.engine.player.x <= 30:
            x = 40
        else:
            x = 0

        y = 0

        width = len(self.TITLE) + 4

        console.draw_frame(
            x=x,
            y=y,
            width=width,
            height=height,
            title=self.TITLE,
            clear=True,
            fg=(255, 255, 255),
            bg=(0, 0, 0),
        )

        if number_of_items_in_inventory > 0:
            for i, item in enumerate(self.engine.player.inventory.items):
                item_key = chr(ord("a") + i)
                # console.print(x + 1, y + i + 1, f"({item_key} )")

                is_equipped = self.engine.player.equipment.item_is_equipped(
                    item)

                item_string = f"({item_key}) {item.name}"

                if is_equipped:
                    item_string = f"{item_string} (E)"

                console.print(x + 1, y + i + 1, item_string)
        else:
            console.print(x + 1, y + 1, "(Empty)")
    def on_render(self, console: tcod.Console) -> None:
        """Render the parent and dim the result, then print the message on top."""
        self.parent.on_render(console)
        console.tiles_rgb["fg"] //= 8
        console.tiles_rgb["bg"] //= 8

        console.print(
            console.width // 2,
            console.height // 2,
            self.text,
            fg=color.white,
            bg=color.black,
            alignment=tcod.CENTER,
        )
Beispiel #18
0
def render_bar(console: Console, character: Actor, current_value: int, maximum_value: int, total_width: int) -> None:
    bar_width = int(float(current_value) / maximum_value * total_width)

    console.draw_rect(x=1, y=44, width=20,
                      height=1, ch=1, bg=(191, 0, 0))

    if bar_width > 0:
        console.draw_rect(x=1, y=44, width=bar_width,
                          height=1, ch=1, bg=(0, 191, 0))

    console.print(
        x=1, y=45, string=f'HP: {current_value}/{maximum_value}')

    render_stats(console, character)
def render_bar(
    console: Console,
    current_value: int,
    maximum_value: int,
    total_width: int,
) -> None:
    """Utilizes the tcod draw_rect functions to draw two rectangular bars and overlays it with text."""
    bar_width = int( float( current_value ) / maximum_value * total_width )

    # I wonder if there's anything I could create and throw in here instead of so many arguments?
    console.draw_rect( x = 0, y = 45, width = 20, height = 1, ch = 1, bg = color.bar_empty )

    if bar_width > 0:
        console.draw_rect( x = 0, y = 45, width = bar_width, height = 1, ch = 1, bg = color.bar_filled )

    console.print( x = 1, y = 45, string = f"HP: {current_value}/{maximum_value}", fg = color.bar_text )
Beispiel #20
0
def render_character_equipments(
    console: Console,
    x: int,
    y: int,
    character: Actor,
) -> None:
    """
    NOTE: Function currently unused(ver27), under development
    NOTE: This function can display any actor's status.
    """

    console.print(
        x=x,
        y=y,
        string=f"Main-hand: {character.equipments.equipments['main_hand']}",
        fg=color.gui_status_text)
Beispiel #21
0
def render_names_at_mouse_location(console: Console, x: int, y: int,
                                   engine: Engine) -> None:
    mouse_x, mouse_y = engine.mouse_location

    names_at_mouse_location = get_names_at_location(x=mouse_x,
                                                    y=mouse_y,
                                                    game_map=engine.game_map)

    tile_name_at_location = get_tile_name_at_location(x=mouse_x,
                                                      y=mouse_y,
                                                      game_map=engine.game_map)

    console.print(x=x, y=y, string=tile_name_at_location, fg=color.white)
    console.print(x=x,
                  y=y + 1,
                  string=names_at_mouse_location,
                  fg=color.yellow)
Beispiel #22
0
    def on_render(self, console: tcod.Console) -> None:
        super().on_render(console)

        if self.engine.player.x <= 30:
            x = 40
        else:
            x = 0

        y = 0
        width = len(self.TITLE) + 4

        console.draw_frame(
            x=x,
            y=y,
            width=width,
            height=7,
            title=self.TITLE,
            clear=True,
            fg=(255, 255, 255),
            bg=(0, 0, 0),
        )
        console.print(
            x=x + 1,
            y=y + 1,
            string=f"Level: {self.engine.player.level.current_level}")
        console.print(x=x + 1,
                      y=y + 2,
                      string=f"XP: {self.engine.player.level.current_xp}")
        console.print(
            x=x + 1,
            y=y + 3,
            string=
            f"XP for next level: {self.engine.player.level.experience_to_next_level}",
        )
        console.print(
            x=x + 1,
            y=y + 4,
            string=
            f"Strength: {self.engine.player.strength} (+{self.engine.player.str_bonus})"
        )
        console.print(
            x=x + 1,
            y=y + 5,
            string=
            f"Dexterity: {self.engine.player.dexterity} (+{self.engine.player.dex_bonus})"
        )
Beispiel #23
0
    def render(self, console: tcod.Console, *, 
        x:int=0, y:int=0, 
        fg:Optional[Tuple[int,int,int]]=None, bg:Optional[Tuple[int,int,int]]= None, 
        text:Optional[str]=None, cursor_position:Optional[int]=None
    ):
        fg, bg = (fg if fg else self.fg), (bg if bg else self.bg)
        
        console.draw_frame(
            x=x+self.x,
            y=y+self.y,
            width=self.width,
            height=self.height,
            title=self.title,
            fg=fg,
            bg=bg,
        )
        string_text = text if text is not None else self.text

        console.print_box(
            x=x+self.x+1,
            y=y+self.y+1,
            height=self.height-2,
            width=self.width-2,
            string=string_text,
            fg=fg,
            bg=bg,
            alignment=self.alignment, 
        )

        if cursor_position is not None:

            try:
                char = string_text[cursor_position]
            except IndexError:
                char = " "
            
            console.print(
                x=self.x + 1 + (self.width - 2) + cursor_position - len(string_text) if 
                self.alignment == constants.RIGHT else 
                self.x + 1 + cursor_position,
                y=self.y+1,
                string=char,
                fg=bg,
                bg=fg,
            )
Beispiel #24
0
def render_inventory_menu(console: Console, engine: Engine) -> None:
    """
    Render an inventory menu, which displays the items in the inventory, and the letter to select them.
    Will move to a different position based on where the player is located, so the player can always see where
    they are.
    """

    console.draw_frame(80, 0, 20, 43, "INVENTORY", True,
                       fg=(255, 255, 255),
                       bg=(0, 0, 0))

    number_of_items_in_inventory = len(engine.player.inventory.items)

    width = 20
    # number_of_items_in_inventory + 2
    height = engine.player.inventory.capacity + 2

    if height <= 3:
        height = 3

    # TODO: Fix these values, not quite right
    if engine.player.x <= 20:
        x = 20
    else:
        x = 0

    if engine.player.y <= 20:
        y = 20
    else:
        y = 0

    # console.draw_frame(x=x, y=y, width=width, height=height, title="Inventory", clear=True, fg=(255, 255, 255),
    #                   bg=(0, 0, 0))

    letter_index = ord('a')

    for i in range(engine.player.inventory.capacity):
        try:
            text = f"({chr(letter_index)}) {engine.player.inventory.items[i].name}"
        except AttributeError:
            text = f"({chr(letter_index)})"

        console.print(81, y=i+1, string=text)

        letter_index += 1
Beispiel #25
0
    def render_messages(
        cls,
        console: tcod.Console,
        x: int,
        y: int,
        width: int,
        height: int,
        messages: Reversible[Message],
    ) -> None:
        """render the messages provided, the messages start at the last message"""
        y_offset = height - 1

        for message in reversed(messages):
            for line in reversed(list(cls.wrap(message.full_text, width))):
                console.print(x=x, y=y + y_offset, string=line, fg=message.fg)
                y_offset -= 1
                if y_offset < 0:
                    return  # no more space for messages
Beispiel #26
0
def render_task(console: Console, motivation: int, T_energy: int,
                special: bool) -> None:

    console.draw_frame(x=1,
                       y=1,
                       width=33,
                       height=9,
                       title="Accept the task?",
                       fg=colors.salmon,
                       bg=colors.bar_filled)

    console.print(
        x=2,
        y=2,
        string=
        f"""motivation: {motivation}\nT energy gain: {T_energy}\nspecial?: {special}\n
        \n[y]- accept task\n[n]- move onwards""",
        fg=colors.bar_text)
    def on_render(self, console: tcod.Console) -> None:
        super().on_render(console)
        number_of_items_in_inventory = len(self.engine.player.inventory.items)

        height = number_of_items_in_inventory + 2

        if height <= 3:
            height = 3

        if self.engine.player.x <= 30:
            x = 40
        else:
            x = 0

        y = 0

        width = len(self.TITLE) + 4

        console.draw_frame(
            x=x,
            y=y,
            width=width,
            height=height,
            title=self.TITLE,
            clear=True,
            fg=(255, 255, 255),
            bg=(0, 0, 0),
        )

        if number_of_items_in_inventory > 0:
            for i, item in enumerate(self.engine.player.inventory.items):
                item_key = chr(ord("a") + i)
                is_equipped = self.engine.player.equipment.item_is_equipped(
                    item)

                item_string = f"({item_key}) {item.name}"

                if is_equipped:
                    item_string = f"{item.string} (E)"

                console.print(x + 1, y + i + 1, item_string)
        else:
            console.print(x + 1, y + 1, "(Empty)")
Beispiel #28
0
    def on_render(self, console: Console) -> None:
        super().on_render(console)

        if self.engine.player.x <= 30:
            x = 40
        else:
            x = 0

        console.draw_frame(
            x=x,
            y=0,
            width=35,
            height=8,
            title=self.TITLE,
            clear=True,
            fg=(255, 255, 255),
            bg=(0, 0, 0),
        )

        console.print(x=x + 1, y=1, string="Congratulations! You level up!")
        console.print(x=x + 1, y=2, string="Select an attribute to increase.")

        console.print(
            x=x + 1,
            y=4,
            string=f"a) Health: raise from {self.engine.player.fighter.max_hp}",
        )

        console.print(
            x=x + 1,
            y=5,
            string=
            f"b) Strength (+1 on attack, from {self.engine.player.fighter.power}",
        )

        console.print(
            x=x + 1,
            y=6,
            string=
            f"c) Agility (+1 on defense, from {self.engine.player.fighter.defense}",
        )
    def on_render(self, console: tcod.Console) -> None:
        """Render an ability menu, which displays the spells in the ability menu, and the letter to select them.
        Will move to a different position based on where the player is located, so the player can always see where
        they are.
        """
        super().on_render(console)
        number_of_abilities_in_ability_menu = len(
            self.engine.player.ability_menu.abilities)

        height = number_of_abilities_in_ability_menu + 2

        if height <= 3:
            height = 3

        if self.engine.player.x <= 30:
            x = 40
        else:
            x = 0

        y = 0

        width = len(self.TITLE) + 4

        console.draw_frame(
            x=x,
            y=y,
            width=width,
            height=height,
            title=self.TITLE,
            clear=True,
            fg=(255, 255, 255),
            bg=(0, 0, 0),
        )

        if number_of_abilities_in_ability_menu > 0:
            for i, item in enumerate(
                    self.engine.player.ability_menu.abilities):
                item_key = chr(ord("a") + i)
                console.print(x + 1, y + i + 1, f"({item_key}) {item.name}")
        else:
            console.print(x + 1, y + 1, "(Empty)")
Beispiel #30
0
    def render_messages(
        cls,
        console: tcod.Console,
        x: int,
        y: int,
        width: int,
        height: int,
        messages: Reversible[Message],
    ) -> None:
        """Отображает предоставленные сообщения начиная с последнего
        """
        y_offset = height - 1

        for message in reversed(messages):
            for line in reversed(
                    list(cls.wrap(message.full_text, width))
            ):  #clswrap.wrap делит текст на части для красивого отображения на экране
                console.print(x=x, y=y + y_offset, string=line, fg=message.fg)
                y_offset -= 1
                if y_offset < 0:
                    return  # Больше нет места для сообщений.