Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.76 KB | None | 0 0
  1.  # This is displayed when a player looks at the room.
  2.     def return_appearance(self, looker, **kwargs):
  3.  
  4.         if not looker:
  5.             return ''
  6.  
  7.         string = ''
  8.  
  9.         # Cache the looker's screen width.
  10.         len = looker.screenwidth
  11.  
  12.         # Note: I want the looker to be the first player in the list so I remove them
  13.         # from the contents list and add them manually to 'players', but only
  14.         # if they're not doing a remote look.
  15.         visible = (con for con in self.contents if con != looker and con.access(looker, "view"))
  16.         exits, players, things, views = [], [], [], []
  17.        
  18.         if looker.location is self:
  19.             players = [looker]
  20.        
  21.        
  22.         # Filter the visible objects into lists based on their type.
  23.         for con in visible:
  24.             if con.destination:
  25.                 exits.append(con)
  26.             elif con.has_account:
  27.                 if con.sessions > 0:
  28.                     players.append(con)
  29.             else:
  30.                 things.append(con)
  31.  
  32.         # Start with the name of the room.
  33.         string += self.format_name(len)
  34.         # Add the description.
  35.         string += self.format_desc(len)
  36.         #string += utils.subheader('', len, nonewline=True)
  37.         # Add players if there are any.
  38.         if players:
  39.             string += self.format_players(len, players, looker)
  40.         # Add non-player things if there are any.
  41.         if things:
  42.             string += self.format_contents(len, things)
  43.         # Add exits if there are any.
  44.         if exits:            
  45.             string += self.format_exits(len, exits)
  46.        
  47.         # Add footer.
  48.         string += self.format_footer(len)
  49.  
  50.         # Return the formatted string.
  51.         return string
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement