# Path: evdemo/evscaperoom/utils.py
# def create_evscaperoom_object(typeclass=None, key="testobj", location=None,
#                               delete_duplicates=True, **kwargs):
#     """
#     This is a convenience-wrapper for quickly building EvscapeRoom objects. This
#     is called from the helper-method create_object on states, but is also useful
#     for the object-create admin command.
# 
#     Note that for the purpose of the Evscaperoom, we only allow one instance
#     of each *name*, deleting the old version if it already exists.
# 
#     Kwargs:
#         typeclass (str): This can take just the class-name in the evscaperoom's
#             objects.py module. Otherwise, a full path is needed.
#         key (str): Name of object.
#         location (Object): The location to create new object.
#         delete_duplicates (bool): Delete old object with same key.
#         kwargs (any): Will be passed into create_object.
#     Returns:
#         new_obj (Object): The newly created object, if any.
# 
# 
#     """
#     if not (callable(typeclass) or
#             typeclass.startswith("evennia") or
#             typeclass.startswith("typeclasses") or
#             typeclass.startswith("evscaperoom")):
#         # unless we specify a full typeclass path or the class itself,
#         # auto-complete it
#         typeclass = _BASE_TYPECLASS_PATH + typeclass
# 
#     if delete_duplicates:
#         old_objs = [obj for obj in search_object(key)
#                     if not inherits_from(obj, "evennia.objects.objects.DefaultCharacter")]
#         if location:
#             # delete only matching objects in the given location
#             [obj.delete() for obj in old_objs if obj.location == location]
#         else:
#             [obj.delete() for obj in old_objs]
# 
#     new_obj = create_object(typeclass=typeclass, key=key,
#                             location=location, **kwargs)
#     return new_obj
# 
# Path: evdemo/evscaperoom/utils.py
# def parse_for_perspectives(string, you=None):
#     """
#     Parse a string with special markers to produce versions both
#     intended for the person doing the action ('you') and for those
#     seeing the person doing that action. Also marks 'things'
#     according to style. See example below.
# 
#     Args:
#         string (str): String on 2nd person form with ~ markers ('~you ~open ...')
#         you (str): What others should see instead of you (Bob opens)
#     Returns:
#         second, third_person (tuple): Strings replace to be shown in 2nd and 3rd person
#             perspective
#     Example:
#         "~You ~open"
#         ->  "You open", "Bob opens"
#     """
#     def _replace_third_person(match):
#         match = match.group(1)
#         lmatch = match.lower()
#         if lmatch == "you":
#             return "|c{}|n".format(you)
#         elif lmatch in irregulars:
#             if match[0].isupper():
#                 return irregulars[lmatch].capitalize()
#             return irregulars[lmatch]
#         elif lmatch[-1] == 's':
#             return match + "es"
#         else:
#             return match + "s"  # simple, most normal form
# 
#     you = "They" if you is None else you
# 
#     first_person = _RE_PERSPECTIVE.sub(r"\1", string)
#     third_person = _RE_PERSPECTIVE.sub(_replace_third_person, string)
#     return first_person, third_person
# 
# def parse_for_things(string, things_style=2, clr="|y"):
#     """
#     Parse string for special *thing markers and decorate
#     it.
# 
#     Args:
#         string (str): The string to parse.
#         things_style (int): The style to handle `*things` marked:
#             0 - no marking (remove `*`)
#             1 - mark with color
#             2 - mark with color and [] (default)
#         clr (str): Which color to use for marker..
#     Example:
#         You open *door -> You open [door].
#     """
#     if not things_style:
#         # hardcore mode - no marking of focus targets
#         return _RE_THING.sub(r"\1", string)
#     elif things_style == 1:
#         # only colors
#         return _RE_THING.sub(r"{}\1|n".format(clr), string)
#     else:
#         # colors and brackets
#         return _RE_THING.sub(r"{}[\1]|n".format(clr), string)


import re
import inspect
from evennia import DefaultObject
from evennia.utils.utils import list_to_string, wrap
from .utils import create_evscaperoom_object
from .utils import parse_for_perspectives, parse_for_things
                       "suitable to {callsigns}.")
        return command_signatures, helpstr

    def get_short_desc(self, full_desc):
        """
        Extract the first sentence from the desc and use as the short desc.

        """
        mat = re.match(r"(^.*?[.?!])", full_desc.strip(), re.M+re.U+re.I+re.S)
        if mat:
            return mat.group(0).strip()
        return full_desc

    def get_help(self, caller):
        """
        Get help about this object. By default we return a
        listing of all actions you can do on this object.

        """
        # custom-created signatures. We don't sort these
        command_signatures, helpstr = self.get_cmd_signatures()

        callsigns = list_to_string(["*" + sig for sig in command_signatures], endsep="or")

        # parse for *thing markers (use these as items)
        options = caller.attributes.get(
            "options", category=self.room.tagcategory, default={})
        style = options.get("things_style", 2)

        helpstr = helpstr.format(callsigns=callsigns)

