Пример #1
0
    def return_appearance(self, viewer):
        """This formats a description. It is the hook a 'look' command
        should call.

        Args:
            viewer (Object): Object doing the looking.
        """
        if not viewer:
            return None
        # get and identify all objects
        visible = (con for con in self.contents
                   if con != viewer and con.access(viewer, "view"))
        exits, users, things = [], [], []
        for con in visible:
            if con.destination:
                exits.append(con)
            elif con.has_player:
                users.append(con)
            else:
                things.append(con)
        # get description, build string
        string = self.get_display_name(viewer, mxp='sense #%s' % self.id)
        string += " (%s)" % mass_unit(self.get_mass())
        if self.traits.health:  # Add health bar if object has health.
            gradient = [
                "|[300", "|[300", "|[310", "|[320", "|[330", "|[230", "|[130",
                "|[030", "|[030"
            ]
            health = make_bar(self.traits.health.actual,
                              self.traits.health.max, 20, gradient)
            string += " %s\n" % health
        if self.db.surface:
            string += " -- %s" % self.db.surface
        string += "\n"
        desc = self.db.desc
        desc_brief = self.db.desc_brief
        if desc:
            string += "%s" % desc
        elif desc_brief:
            string += "%s" % desc_brief
        else:
            string += 'A shimmering illusion of %s shifts from form to form.' % self.name
        if exits:
            string += "\n|wExits: " + ", ".join(
                "%s" % e.get_display_name(viewer) for e in exits)
        if users or things:
            user_list = ", ".join(u.get_display_name(viewer) for u in users)
            ut_joiner = ', ' if users and things else ''
            item_list = ", ".join(t.get_display_name(viewer) for t in things)
            string += "\n|wContains:|n " + user_list + ut_joiner + item_list
        return string
Пример #2
0
    def return_appearance(self, viewer):
        """This formats a description. It is the hook a 'look' command should call.

        Args:
            viewer (Object): Object doing the looking.
        """
        if not viewer:
            return
        # get and identify all objects
        visible = (con for con in self.contents if con != viewer and
                   con.access(viewer, 'view'))
        exits, users, things = [], [], []
        for con in visible:
            if con.destination:
                exits.append(con)
            elif con.has_player:
                users.append(con)
            else:
                things.append(con)
        # get description, build string

        string = "\n%s" % self.mxp_name(viewer, '@verb #%s' % self.id)
        string += " (%s) " % mass_unit(self.get_mass())
        if self.attributes.has('health') and self.attributes.has('health_max'):  # Add character health bar.
            gradient = ["|[300", "|[300", "|[310", "|[320", "|[330", "|[230", "|[130", "|[030", "|[030"]
            health = make_bar(self.attributes.get('health'), self.attributes.get('health_max'), 20, gradient)
            string += " %s\n" % health
        else:
            string += "\n"
        desc = self.db.desc
        desc_brief = self.db.desc_brief
        if desc:
            string += "%s" % desc
        elif desc_brief:
            string += "%s" % desc_brief
        else:
            string += 'A shimmering illusion shifts from form to form.'
        if exits:
            string += "\n|wExits: " + ", ".join("%s" % e.full_name(viewer) for e in exits)
        if users or things:
            user_list = ", ".join(u.full_name(viewer) for u in users)
            ut_joiner = ', ' if users and things else ''
            item_list = ", ".join(t.full_name(viewer) if hasattr(t, 'full_name') else t.name for t in things)
            string += "\n|wYou see:|n " + user_list + ut_joiner + item_list
        return string
Пример #3
0
    def return_appearance(self, viewer):
        """This formats a description. It is the hook a 'look' command
        should call.

        Args:
            viewer (Object): Object doing the looking.
        """
        if not viewer:
            return None
        # get and identify all objects
        visible = (con for con in self.contents if con != viewer and con.access(viewer, "view"))
        exits, users, things = [], [], []
        for con in visible:
            if con.destination:
                exits.append(con)
            elif con.has_player:
                users.append(con)
            else:
                things.append(con)
        # get description, build string
        string = self.get_display_name(viewer, mxp='sense #%s' % self.id)
        string += " (%s)" % mass_unit(self.get_mass())
        if self.traits.health:  # Add health bar if object has health.
            gradient = ["|[300", "|[300", "|[310", "|[320", "|[330", "|[230", "|[130", "|[030", "|[030"]
            health = make_bar(self.traits.health.actual, self.traits.health.max, 20, gradient)
            string += " %s\n" % health
        if self.db.surface:
            string += " -- %s" % self.db.surface
        string += "\n"
        desc = self.db.desc
        desc_brief = self.db.desc_brief
        if desc:
            string += "%s" % desc
        elif desc_brief:
            string += "%s" % desc_brief
        else:
            string += 'A shimmering illusion of %s shifts from form to form.' % self.name
        if exits:
            string += "\n|wExits: " + ", ".join("%s" % e.get_display_name(viewer) for e in exits)
        if users or things:
            user_list = ", ".join(u.get_display_name(viewer) for u in users)
            ut_joiner = ', ' if users and things else ''
            item_list = ", ".join(t.get_display_name(viewer) for t in things)
            string += "\n|wContains:|n " + user_list + ut_joiner + item_list
        return string
Пример #4
0
 def return_appearance(self, viewer):
     """This formats a description. It is the hook a 'look' command should call.
     Args:
         viewer (Object): Object doing the looking.
     """
     if not viewer:
         return ''
     if not viewer.is_typeclass('typeclasses.accounts.Account'):
         viewer = viewer.account  # make viewer reference the account object
     char = viewer.puppet
     # get and identify all objects
     visible = (con for con in self.contents
                if con != viewer and con.access(viewer, 'view'))
     exits, users, things = [], [], []
     for con in visible:
         if con.destination:
             exits.append(con)
         elif con.has_account:
             users.append(con)
         else:
             if not con.db.worn:
                 things.append(con)
     string = "\n%s" % self.get_display_name(
         viewer, mxp='sense %s' % self.get_display_name(viewer, plain=True))
     if self.location and self.location.tags.get('rp', category='flags'):
         pose = self.db.messages and self.db.messages.get('pose', None)
         string += ' %s' % pose or ''
     if self.traits.mass and self.traits.mass.actual > 0:
         string += " |y(%s)|n " % mass_unit(self.get_mass())
     if self.traits.health:  # Add character health bar if character has health.
         gradient = [
             "|[300", "|[300", "|[310", "|[320", "|[330", "|[230", "|[130",
             "|[030", "|[030"
         ]
         health = make_bar(self.traits.health.actual,
                           self.traits.health.max, 20, gradient)
         string += " %s\n" % health
     else:
         string += "\n"
     desc = self.db.desc
     desc_brief = self.db.desc_brief
     if desc:
         string += "%s" % desc
     elif desc_brief:
         string += "%s" % desc_brief
     else:
         string += 'A shimmering illusion shifts from form to form.'
     # ---- Allow clothes wearing to be seen
     worn_string_list = []
     clothes_list = get_worn_clothes(self, exclude_covered=True)
     # Append worn, uncovered clothing to the description
     for garment in clothes_list:
         if garment.db.worn is True:  # If 'worn' is True,
             worn_string_list.append(garment.name)  # just append the name.
         # Otherwise, append the name and the string value of 'worn'
         elif garment.db.worn:
             worn_string_list.append("%s %s" %
                                     (garment.name, garment.db.worn))
     if worn_string_list:  # Append worn clothes.
         string += "|/|/%s is wearing %s." % (
             self, list_to_string(worn_string_list))
     # ---- List things carried (excludes worn things)
     if users or things:
         user_list = ", ".join(u.get_display_name(viewer) for u in users)
         ut_joiner = ', ' if users and things else ''
         item_list = ", ".join(t.get_display_name(viewer) for t in things)
         string += "\n|wYou see:|n " + user_list + ut_joiner + item_list
     # ---- Look Notify system:
     if self != char:
         if not (self.db.settings and 'look notify' in self.db.settings
                 and self.db.settings['look notify'] is False):
             self.msg("%s just looked at you." %
                      char.get_display_name(self))
     return string
Пример #5
0
 def return_appearance(self, viewer):
     """This formats a description. It is the hook a 'look' command should call.
     Args:
         viewer (Object): Object doing the looking.
     """
     if not viewer:
         return ''
     if not viewer.is_typeclass('typeclasses.accounts.Account'):
         viewer = viewer.account  # make viewer reference the account object
     char = viewer.puppet
     # get and identify all objects
     visible = (con for con in self.contents if con != viewer and
                con.access(viewer, 'view'))
     exits, users, things = [], [], []
     for con in visible:
         if con.destination:
             exits.append(con)
         elif con.has_account:
             users.append(con)
         else:
             if not con.db.worn:
                 things.append(con)
     string = "\n%s" % self.get_display_name(viewer, mxp='sense %s' % self.get_display_name(viewer, plain=True))
     if self.location and self.location.tags.get('rp', category='flags'):
         pose = self.db.messages and self.db.messages.get('pose', None)
         string += ' %s' % pose or ''
     if self.traits.mass and self.traits.mass.actual > 0:
         string += " |y(%s)|n " % mass_unit(self.get_mass())
     if self.traits.health:  # Add character health bar if character has health.
         gradient = ["|[300", "|[300", "|[310", "|[320", "|[330", "|[230", "|[130", "|[030", "|[030"]
         health = make_bar(self.traits.health.actual, self.traits.health.max, 20, gradient)
         string += " %s\n" % health
     else:
         string += "\n"
     desc = self.db.desc
     desc_brief = self.db.desc_brief
     if desc:
         string += "%s" % desc
     elif desc_brief:
         string += "%s" % desc_brief
     else:
         string += 'A shimmering illusion shifts from form to form.'
     # ---- Allow clothes wearing to be seen
     worn_string_list = []
     clothes_list = get_worn_clothes(self, exclude_covered=True)
     # Append worn, uncovered clothing to the description
     for garment in clothes_list:
         if garment.db.worn is True:  # If 'worn' is True,
             worn_string_list.append(garment.name)  # just append the name.
         # Otherwise, append the name and the string value of 'worn'
         elif garment.db.worn:
             worn_string_list.append("%s %s" % (garment.name, garment.db.worn))
     if worn_string_list:  # Append worn clothes.
         string += "|/|/%s is wearing %s." % (self, list_to_string(worn_string_list))
     # ---- List things carried (excludes worn things)
     if users or things:
         user_list = ", ".join(u.get_display_name(viewer) for u in users)
         ut_joiner = ', ' if users and things else ''
         item_list = ", ".join(t.get_display_name(viewer) for t in things)
         string += "\n|wYou see:|n " + user_list + ut_joiner + item_list
     # ---- Look Notify system:
     if self != char:
         if not (self.db.settings and 'look notify' in self.db.settings
                 and self.db.settings['look notify'] is False):
             self.msg("%s just looked at you." % char.get_display_name(self))
     return string