Пример #1
0
    def func(self):
        """
        check inventory, listing carried and worn items,
        and optionally, their weight.
        """
        you = self.character
        items = you.contents
        items_not_worn = []

        wear_table = evtable.EvTable(border="header")
        for item in items:
            if item.db.worn:
                wear_table.add_row("|C%s|n" % item.name, item.db.desc or "")
            else:
                items_not_worn.append(item)
        mass = you.traits.mass.actual if you.traits.mass else 0
        table = evtable.EvTable(border='header')
        for item in items_not_worn:
            i_mass = mass_unit(item.get_mass()) if hasattr(item, 'get_mass') else 0
            second = '(|y%s|n) ' % i_mass if 'weight' in self.switches else ''
            second += item.db.desc_brief or item.db.desc or ''
            table.add_row('%s' % item.get_display_name(you.sessions, mxp=('sense %s' % item.key)),
                          second or '')
        my_mass, my_total_mass = [mass, you.get_mass() if hasattr(you, 'get_mass') else 0]
        string = "|wYou (%s) and your possessions (%s) total |y%s|n:\n%s" %\
                 (mass_unit(mass), mass_unit(my_total_mass - my_mass),
                  mass_unit(my_total_mass), table)
        if not wear_table.nrows == 0:
            string += "|/|wYou are wearing:\n%s" % wear_table
        you.msg(string)
Пример #2
0
    def func(self):
        """
        check inventory, listing carried and worn items,
        and optionally, their weight.
        """
        you = self.character
        items = you.contents
        items_not_worn = []

        wear_table = evtable.EvTable(border="header")
        for item in items:
            if item.db.worn:
                wear_table.add_row("|C%s|n" % item.name, item.db.desc or "")
            else:
                items_not_worn.append(item)
        mass = you.traits.mass.actual if you.traits.mass else 0
        table = evtable.EvTable(border='header')
        for item in items_not_worn:
            i_mass = mass_unit(item.get_mass()) if hasattr(item,
                                                           'get_mass') else 0
            second = '(|y%s|n) ' % i_mass if 'weight' in self.switches else ''
            second += item.db.desc_brief or item.db.desc or ''
            table.add_row(
                '%s' % item.get_display_name(you.sessions,
                                             mxp=('sense %s' % item.key)),
                second or '')
        my_mass, my_total_mass = [
            mass, you.get_mass() if hasattr(you, 'get_mass') else 0
        ]
        string = "|wYou (%s) and your possessions (%s) total |y%s|n:\n%s" %\
                 (mass_unit(mass), mass_unit(my_total_mass - my_mass),
                  mass_unit(my_total_mass), table)
        if not wear_table.nrows == 0:
            string += "|/|wYou are wearing:\n%s" % wear_table
        you.msg(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 func(self):
     """check inventory"""
     you = self.caller
     items = you.contents
     if not items:
         string = "You are not carrying anything."
     else:
         table = prettytable.PrettyTable(["name", "desc_brief"])
         table.header = False
         table.border = False
         for item in items:
             imass = mass_unit(item.get_mass()) if hasattr(item, "get_mass") else "- unknown -"
             second = imass if "weight" in self.switches else item.db.desc_brief
             table.add_row(
                 [
                     "%s" % item.mxp_name(you.sessions, "@verb #%s" % item.id)
                     if hasattr(item, "mxp_name")
                     else item.get_display_name(you.sessions),
                     second and second or "",
                 ]
             )
         imass = you.get_mass() if hasattr(item, "get_mass") else "- unknown -"
         string = "|wYou and what you carry total |y%s|n:\n%s" % (mass_unit(imass), table)
     you.msg(string)
Пример #5
0
 def func(self):
     """check inventory"""
     you = self.caller
     items = you.contents
     if not items:
         string = 'You are not carrying anything.'
     else:
         table = prettytable.PrettyTable(['name', 'desc_brief'])
         table.header = False
         table.border = False
         for item in items:
             imass = mass_unit(item.get_mass()) if hasattr(
                 item, 'get_mass') else '- unknown -'
             second = imass if 'weight' in self.switches else item.db.desc_brief
             table.add_row([
                 '%s' % item.mxp_name(you.sessions, '@verb #%s' % item.id)
                 if hasattr(item, 'mxp_name') else item.get_display_name(
                     you.sessions), second and second or ''
             ])
         imass = you.get_mass() if hasattr(item,
                                           'get_mass') else '- unknown -'
         string = "|wYou and what you carry total |y%s|n:\n%s" % (
             mass_unit(imass), table)
     you.msg(string)
Пример #6
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
Пример #7
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
Пример #8
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 = self.mxp_name(viewer, '@verb #%s' % self.id)
        string += " (%s)" % mass_unit(self.get_mass())
        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 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) for t in things)
            string += "\n|wContains:|n " + user_list + ut_joiner + item_list
        return string
Пример #9
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 = self.mxp_name(viewer, '@verb #%s' % self.id)
        string += " (%s)" % mass_unit(self.get_mass())
        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 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) for t in things)
            string += "\n|wContains:|n " + user_list + ut_joiner + item_list
        return string
Пример #10
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
Пример #11
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