From a76ca4e387c0c91ada6a0248c3abe45ab0782ab3 Mon Sep 17 00:00:00 2001 From: Cal Date: Wed, 29 Mar 2023 10:48:46 -0600 Subject: [PATCH] update container docs, test --- .../contrib/game_systems/containers/containers.py | 8 ++++++-- evennia/contrib/game_systems/containers/tests.py | 13 +++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/evennia/contrib/game_systems/containers/containers.py b/evennia/contrib/game_systems/containers/containers.py index 19cbcf76bb..8e0c70579e 100644 --- a/evennia/contrib/game_systems/containers/containers.py +++ b/evennia/contrib/game_systems/containers/containers.py @@ -73,6 +73,9 @@ class ContribContainer(_BASE_OBJECT_TYPECLASS): Returns: 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 @@ -87,7 +90,8 @@ class ContribContainer(_BASE_OBJECT_TYPECLASS): Returns: 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. """ # check if we're already at capacity @@ -261,7 +265,7 @@ class CmdPut(CmdDrop): if container.db.put_err_msg: self.msg(container.db.put_err_msg) else: - self.msg("You can't get things from that.") + self.msg("You can't put things in that.") return # Call the object script's at_pre_drop() method. diff --git a/evennia/contrib/game_systems/containers/tests.py b/evennia/contrib/game_systems/containers/tests.py index 5057c7695b..d52022f3c2 100644 --- a/evennia/contrib/game_systems/containers/tests.py +++ b/evennia/contrib/game_systems/containers/tests.py @@ -36,3 +36,16 @@ class TestContainerCmds(BaseEvenniaCommandTest): self.call(CmdPut(), "obj in box", "You put an Obj in a Box.") # get from the container 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.") + + + \ No newline at end of file