Fixed remaining issues. All tests pass.

This commit is contained in:
Andrew Bastien 2022-07-14 22:53:37 -04:00
parent 93aae906bf
commit e0dc224d08
5 changed files with 37 additions and 27 deletions

View file

@ -189,7 +189,7 @@ class EventCharacter(DefaultCharacter):
"""Return the CallbackHandler.""" """Return the CallbackHandler."""
return CallbackHandler(self) return CallbackHandler(self)
def announce_move_from(self, destination, msg=None, mapping=None): def announce_move_from(self, destination, msg=None, move_type="move", mapping=None, **kwargs):
""" """
Called if the move is to be announced. This is Called if the move is to be announced. This is
called while we are still standing in the old called while we are still standing in the old
@ -234,9 +234,9 @@ class EventCharacter(DefaultCharacter):
if not string: if not string:
return return
super().announce_move_from(destination, msg=string, mapping=mapping) super().announce_move_from(destination, msg=string, move_type=move_type, mapping=mapping, **kwargs)
def announce_move_to(self, source_location, msg=None, mapping=None): def announce_move_to(self, source_location, msg=None, move_type="move", mapping=None, **kwargs):
""" """
Called after the move if the move was not quiet. At this point Called after the move if the move was not quiet. At this point
we are standing in the new location. we are standing in the new location.
@ -292,9 +292,9 @@ class EventCharacter(DefaultCharacter):
if not string: if not string:
return return
super().announce_move_to(source_location, msg=string, mapping=mapping) super().announce_move_to(source_location, msg=string, move_type=move_type, mapping=mapping, **kwargs)
def at_pre_move(self, destination): def at_pre_move(self, destination, move_type="move", **kwargs):
""" """
Called just before starting to move this object to Called just before starting to move this object to
destination. destination.
@ -334,7 +334,7 @@ class EventCharacter(DefaultCharacter):
return True return True
def at_post_move(self, source_location): def at_post_move(self, source_location, move_type="move", **kwargs):
""" """
Called after move has completed, regardless of quiet mode or Called after move has completed, regardless of quiet mode or
not. Allows changes to the object due to the location it is not. Allows changes to the object due to the location it is
@ -644,7 +644,7 @@ class EventExit(DefaultExit):
"""Return the CallbackHandler.""" """Return the CallbackHandler."""
return CallbackHandler(self) return CallbackHandler(self)
def at_traverse(self, traversing_object, target_location): def at_traverse(self, traversing_object, target_location, **kwargs):
""" """
This hook is responsible for handling the actual traversal, This hook is responsible for handling the actual traversal,
normally by calling normally by calling
@ -665,7 +665,7 @@ class EventExit(DefaultExit):
if not allow: if not allow:
return return
super().at_traverse(traversing_object, target_location) super().at_traverse(traversing_object, target_location, **kwargs)
# After traversing # After traversing
if is_character: if is_character:
@ -732,7 +732,7 @@ class EventObject(DefaultObject):
"""Return the CallbackHandler.""" """Return the CallbackHandler."""
return CallbackHandler(self) return CallbackHandler(self)
def at_get(self, getter): def at_get(self, getter, **kwargs):
""" """
Called by the default `get` command when this object has been Called by the default `get` command when this object has been
picked up. picked up.
@ -745,10 +745,10 @@ class EventObject(DefaultObject):
permissions for that. permissions for that.
""" """
super().at_get(getter) super().at_get(getter, **kwargs)
self.callbacks.call("get", getter, self) self.callbacks.call("get", getter, self)
def at_drop(self, dropper): def at_drop(self, dropper, **kwargs):
""" """
Called by the default `drop` command when this object has been Called by the default `drop` command when this object has been
dropped. dropped.
@ -761,7 +761,7 @@ class EventObject(DefaultObject):
permissions from that. permissions from that.
""" """
super().at_drop(dropper) super().at_drop(dropper, **kwargs)
self.callbacks.call("drop", dropper, self) self.callbacks.call("drop", dropper, self)

View file

@ -185,7 +185,7 @@ class EvscapeRoom(EvscaperoomObject, DefaultRoom):
# Evennia hooks # Evennia hooks
def at_object_receive(self, moved_obj, source_location): def at_object_receive(self, moved_obj, source_location, move_type="move", **kwargs):
""" """
Called when an object arrives in the room. This can be used to Called when an object arrives in the room. This can be used to
sum up the situation, set tags etc. sum up the situation, set tags etc.
@ -195,7 +195,7 @@ class EvscapeRoom(EvscaperoomObject, DefaultRoom):
self.log(f"JOIN: {moved_obj} joined room") self.log(f"JOIN: {moved_obj} joined room")
self.state.character_enters(moved_obj) self.state.character_enters(moved_obj)
def at_object_leave(self, moved_obj, target_location, **kwargs): def at_object_leave(self, moved_obj, target_location, move_type="move", **kwargs):
""" """
Called when an object leaves the room; if this is a Character we need Called when an object leaves the room; if this is a Character we need
to clean them up and move them to the menu state. to clean them up and move them to the menu state.

View file

@ -538,7 +538,7 @@ class WildernessRoom(DefaultRoom):
# This object wasn't in the wilderness yet. Let's add it. # This object wasn't in the wilderness yet. Let's add it.
itemcoords[moved_obj] = self.coordinates itemcoords[moved_obj] = self.coordinates
def at_object_leave(self, moved_obj, target_location): def at_object_leave(self, moved_obj, target_location, move_type="move", **kwargs):
""" """
Called just before an object leaves from inside this object. This is a Called just before an object leaves from inside this object. This is a
default Evennia hook. default Evennia hook.

View file

@ -259,7 +259,7 @@ class TutorialRoom(DefaultRoom):
) )
self.cmdset.add_default(TutorialRoomCmdSet) self.cmdset.add_default(TutorialRoomCmdSet)
def at_object_receive(self, new_arrival, source_location): def at_object_receive(self, new_arrival, source_location, move_type="move", **kwargs):
""" """
When an object enter a tutorial room we tell other objects in When an object enter a tutorial room we tell other objects in
the room about it by trying to call a hook on them. The Mob object the room about it by trying to call a hook on them. The Mob object
@ -451,7 +451,7 @@ class IntroRoom(TutorialRoom):
"the account." "the account."
) )
def at_object_receive(self, character, source_location): def at_object_receive(self, character, source_location, move_type="move", **kwargs):
""" """
Assign properties on characters Assign properties on characters
""" """
@ -770,7 +770,7 @@ class BridgeRoom(WeatherRoom):
# send a message most of the time # send a message most of the time
self.msg_contents("|w%s|n" % random.choice(BRIDGE_WEATHER)) self.msg_contents("|w%s|n" % random.choice(BRIDGE_WEATHER))
def at_object_receive(self, character, source_location): def at_object_receive(self, character, source_location, move_type="move", **kwargs):
""" """
This hook is called by the engine whenever the player is moved This hook is called by the engine whenever the player is moved
into this room. into this room.
@ -796,7 +796,7 @@ class BridgeRoom(WeatherRoom):
character.db.tutorial_bridge_position = 0 character.db.tutorial_bridge_position = 0
character.execute_cmd("look") character.execute_cmd("look")
def at_object_leave(self, character, target_location): def at_object_leave(self, character, target_location, move_type="move", **kwargs):
""" """
This is triggered when the player leaves the bridge room. This is triggered when the player leaves the bridge room.
""" """
@ -1038,7 +1038,7 @@ class DarkRoom(TutorialRoom):
# put players in darkness # put players in darkness
char.msg("The room is completely dark.") char.msg("The room is completely dark.")
def at_object_receive(self, obj, source_location): def at_object_receive(self, obj, source_location, move_type="move", **kwargs):
""" """
Called when an object enters the room. Called when an object enters the room.
""" """
@ -1048,7 +1048,7 @@ class DarkRoom(TutorialRoom):
# in case the new guy carries light with them # in case the new guy carries light with them
self.check_light_state() self.check_light_state()
def at_object_leave(self, obj, target_location): def at_object_leave(self, obj, target_location, move_type="move", **kwargs):
""" """
In case people leave with the light, we make sure to clear the In case people leave with the light, we make sure to clear the
DarkCmdSet if necessary. This also works if they are DarkCmdSet if necessary. This also works if they are
@ -1103,7 +1103,7 @@ class TeleportRoom(TutorialRoom):
self.db.failure_teleport_msg = "You fail!" self.db.failure_teleport_msg = "You fail!"
self.db.failure_teleport_to = "dark cell" self.db.failure_teleport_to = "dark cell"
def at_object_receive(self, character, source_location): def at_object_receive(self, character, source_location, move_type="move", **kwargs):
""" """
This hook is called by the engine whenever the player is moved into This hook is called by the engine whenever the player is moved into
this room. this room.
@ -1167,7 +1167,7 @@ class OutroRoom(TutorialRoom):
"character." "character."
) )
def at_object_receive(self, character, source_location): def at_object_receive(self, character, source_location, move_type="move", **kwargs):
""" """
Do cleanup. Do cleanup.
""" """
@ -1183,6 +1183,6 @@ class OutroRoom(TutorialRoom):
obj.delete() obj.delete()
character.tags.clear(category="tutorial_world") character.tags.clear(category="tutorial_world")
def at_object_leave(self, character, destination): def at_object_leave(self, character, destination, move_type="move", **kwargs):
if character.account: if character.account:
character.account.execute_cmd("unquell") character.account.execute_cmd("unquell")

View file

@ -1486,6 +1486,9 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
Args: Args:
destination (Object): The object we are moving to destination (Object): The object we are moving to
move_type (str): The type of move. "give", "traverse", etc. move_type (str): The type of move. "give", "traverse", etc.
This is an arbitrary string provided to obj.move_to().
Useful for altering messages or altering logic depending
on the kind of movement.
**kwargs (dict): Arbitrary, optional arguments for users **kwargs (dict): Arbitrary, optional arguments for users
overriding the call (unused by default). overriding the call (unused by default).
@ -1622,7 +1625,7 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
destination.msg_contents((string, {"type": move_type}), exclude=(self,), from_obj=self, mapping=mapping) destination.msg_contents((string, {"type": move_type}), exclude=(self,), from_obj=self, mapping=mapping)
def at_post_move(self, source_location, **kwargs): def at_post_move(self, source_location, move_type="move", **kwargs):
""" """
Called after move has completed, regardless of quiet mode or Called after move has completed, regardless of quiet mode or
not. Allows changes to the object due to the location it is not. Allows changes to the object due to the location it is
@ -1630,6 +1633,10 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
Args: Args:
source_location (Object): Wwhere we came from. This may be `None`. source_location (Object): Wwhere we came from. This may be `None`.
move_type (str): The type of move. "give", "traverse", etc.
This is an arbitrary string provided to obj.move_to().
Useful for altering messages or altering logic depending
on the kind of movement.
**kwargs (dict): Arbitrary, optional arguments for users **kwargs (dict): Arbitrary, optional arguments for users
overriding the call (unused by default). overriding the call (unused by default).
@ -1647,6 +1654,9 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
moved_obj (Object): The object leaving moved_obj (Object): The object leaving
target_location (Object): Where `moved_obj` is going. target_location (Object): Where `moved_obj` is going.
move_type (str): The type of move. "give", "traverse", etc. move_type (str): The type of move. "give", "traverse", etc.
This is an arbitrary string provided to obj.move_to().
Useful for altering messages or altering logic depending
on the kind of movement.
**kwargs (dict): Arbitrary, optional arguments for users **kwargs (dict): Arbitrary, optional arguments for users
overriding the call (unused by default). overriding the call (unused by default).
@ -2668,9 +2678,9 @@ class ExitCommand(_COMMAND_DEFAULT_CLASS):
""" """
if self.obj.destination: if self.obj.destination:
return " (exit to %s)" % self.obj.destination.get_display_name(caller) return " (exit to %s)" % self.obj.destination.get_display_name(caller, **kwargs)
else: else:
return " (%s)" % self.obj.get_display_name(caller) return " (%s)" % self.obj.get_display_name(caller, **kwargs)
# #