update container docs, test

This commit is contained in:
Cal 2023-03-29 10:48:46 -06:00
parent 7339e0e630
commit 3c37fc099c
2 changed files with 19 additions and 2 deletions

View file

@ -73,6 +73,9 @@ class ContribContainer(_BASE_OBJECT_TYPECLASS):
Returns: Returns:
boolean: Whether the object `target` should be gotten or not. boolean: Whether the object `target` should be gotten or not.
Notes:
If this method returns False/None, the getting is cancelled before it is even started.
""" """
return True return True
@ -87,7 +90,8 @@ class ContribContainer(_BASE_OBJECT_TYPECLASS):
Returns: Returns:
boolean: Whether the object `target` should be put down or not. boolean: Whether the object `target` should be put down or not.
Note: Notes:
If this method returns False/None, the putting is cancelled before it is even started.
To add more complex capacity checks, modify this method on your child typeclass. To add more complex capacity checks, modify this method on your child typeclass.
""" """
# check if we're already at capacity # check if we're already at capacity
@ -261,7 +265,7 @@ class CmdPut(CmdDrop):
if container.db.put_err_msg: if container.db.put_err_msg:
self.msg(container.db.put_err_msg) self.msg(container.db.put_err_msg)
else: else:
self.msg("You can't get things from that.") self.msg("You can't put things in that.")
return return
# Call the object script's at_pre_drop() method. # Call the object script's at_pre_drop() method.

View file

@ -36,3 +36,16 @@ class TestContainerCmds(BaseEvenniaCommandTest):
self.call(CmdPut(), "obj in box", "You put an Obj in a Box.") self.call(CmdPut(), "obj in box", "You put an Obj in a Box.")
# get from the container # get from the container
self.call(CmdContainerGet(), "obj from box", "You get an Obj from a Box.") self.call(CmdContainerGet(), "obj from box", "You get an Obj from a Box.")
def test_locked_get_put(self):
# lock container
self.container.locks.add("get_from:false()")
# move object to container to try getting
self.obj1.location = self.container
self.call(CmdContainerGet(), "obj from box", "You can't get things from that.")
# move object to character to try putting
self.obj1.location = self.char1
self.call(CmdPut(), "obj in box", "You can't put things in that.")