Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # populated by `return_appearance`
- appearance_template = """
- {header}
- |c\n{name}|n
- {desc}
- {exits}{characters}{things}
- {footer}
- """
- def return_appearance(self, looker, **kwargs):
- """
- Main callback used by 'look' for the object to describe itself.
- This formats a description. By default, this looks for the `appearance_template`
- string set on this class and populates it with formatting keys
- 'name', 'desc', 'exits', 'characters', 'things' as well as
- (currently empty) 'header'/'footer'.
- Args:
- looker (Object): Object doing the looking.
- **kwargs (dict): Arbitrary, optional arguments for users
- overriding the call. This is passed into the helper
- methods and into `get_display_name` calls.
- Returns:
- str: The description of this entity. By default this includes
- the entity's name, description and any contents inside it.
- Notes:
- To simply change the layout of how the object displays itself (like
- adding some line decorations or change colors of different sections),
- you can simply edit `.appearance_template`. You only need to override
- this method (and/or its helpers) if you want to change what is passed
- into the template or want the most control over output.
- """
- if not looker:
- return ""
- # ourselves
- name = self.get_display_name(looker, **kwargs)
- desc = self.db.desc or "Description non définie."
- # contents
- content_names_map = self.get_content_names(looker, **kwargs)
- exits = list_to_string(content_names_map["exits"])
- characters = list_to_string(content_names_map["characters"])
- things = list_to_string(content_names_map["things"])
- # populate the appearance_template string. It's a good idea to strip it and
- # let the client add any extra spaces instead.
- return self.appearance_template.format(
- header="",
- name=name,
- desc=desc,
- exits=f"|wExits:|n {exits}" if exits else "",
- characters=f"\n|wPersonnages:|n {characters}" if characters else "",
- things=f"\n|wAgents:|n {things}" if things else "",
- footer="",
- ).strip()
Advertisement
Add Comment
Please, Sign In to add comment