# Path: evdemo/evscaperoom/utils.py
# def create_evscaperoom_object(typeclass=None, key="testobj", location=None,
#                               delete_duplicates=True, **kwargs):
#     """
#     This is a convenience-wrapper for quickly building EvscapeRoom objects. This
#     is called from the helper-method create_object on states, but is also useful
#     for the object-create admin command.
# 
#     Note that for the purpose of the Evscaperoom, we only allow one instance
#     of each *name*, deleting the old version if it already exists.
# 
#     Kwargs:
#         typeclass (str): This can take just the class-name in the evscaperoom's
#             objects.py module. Otherwise, a full path is needed.
#         key (str): Name of object.
#         location (Object): The location to create new object.
#         delete_duplicates (bool): Delete old object with same key.
#         kwargs (any): Will be passed into create_object.
#     Returns:
#         new_obj (Object): The newly created object, if any.
# 
# 
#     """
#     if not (callable(typeclass) or
#             typeclass.startswith("evennia") or
#             typeclass.startswith("typeclasses") or
#             typeclass.startswith("evscaperoom")):
#         # unless we specify a full typeclass path or the class itself,
#         # auto-complete it
#         typeclass = _BASE_TYPECLASS_PATH + typeclass
# 
#     if delete_duplicates:
#         old_objs = [obj for obj in search_object(key)
#                     if not inherits_from(obj, "evennia.objects.objects.DefaultCharacter")]
#         if location:
#             # delete only matching objects in the given location
#             [obj.delete() for obj in old_objs if obj.location == location]
#         else:
#             [obj.delete() for obj in old_objs]
# 
#     new_obj = create_object(typeclass=typeclass, key=key,
#                             location=location, **kwargs)
#     return new_obj
# 
# Path: evdemo/evscaperoom/utils.py
# def parse_for_perspectives(string, you=None):
#     """
#     Parse a string with special markers to produce versions both
#     intended for the person doing the action ('you') and for those
#     seeing the person doing that action. Also marks 'things'
#     according to style. See example below.
# 
#     Args:
#         string (str): String on 2nd person form with ~ markers ('~you ~open ...')
#         you (str): What others should see instead of you (Bob opens)
#     Returns:
#         second, third_person (tuple): Strings replace to be shown in 2nd and 3rd person
#             perspective
#     Example:
#         "~You ~open"
#         ->  "You open", "Bob opens"
#     """
#     def _replace_third_person(match):
#         match = match.group(1)
#         lmatch = match.lower()
#         if lmatch == "you":
#             return "|c{}|n".format(you)
#         elif lmatch in irregulars:
#             if match[0].isupper():
#                 return irregulars[lmatch].capitalize()
#             return irregulars[lmatch]
#         elif lmatch[-1] == 's':
#             return match + "es"
#         else:
#             return match + "s"  # simple, most normal form
# 
#     you = "They" if you is None else you
# 
#     first_person = _RE_PERSPECTIVE.sub(r"\1", string)
#     third_person = _RE_PERSPECTIVE.sub(_replace_third_person, string)
#     return first_person, third_person
# 
# def parse_for_things(string, things_style=2, clr="|y"):
#     """
#     Parse string for special *thing markers and decorate
#     it.
# 
#     Args:
#         string (str): The string to parse.
#         things_style (int): The style to handle `*things` marked:
#             0 - no marking (remove `*`)
#             1 - mark with color
#             2 - mark with color and [] (default)
#         clr (str): Which color to use for marker..
#     Example:
#         You open *door -> You open [door].
#     """
#     if not things_style:
#         # hardcore mode - no marking of focus targets
#         return _RE_THING.sub(r"\1", string)
#     elif things_style == 1:
#         # only colors
#         return _RE_THING.sub(r"{}\1|n".format(clr), string)
#     else:
#         # colors and brackets
#         return _RE_THING.sub(r"{}[\1]|n".format(clr), string)


# Path: evdemo/evscaperoom/objects.py
import re
import inspect
from evennia import DefaultObject
from evennia.utils.utils import list_to_string, wrap
from .utils import create_evscaperoom_object
from .utils import parse_for_perspectives, parse_for_things

                       "suitable to {callsigns}.")
        return command_signatures, helpstr

    def get_short_desc(self, full_desc):
        """
        Extract the first sentence from the desc and use as the short desc.

        """
        mat = re.match(r"(^.*?[.?!])", full_desc.strip(), re.M+re.U+re.I+re.S)
        if mat:
            return mat.group(0).strip()
        return full_desc

    def get_help(self, caller):
        """
        Get help about this object. By default we return a
        listing of all actions you can do on this object.

        """
        # custom-created signatures. We don't sort these
        command_signatures, helpstr = self.get_cmd_signatures()

        callsigns = list_to_string(["*" + sig for sig in command_signatures], endsep="or")

        # parse for *thing markers (use these as items)
        options = caller.attributes.get(
            "options", category=self.room.tagcategory, default={})
        style = options.get("things_style", 2)

        helpstr = helpstr.format(callsigns=callsigns)

        helpstr = parse_for_things(helpstr, style, clr="|w")