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:
|
if caller == obj:
|
||||||
self.msg("You can't get yourself.")
|
self.msg("You can't get yourself.")
|
||||||
return
|
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:
|
if obj.db.get_err_msg:
|
||||||
self.msg(obj.db.get_err_msg)
|
self.msg(obj.db.get_err_msg)
|
||||||
else:
|
else:
|
||||||
|
|
@ -199,9 +201,7 @@ class CmdContainerGet(CmdGet):
|
||||||
|
|
||||||
# calling possible at_pre_get_from hook on location
|
# 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):
|
if hasattr(location, "at_pre_get_from") and not location.at_pre_get_from(caller, obj):
|
||||||
return
|
self.msg("You can't get that.")
|
||||||
# calling at_pre_get hook method
|
|
||||||
if not obj.at_pre_get(caller):
|
|
||||||
return
|
return
|
||||||
|
|
||||||
success = obj.move_to(caller, quiet=True, move_type="get")
|
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.
|
# Call the object script's at_pre_drop() method.
|
||||||
if not obj.at_pre_drop(caller):
|
if not obj.at_pre_drop(caller):
|
||||||
|
self.msg("You can't put that down.")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Call the container's possible at_pre_put_in method.
|
# 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):
|
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
|
return
|
||||||
|
|
||||||
success = obj.move_to(container, quiet=True, move_type="drop")
|
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
|
# make sure the object is in the container so we can look at it
|
||||||
self.obj1.location = self.container
|
self.obj1.location = self.container
|
||||||
self.call(CmdContainerLook(), "obj in box", "Obj")
|
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):
|
def test_get_and_put(self):
|
||||||
# get normally
|
# get normally
|
||||||
|
|
@ -47,5 +50,13 @@ class TestContainerCmds(BaseEvenniaCommandTest):
|
||||||
self.obj1.location = self.char1
|
self.obj1.location = self.char1
|
||||||
self.call(CmdPut(), "obj in box", "You can't put things in that.")
|
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