Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Format the room description.
- def return_appearance(self, looker, **kwargs):
- """
- This formats a description. It is the hook a 'look' command
- should call.
- Args:
- looker (Object): Object doing the looking.
- **kwargs (dict): Arbitrary, optional arguments for users
- overriding the call (unused by default).
- """
- if not looker:
- return ""
- # Cache the looker's screenwidth. This will default to 80.
- len = looker.screenwidth()
- # Get and identify all objects. This needs to be replaced with
- # the new visible_contents method that knows about dark and
- # visibility.
- visible = (con for con in self.contents if con != looker and
- con.access(looker, "view"))
- # Initialize the lists of the various types of objects we're looking for.
- exits, users, things, places, views = [], [], [], [], []
- # Add the looker to the front of the users list.
- if looker.location is self:
- users = [looker]
- # Filter the visible objects into lists based on their type.
- for con in visible:
- if con.destination:
- exits.append(con)
- elif con.has_account and con.sessions:
- # If you want dark sleepers, remove 'and con.sessions > 0'
- users.append(con)
- elif isinstance(con, Place):
- places.append(con)
- else:
- things.append(con)
- string = header(self.format_name(looker), len)
- desc = self.db.desc
- if desc:
- string += "%s\n" % desc
- if places:
- string += subheader("Places", len)
- string += self.format_contents(looker, places, len)
- if views:
- string += subheader("Views", len)
- string += self.format_views(looker, views, len)
- if users:
- string += subheader('Players', len, nonewline=True)
- string += self.format_players(looker, users, len)
- if things:
- string += subheader('Things', len)
- string += self.format_contents(looker, things, len)
- string += '\n'
- # TODO: This needs to be spit into it's own method!
- if exits:
- # Sort exits.
- ex = self.sort_exits(exits)
- # Initialize a list to hold our formatted exits.
- out = []
- # Process our exits.
- for x in ex:
- # Grab the aliases from the aliasmanager.
- # This could be a string -or- a list of strings.
- a = x.aliases.all()
- if a:
- # If `a` is a List then use the first element only,
- # otherwise we'll use the whole thing.
- if type(a) is list:
- # Uppercase this shit.
- s = a[0].upper()
- else:
- s = a.upper()
- else:
- # No aliases, just use the name of the exit.
- s = x.key
- # Append the formatted exit spec to the output list.
- out.append( "%s |r<|530%s|r>|n" % (x.key, s))
- # Add our header to the output string.
- string += subheader('Exits', len)
- # Columnize the output list and add it to the output string.
- string += columnize(out, width=len, cols=3)
- # Add a trailing newline to the output string.
- string += '\n'
- # Now let's look for other crap.
- i = []
- if self.db.views:
- i.append('views')
- if self.db.features:
- i.append('features')
- if looker.admin() and self.db.jnotes:
- i.append('jnotes')
- # Add the footer to the output string.
- string += footer(", ".join(i), len, nonewline=True)
- # Return the output string.
- return string
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement