Merge branch 'evennia:main' into v4.1.1-patched

This commit is contained in:
Adam Curtis 2024-07-06 18:46:50 -04:00 committed by GitHub
commit bd9a8a8636
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
110 changed files with 3331 additions and 640 deletions

View file

@ -178,26 +178,30 @@ class ObjManipCommand(COMMAND_DEFAULT_CLASS):
def get_object_typeclass(
self, obj_type: str = "object", typeclass: str = None, method: str = "cmd_create", **kwargs
) -> tuple[typing.Optional["Builder"], list[str]]:
) -> tuple[typing.Optional["Typeclass"], list[str]]:
"""
This hook is called by build commands to determine which typeclass to use for a specific purpose. For instance,
when using dig, the system can use this to autodetect which kind of Room typeclass to use based on where the
builder is currently located.
Note: Although intended to be used with typeclasses, as long as this hook returns a class with a create method,
which accepts the same API as DefaultObject.create(), build commands and other places should take it.
This hook is called by build commands to determine which typeclass to use for a specific
purpose.
Args:
obj_type (str, optional): The type of object that is being created. Defaults to "object". Evennia provides
"room", "exit", and "character" by default, but this can be extended.
typeclass (str, optional): The typeclass that was requested by the player. Defaults to None.
Can also be an actual class.
obj_type (str, optional): The type of object that is being created. Defaults to
"object". Evennia provides "room", "exit", and "character" by default, but this can be
extended.
typeclass (str, optional): The typeclass that was requested by the player. Defaults to
None. Can also be an actual class.
method (str, optional): The method that is calling this hook. Defaults to "cmd_create".
Others are "cmd_dig", "cmd_open", "cmd_tunnel", etc.
Returns:
results_tuple (tuple[Optional[Builder], list[str]]): A tuple containing the typeclass to use and a list of
errors. (which might be empty.)
tuple: A tuple containing the typeclass to use and a list of errors. (which might be
empty.)
Notes:
Although intended to be used with typeclasses, as long as this hook returns a class with
a create method, which accepts the same API as DefaultObject.create(), build commands
and other places should take it. While not used by default, one could picture using this
for things like autodetecting which room to build next based on the current location.
"""
found_typeclass = typeclass or self.default_typeclasses.get(obj_type, None)
@ -1028,7 +1032,7 @@ class CmdDig(ObjManipCommand):
if new_room.aliases.all():
alias_string = " (%s)" % ", ".join(new_room.aliases.all())
room_string = f"Created room {new_room}({new_room.dbref}){alias_string} of type {new_room}."
room_string = f"Created room {new_room}({new_room.dbref}){alias_string} of type {new_room.typeclass_path}."
# create exit to room