mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
messages, test additions
This commit is contained in:
parent
3c37fc099c
commit
9304c8ea29
2 changed files with 18 additions and 5 deletions
|
|
@ -190,7 +190,9 @@ class CmdContainerGet(CmdGet):
|
|||
if caller == obj:
|
||||
self.msg("You can't get yourself.")
|
||||
return
|
||||
if not obj.access(caller, "get"):
|
||||
|
||||
# check if this object can be gotten
|
||||
if not obj.access(caller, "get") or not obj.at_pre_get(caller):
|
||||
if obj.db.get_err_msg:
|
||||
self.msg(obj.db.get_err_msg)
|
||||
else:
|
||||
|
|
@ -199,9 +201,7 @@ class CmdContainerGet(CmdGet):
|
|||
|
||||
# calling possible at_pre_get_from hook on location
|
||||
if hasattr(location, "at_pre_get_from") and not location.at_pre_get_from(caller, obj):
|
||||
return
|
||||
# calling at_pre_get hook method
|
||||
if not obj.at_pre_get(caller):
|
||||
self.msg("You can't get that.")
|
||||
return
|
||||
|
||||
success = obj.move_to(caller, quiet=True, move_type="get")
|
||||
|
|
@ -270,10 +270,12 @@ class CmdPut(CmdDrop):
|
|||
|
||||
# Call the object script's at_pre_drop() method.
|
||||
if not obj.at_pre_drop(caller):
|
||||
self.msg("You can't put that down.")
|
||||
return
|
||||
|
||||
# Call the container's possible at_pre_put_in method.
|
||||
if hasattr(container, "at_pre_put_in") and not container.at_pre_put_in(caller, obj):
|
||||
self.msg("You can't put that there.")
|
||||
return
|
||||
|
||||
success = obj.move_to(container, quiet=True, move_type="drop")
|
||||
|
|
|
|||
|
|
@ -28,6 +28,9 @@ class TestContainerCmds(BaseEvenniaCommandTest):
|
|||
# make sure the object is in the container so we can look at it
|
||||
self.obj1.location = self.container
|
||||
self.call(CmdContainerLook(), "obj in box", "Obj")
|
||||
# move it into a non-container object and look at it there too
|
||||
self.obj1.location = self.obj2
|
||||
self.call(CmdContainerLook(), "obj in obj2", "Obj")
|
||||
|
||||
def test_get_and_put(self):
|
||||
# get normally
|
||||
|
|
@ -47,5 +50,13 @@ class TestContainerCmds(BaseEvenniaCommandTest):
|
|||
self.obj1.location = self.char1
|
||||
self.call(CmdPut(), "obj in box", "You can't put things in that.")
|
||||
|
||||
|
||||
def test_at_capacity_put(self):
|
||||
# set container capacity
|
||||
self.container.capacity = 1
|
||||
# move object to container to fill capacity
|
||||
self.obj2.location = self.container
|
||||
# move object to character to try putting
|
||||
self.obj1.location = self.char1
|
||||
self.call(CmdPut(), "obj in box", "You can't fit anything else in a Box.")
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue