Ejemplo n.º 1
0
 def sort_statuses(left, right):
     """Sort statuses first by their effect (bad, good, neutral), and
     second by their name."""
     diff = cmp(status.type_of(left), status.type_of(right))
     if diff == 0:
         diff = cmp(left, right)
     return diff
Ejemplo n.º 2
0
 def sort_statuses(left, right):
     """Sort statuses first by their effect (bad, good, neutral), and
     second by their name."""
     diff = cmp(status.type_of(left), status.type_of(right))
     if diff == 0:
         diff = cmp(left, right)
     return diff
Ejemplo n.º 3
0
    def _status_box(self):
        """
        Create the pane with information about the player's current state.
        """

        default = "(none)"

        status_frame = curses.newwin(
            self._height(), 
            self.status_width, 
            self._top(), 
            self.level_width - 1
        )

        status_frame.erase()
        status_frame.border("|", "|", "-", " ", "+", "+", "|", "|")
        status_frame.addstr(0, 2, " status ")
        status_frame.chgat(0, 2, len(" status "), get_color(curses.COLOR_CYAN))
        statuses = self._get_statuses()
        for row, stat in enumerate(statuses, 1):
            attrs = []
            if status.type_of(stat) == "bad":
                attrs += [get_color(curses.COLOR_RED)]

            attrs = reduce(lambda a, b: a | b, attrs, 0)
            status_frame.addnstr(row, 1, stat, self.status_width-2, attrs)

        if len(statuses) == 0:
            center = (self.status_width / 2) - (len(default) / 2)
            status_frame.addstr(1, center, default)

        return status_frame
Ejemplo n.º 4
0
    def _status_box(self):
        """
        Create the pane with information about the player's current state.
        """

        default = "(none)"

        status_frame = curses.newwin(self._height(), self.status_width,
                                     self._top(), self.level_width - 1)

        status_frame.erase()
        status_frame.border("|", "|", "-", " ", "+", "+", "|", "|")
        status_frame.addstr(0, 2, " status ")
        status_frame.chgat(0, 2, len(" status "), get_color(curses.COLOR_CYAN))
        statuses = self._get_statuses()
        for row, stat in enumerate(statuses, 1):
            attrs = []
            if status.type_of(stat) == "bad":
                attrs += [get_color(curses.COLOR_RED)]

            attrs = reduce(lambda a, b: a | b, attrs, 0)
            status_frame.addnstr(row, 1, stat, self.status_width - 2, attrs)

        if len(statuses) == 0:
            center = (self.status_width / 2) - (len(default) / 2)
            status_frame.addstr(1, center, default)

        return status_frame