diff --git a/evennia/objects/objects.py b/evennia/objects/objects.py index d96cdf1f4..90b149fda 100644 --- a/evennia/objects/objects.py +++ b/evennia/objects/objects.py @@ -169,14 +169,18 @@ class DefaultObject(ObjectDB): @property def has_player(self): """ - Convenience function for checking if an active player is - currently connected to this object + Convenience property for checking if an active player is + currently connected to this object. + """ return any(self.sessions) @property def is_superuser(self): - "Check if user has a player, and if so, if it is a superuser." + """ + Check if user has a player, and if so, if it is a superuser. + + """ return self.db_player and self.db_player.is_superuser \ and not self.db_player.attributes.get("_quell") @@ -186,7 +190,16 @@ class DefaultObject(ObjectDB): objects that has this object set as its location. This should be publically available. - exclude is one or more objects to not return + Args: + exclude (Object): Object to exclude from returned + contents list + + Returns: + contents (list): List of contents of this Object. + + Notes: + Also available as the `contents` property. + """ return self.contents_cache.get(exclude=exclude) contents = property(contents_get) @@ -195,8 +208,8 @@ class DefaultObject(ObjectDB): @property def exits(self): """ - Returns all exits from this object, i.e. all objects - at this location having the property destination != None. + Returns all exits from this object, i.e. all objects at this + location having the property destination != `None`. """ return [exi for exi in self.contents if exi.destination] @@ -328,25 +341,25 @@ class DefaultObject(ObjectDB): """ Simple shortcut wrapper to search for players, not characters. - searchdata - search criterion - the key or dbref of the player - to search for. If this is "here" or "me", search - for the player connected to this object. - quiet - return the results as a list rather than echo eventual - standard error messages. + Args: + searchdata (str): Search criterion - the key or dbref of the player + to search for. If this is "here" or "me", search + for the player connected to this object. + quiet (bool): Returns the results as a list rather than + echo eventual standard error messages. Default `False`. Returns: - quiet=False (default): - no match or multimatch: - auto-echoes errors to self.msg, then returns None - (results are handled by settings.SEARCH_AT_RESULT - and settings.SEARCH_AT_MULTIMATCH_INPUT) - match: - a unique player match - quiet=True: - no match or multimatch: - returns None or list of multi-matches - match: - a unique object match + result (Player, None or list): Just what is returned depends on + the `quiet` setting: + - `quiet=True`: No match or multumatch auto-echoes errors + to self.msg, then returns `None`. The esults are passed + through `settings.SEARCH_AT_RESULT` and + `settings.SEARCH_AT_MULTIMATCH_INPUT`. If there is a + unique match, this will be returned. + - `quiet=True`: No automatic error messaging is done, and + what is returned is always a list with 0, 1 or more + matching Players. + """ if isinstance(searchdata, basestring): # searchdata is a string; wrap some common self-references @@ -361,28 +374,33 @@ class DefaultObject(ObjectDB): def execute_cmd(self, raw_string, sessid=None, **kwargs): """ - Do something as this object. This method is a copy of the execute_ - cmd method on the session. This is never called normally, it's only - used when wanting specifically to let an object be the caller of a - command. It makes use of nicks of eventual connected players as well. + Do something as this object. This method is a copy of the + `execute_cmd` method on the session. This is never called + normally, it's only used when wanting specifically to let an + object be the caller of a command. It makes use of nicks of + eventual connected players as well. - Argument: - raw_string (string) - raw command input - sessid (int) - optional session id to return results to - **kwargs - other keyword arguments will be added to the found command - object instace as variables before it executes. This is - unused by default Evennia but may be used to set flags and - change operating paramaters for commands at run-time. + Args: + raw_string (string): Raw command input + sessid (int, optional): Session id to return results to - Returns Deferred - this is an asynchronous Twisted object that will - not fire until the command has actually finished executing. To - overload this one needs to attach callback functions to it, with - addCallback(function). This function will be called with an - eventual return value from the command execution. + Kwargs: + Other keyword arguments will be added to the found command + object instace as variables before it executes. This is + unused by default Evennia but may be used to set flags and + change operating paramaters for commands at run-time. + + Returns: + defer (Deferred): This is an asynchronous Twisted object that + will not fire until the command has actually finished + executing. To overload this one needs to attach + callback functions to it, with addCallback(function). + This function will be called with an eventual return + value from the command execution. This return is not + used at all by Evennia by default, but might be useful + for coders intending to implement some sort of nested + command structure. - This return is not used at all by Evennia by default, but might - be useful for coders intending to implement some sort of nested - command structure. """ # nick replacement - we require full-word matching. # do text encoding conversion @@ -437,10 +455,19 @@ class DefaultObject(ObjectDB): def msg_contents(self, message, exclude=None, from_obj=None, **kwargs): """ - Emits something to all objects inside an object. + Emits a message to all objects inside this object. - exclude is a list of objects not to send to. See self.msg() for + Args: + message (str): Message to send. + exclude (list, optional): A list of objects not to send to. + from_obj (Object, optional): An object designated as the + "sender" of the message. See `DefaultObject.msg()` for more info. + + Kwargs: + Keyword arguments will be passed on to `obj.msg()` for all + messaged objects. + """ contents = self.contents if exclude: @@ -454,13 +481,6 @@ class DefaultObject(ObjectDB): """ Moves this object to a new location. - Moves this object to a new location. Note that if is an - exit object (i.e. it has "destination"!=None), the move_to will - happen to this destination and -not- into the exit object itself, unless - use_destination=False. Note that no lock checks are done by this - function, such things are assumed to have been handled before calling - move_to. - Args: destination (Object): Reference to the object to move to. This can also be an exit object, in which case the @@ -481,8 +501,24 @@ class DefaultObject(ObjectDB): result (bool): True/False depending on if there were problems with the move. This method may also return various error messages to the emit_to_obj. + + Notes: + No access checks are done in this method, these should be handled before + calling `move_to`. + + The `DefaultObject` hooks called (if `move_hooks=True`) are, in order: + + 1. `self.at_before_move(destination)` (if this returns False, move is aborted) + 1. `source_location.at_object_leave(self, destination)` + 1. `self.announce_move_from(destination)` + 1. (move happens here) + 1. `self.announce_move_to(source_location)` + 1. `destination.at_object_receive(self, source_location)` + 1. `self.at_after_move(source_location)` + """ def logerr(string=""): + "Simple log helper method" trc = traceback.format_exc() errstring = "%s%s" % (trc, string) log_trace() @@ -600,8 +636,8 @@ class DefaultObject(ObjectDB): def clear_contents(self): """ - Moves all objects (players/things) to their home - location or to default home. + Moves all objects (players/things) to their home location or + to default home. """ # Gather up everything that thinks this is its location. default_home_id = int(settings.DEFAULT_HOME.lstrip("#")) @@ -645,14 +681,17 @@ class DefaultObject(ObjectDB): def copy(self, new_key=None): """ - Makes an identical copy of this object. If you want to customize the - copy by changing some settings, use ObjectDB.object.copy_object() + Makes an identical copy of this object, identical except for a + new dbref in the database. If you want to customize the copy + by changing some settings, use ObjectDB.object.copy_object() directly. - new_key (string) - new key/name of copied object. If new_key is not - specified, the copy will be named _copy - by default. - Returns: Object (copy of this one) + Args: + new_key (string): New key/name of copied object. If new_key is not + specified, the copy will be named _copy by default. + Returns: + copy (Object): A copy of this object. + """ def find_clone_key(): """ @@ -674,10 +713,14 @@ class DefaultObject(ObjectDB): delete_iter = 0 def delete(self): """ - Deletes this object. - Before deletion, this method makes sure to move all contained - objects to their respective home locations, as well as clean - up all exits to/from the object. + Deletes this object. Before deletion, this method makes sure + to move all contained objects to their respective home + locations, as well as clean up all exits to/from the object. + + Returns: + noerror (bool): Returns whether or not the delete completed + successfully or not. + """ global _ScriptDB if not _ScriptDB: @@ -727,10 +770,12 @@ class DefaultObject(ObjectDB): def __eq__(self, other): """ - Checks for equality against an id string or another object or user. + Checks for equality against an id string or another object or + user. + + Args: + other (Object): object to compare to. - This has be located at this level, having it in the - parent doesn't work. """ try: return self.dbid == other.dbid @@ -741,6 +786,10 @@ class DefaultObject(ObjectDB): except AttributeError: return False + # + # Hook methods + # + def at_first_save(self): """ This is called by the typeclass system whenever an instance of @@ -748,6 +797,7 @@ class DefaultObject(ObjectDB): for calling the startup hooks for the various game entities. When overloading you generally don't overload this but overload the hooks called by this method. + """ self.basetype_setup() self.at_object_creation() @@ -804,11 +854,12 @@ class DefaultObject(ObjectDB): def basetype_setup(self): """ - This sets up the default properties of an Object, - just before the more general at_object_creation. + This sets up the default properties of an Object, just before + the more general at_object_creation. You normally don't need to change this unless you change some fundamental things like names of permission groups. + """ # the default security setup fallback for a generic # object. Overload in child for a custom setup. Also creation @@ -834,21 +885,24 @@ class DefaultObject(ObjectDB): setup after the object is created. An example of this is EXITs, who need to know keys, aliases, locks etc to set up their exit-cmdsets. + """ pass def at_object_creation(self): """ - Called once, when this object is first created. This is - the normal hook to overload for most object types. + Called once, when this object is first created. This is the + normal hook to overload for most object types. + """ pass def at_object_delete(self): """ - Called just before the database object is - permanently delete()d from the database. If - this method returns False, deletion is aborted. + Called just before the database object is permanently + delete()d from the database. If this method returns False, + deletion is aborted. + """ return True @@ -859,6 +913,7 @@ class DefaultObject(ObjectDB): happens on-demand first time the object is used or activated in some way after being created but also after each server restart or reload. + """ pass @@ -868,44 +923,53 @@ class DefaultObject(ObjectDB): command handler. If changes need to be done on the fly to the cmdset before passing them on to the cmdhandler, this is the place to do it. This is called also if the object currently - have no cmdsets. **kwargs are usually not set but could be - used e.g. to force rebuilding of a dynamically created cmdset - or similar. + have no cmdsets. + + Kwargs: + Usually not set but could be used e.g. to force rebuilding + of a dynamically created cmdset or similar. + """ pass def at_pre_puppet(self, player, sessid=None): """ - Called just before a Player connects to this object - to puppet it. + Called just before a Player connects to this object to puppet + it. - player - connecting player object - sessid - session id controlling the connection + Args: + player (Player): This is the connecting player. + sessid (int): Session id controlling the connection. """ pass def at_post_puppet(self): """ - Called just after puppeting has been completed and - all Player<->Object links have been established. + Called just after puppeting has been completed and all + Player<->Object links have been established. + """ self.player.db._last_puppet = self def at_pre_unpuppet(self): """ - Called just before beginning to un-connect a puppeting - from this Player. + Called just before beginning to un-connect a puppeting from + this Player. + """ pass def at_post_unpuppet(self, player, sessid=None): """ - Called just after the Player successfully disconnected - from this object, severing all connections. + Called just after the Player successfully disconnected from + this object, severing all connections. + + Args: + player (Player): The player object that just disconnected + from this object. + sessid (int): Session id controlling the connection that + just disconnected. - player - the player object that just disconnected from - this object. - sessid - session id controlling the connection """ pass @@ -914,6 +978,7 @@ class DefaultObject(ObjectDB): This hook is called whenever the server is shutting down for restart/reboot. If you want to, for example, save non-persistent properties across a restart, this is the place to do it. + """ pass @@ -921,6 +986,7 @@ class DefaultObject(ObjectDB): """ This hook is called whenever the server is shutting down fully (i.e. not for a restart). + """ pass @@ -931,6 +997,17 @@ class DefaultObject(ObjectDB): not affect the result of the lock check. It can be used e.g. to customize error messages in a central location or other effects based on the access result. + + Args: + result (bool): The outcome of the access call. + accessing_obj (Object or Player): The entity trying to + gain access. access_type (str): The type of access that + was requested. + + Kwargs: + Not used by default, added for possible expandability in a + game. + """ pass @@ -939,13 +1016,19 @@ class DefaultObject(ObjectDB): def at_before_move(self, destination): """ - Called just before starting to move - this object to destination. + Called just before starting to move this object to + destination. - destination - the object we are moving to + Args: + destination (Object): The object we are moving to + + Returns: + shouldmove (bool): If we should move or not. + + Notes: + If this method returns False/None, the move is cancelled + before it is even started. - If this method returns False/None, the move - is cancelled before it is even started. """ #return has_perm(self, destination, "can_move") return True @@ -956,7 +1039,9 @@ class DefaultObject(ObjectDB): called while we are still standing in the old location. - destination - the place we are going to. + Args: + destination (Object): The place we are going to. + """ if not self.location: return @@ -969,10 +1054,12 @@ class DefaultObject(ObjectDB): def announce_move_to(self, source_location): """ - Called after the move if the move was not quiet. At this - point we are standing in the new location. + Called after the move if the move was not quiet. At this point + we are standing in the new location. + + Args: + source_location (Object): The place we came from - source_location - the place we came from """ name = self.name @@ -992,10 +1079,13 @@ class DefaultObject(ObjectDB): def at_after_move(self, source_location): """ - Called after move has completed, regardless of quiet mode or not. - Allows changes to the object due to the location it is now in. + Called after move has completed, regardless of quiet mode or + not. Allows changes to the object due to the location it is + now in. + + Args: + source_location (Object): Wwhere we came from. This may be `None`. - source_location - where we came from. This may be None. """ pass @@ -1003,8 +1093,10 @@ class DefaultObject(ObjectDB): """ Called just before an object leaves from inside this object - moved_obj - the object leaving - target_location - where the object is going. + Args: + moved_obj (Object): The object leaving + target_location (Object): Where `moved_obj` is going. + """ pass @@ -1012,93 +1104,140 @@ class DefaultObject(ObjectDB): """ Called after an object has been moved into this object. - moved_obj - the object moved into this one - source_location - where moved_object came from. + Args: + moved_obj (Object): The object moved into this one + source_location (Object): Where `moved_object` came from. + """ pass def at_before_traverse(self, traversing_object): """ - Called just before an object uses this object to - traverse to another object (i.e. this object is a type of Exit) + Called just before an object uses this object to traverse to + another object (i.e. this object is a type of Exit) + + Args: + traversing_object (Object): The object traversing us. + + Notes: + The target destination should normally be available as + `self.destination`. - The target location should normally be available as self.destination. """ pass def at_traverse(self, traversing_object, target_location): """ - This hook is responsible for handling the actual traversal, normally - by calling traversing_object.move_to(target_location). It is normally - only implemented by Exit objects. If it returns False (usually because - move_to returned False), at_after_traverse below should not be called - and instead at_failed_traverse should be called. + This hook is responsible for handling the actual traversal, + normally by calling + `traversing_object.move_to(target_location)`. It is normally + only implemented by Exit objects. If it returns False (usually + because move_to returned False), at_after_traverse below + should not be called and instead at_failed_traverse should be + called. + + Args: + traversing_object (Object): Object traversing us. + target_location (Object): Where target is going. + """ pass def at_after_traverse(self, traversing_object, source_location): """ Called just after an object successfully used this object to - traverse to another object (i.e. this object is a type of Exit) + traverse to another object (i.e. this object is a type of + Exit) - The target location should normally be available as self.destination. + Args: + traversing_object (Object): The object traversing us. + source_location (Object): Where `traversing_object` came from. + + Notes: + The target location should normally be available as `self.destination`. """ pass def at_failed_traverse(self, traversing_object): """ - This is called if an object fails to traverse this object for some - reason. It will not be called if the attribute err_traverse is defined, - that attribute will then be echoed back instead. + This is called if an object fails to traverse this object for + some reason. + + Args: + traversing_object (Object): The object that failed traversing us. + + Notes: + Using the default exits, this hook will not be called if an + Attribute `err_traverse` is defined - this will in that case be + read for an error string instead. + """ pass def at_msg_receive(self, text=None, **kwargs): """ - This hook is called whenever someone - sends a message to this object. + This hook is called whenever someone sends a message to this + object using the `msg` method. - Note that from_obj may be None if the sender did - not include itself as an argument to the obj.msg() - call - so you have to check for this. . + Note that from_obj may be None if the sender did not include + itself as an argument to the obj.msg() call - so you have to + check for this. . + + Consider this a pre-processing method before msg is passed on + to the user sesssion. If this method returns False, the msg + will not be passed on. + + Args: + text (str, optional): The message received. + + Kwargs: + This includes any keywords sent to the `msg` method. + + Returns: + receive (bool): If this message should be received. + + Notes: + If this method returns False, the `msg` operation + will abort without sending the message. - Consider this a pre-processing method before - msg is passed on to the user sesssion. If this - method returns False, the msg will not be - passed on. - Input: - msg = the message received - from_obj = the one sending the message - Output: - boolean True/False """ return True def at_msg_send(self, text=None, to_obj=None, **kwargs): """ - This is a hook that is called when /this/ object - sends a message to another object with obj.msg() - while also specifying that it is the one sending. + This is a hook that is called when *this* object sends a + message to another object with `obj.msg(text, to_obj=obj)`. + + Args: + text (str): Text to send. + to_obj (Object): The object to send to. + + Kwargs: + Keywords passed from msg() + + Notes: + Since this method is executed `from_obj`, if no `from_obj` + was passed to `DefaultCharacter.msg` this hook will never + get called. - Note that this method is executed on the object - passed along with the msg() function (i.e. using - obj.msg(msg, from_obj=caller) will then launch caller.at_msg()) - and if no object was passed, it will never be called. """ pass # hooks called by the default cmdset. - def return_appearance(self, pobject): + def return_appearance(self, looker): """ - This is a convenient hook for a 'look' - command to call. + This formats a description. It is the hook a 'look' command + should call. + + Args: + looker (Object): Object doing the looking. """ - if not pobject: + if not looker: return # get and identify all objects - visible = (con for con in self.contents if con != pobject and - con.access(pobject, "view")) + visible = (con for con in self.contents if con != looker and + con.access(looker, "view")) exits, users, things = [], [], [] for con in visible: key = con.key @@ -1121,39 +1260,58 @@ class DefaultObject(ObjectDB): def at_desc(self, looker=None): """ - This is called whenever someone looks - at this object. Looker is the looking - object. + This is called whenever someone looks at this object. + + looker (Object): The object requesting the description. + """ pass def at_get(self, getter): """ - Called when this object has been picked up. Obs- - this method cannot stop the pickup - use permissions - for that! + Called by the default `get` command when this object has been + picked up. + + Args: + getter (Object): The object getting this object. + + Notes: + This hook cannot stop the pickup from happening. Use + permissions for that. - getter - the object getting this object. """ pass def at_drop(self, dropper): """ - Called when this object has been dropped. + Called by the default `drop` command when this object has been + dropped. + + Args: + dropper (Object): The object which just dropped this object. + + Notes: + This hook cannot stop the pickup from happening. Use + permissions from that. - dropper - the object which just dropped this object. """ pass def at_say(self, speaker, message): """ Called on this object if an object inside this object speaks. - The string returned from this method is the final form - of the speech. Obs - you don't have to add things like - 'you say: ' or similar, that is handled by the say command. + The string returned from this method is the final form of the + speech. + + Args: + speaker (Object): The object speaking. + message (str): The words spoken. + + Notes: + You should not need to add things like 'you say: ' or + similar here, that should be handled by the say command before + this. - speaker - the object speaking - message - the words spoken. """ return message @@ -1164,18 +1322,19 @@ class DefaultObject(ObjectDB): class DefaultCharacter(DefaultObject): """ - This is just like the Object except it implements its own - version of the at_object_creation to set up the script - that adds the default cmdset to the object. + This implements an Object puppeted by a Session and what that + means. + """ def basetype_setup(self): """ - Setup character-specific security + Setup character-specific security. - You should normally not need to overload this, but if you do, make - sure to reproduce at least the two last commands in this method (unless - you want to fundamentally change how a Character object works). + You should normally not need to overload this, but if you do, + make sure to reproduce at least the two last commands in this + method (unless you want to fundamentally change how a + Character object works). """ super(DefaultCharacter, self).basetype_setup() @@ -1184,23 +1343,22 @@ class DefaultCharacter(DefaultObject): # add the default cmdset self.cmdset.add_default(settings.CMDSET_CHARACTER, permanent=True) - def at_object_creation(self): - """ - All this does (for now) is to add the default cmdset. Since - the script is permanently stored to this object (the permanent - keyword creates a script to do this), we should never need to - do this again for as long as this object exists. - """ - pass - def at_after_move(self, source_location): - "Default is to look around after a move." + """ + We make sure to look around after a move. + + """ self.execute_cmd('look') def at_pre_puppet(self, player, sessid=None): """ - This recovers the character again after having been "stoved away" - at the unpuppet + This implementation recovers the character again after having been "stoved + away" to the `None` location in `at_post_unpuppet`. + + Args: + player (Player): This is the connecting player. + sessid (int): Session id controlling the connection. + """ if self.db.prelogout_location: # try to recover @@ -1217,7 +1375,9 @@ class DefaultCharacter(DefaultObject): def at_post_puppet(self): """ - Called just after puppeting has completed. + Called just after puppeting has been completed and all + Player<->Object links have been established. + """ self.msg("\nYou become {c%s{n.\n" % self.name) self.execute_cmd("look") @@ -1227,8 +1387,14 @@ class DefaultCharacter(DefaultObject): def at_post_unpuppet(self, player, sessid=None): """ We stove away the character when the player goes ooc/logs off, - otherwise the character object will remain in the room also after the - player logged off ("headless", so to say). + otherwise the character object will remain in the room also + after the player logged off ("headless", so to say). + + Args: + player (Player): The player object that just disconnected + from this object. + sessid (int): Session id controlling the connection that + just disconnected. """ if self.location: # have to check, in case of multiple connections closing self.location.msg_contents("%s has left the game." % self.name, exclude=[self]) @@ -1242,12 +1408,13 @@ class DefaultCharacter(DefaultObject): class DefaultRoom(DefaultObject): """ This is the base room object. It's just like any Object except its - location is None. + location is always `None`. """ def basetype_setup(self): """ - Simple setup, shown as an example - (since default is None anyway) + Simple room setup setting locks to make sure the room + cannot be picked up. + """ super(DefaultRoom, self).basetype_setup() @@ -1269,6 +1436,7 @@ class DefaultExit(DefaultObject): created dynamically depending on what the exit is called). This command (which has a high priority) will thus allow us to traverse exits simply by giving the exit-object's name on its own. + """ # Helper classes and methods to implement the Exit. These need not @@ -1279,23 +1447,26 @@ class DefaultExit(DefaultObject): """ Helper function for creating an exit command set + command. - The command of this cmdset has the same name as the Exit object - and allows the exit to react when the player enter the exit's name, - triggering the movement between rooms. + The command of this cmdset has the same name as the Exit + object and allows the exit to react when the player enter the + exit's name, triggering the movement between rooms. + + Args: + exiddobj (Object): The DefaultExit object to base the command on. - Note that exitdbobj is an ObjectDB instance. This is necessary - for handling reloads and avoid tracebacks if this is called while - the typeclass system is rebooting. """ class ExitCommand(command.Command): """ - This is a command that simply cause the caller - to traverse the object it is attached to. + This is a command that simply cause the caller to traverse + the object it is attached to. + """ obj = None def func(self): - "Default exit traverse if no syscommand is defined." + """ + Default exit traverse if no syscommand is defined. + """ if self.obj.access(self.caller, 'traverse'): # we may traverse the exit. @@ -1333,8 +1504,9 @@ class DefaultExit(DefaultObject): """ Setup exit-security - You should normally not need to overload this - if you do make sure you - include all the functionality in this method. + You should normally not need to overload this - if you do make + sure you include all the functionality in this method. + """ super(DefaultExit, self).basetype_setup() @@ -1349,28 +1521,32 @@ class DefaultExit(DefaultObject): def at_cmdset_get(self, **kwargs): """ - Called when the cmdset is requested from this object, just before the - cmdset is actually extracted. If no Exit-cmdset is cached, create - it now. + Called just before cmdsets on this object are requested by the + command handler. If changes need to be done on the fly to the + cmdset before passing them on to the cmdhandler, this is the + place to do it. This is called also if the object currently + have no cmdsets. + + Kwargs: + force_init (bool): If `True`, force a re-build of the cmdset + (for example to update aliases). - kwargs: - force_init=True - force a re-build of the cmdset (for example to update aliases) """ if "force_init" in kwargs or not self.cmdset.has_cmdset("_exitset", must_be_default=True): # we are resetting, or no exit-cmdset was set. Create one dynamically. self.cmdset.add_default(self.create_exit_cmdset(self), permanent=False) - # this and other hooks are what usually can be modified safely. - - def at_object_creation(self): - "Called once, when object is first created (after basetype_setup)." - pass def at_traverse(self, traversing_object, target_location): """ - This implements the actual traversal. The traverse lock has already been - checked (in the Exit command) at this point. + This implements the actual traversal. The traverse lock has + already been checked (in the Exit command) at this point. + + Args: + traversing_object (Object): Object traversing us. + target_location (Object): Where target is going. + """ source_location = traversing_object.location if traversing_object.move_to(target_location): @@ -1383,19 +1559,17 @@ class DefaultExit(DefaultObject): # No shorthand error message. Call hook. self.at_failed_traverse(traversing_object) - def at_after_traverse(self, traversing_object, source_location): - """ - Called after a successful traverse. - """ - pass - def at_failed_traverse(self, traversing_object): """ - This is called if an object fails to traverse this object for some - reason. It will not be called if the attribute "err_traverse" is - defined, that attribute will then be echoed back instead as a - convenient shortcut. + Overloads the default hook to implement a simple default error message. + + Args: + traversing_object (Object): The object that failed traversing us. + + Notes: + Using the default exits, this hook will not be called if an + Attribute `err_traverse` is defined - this will in that case be + read for an error string instead. - (See also hooks at_before_traverse and at_after_traverse). """ traversing_object.msg("You cannot go there.")