Expanded the property overload of dig and create by moving the entire lockstring into the property for easier overloading, pertaining to #1135.

This commit is contained in:
Griatch 2016-12-12 23:28:34 +01:00
parent 26bee8c751
commit 619a9cee57

View file

@ -468,7 +468,10 @@ class CmdCreate(ObjManipCommand):
key = "@create"
locks = "cmd:perm(create) or perm(Builders)"
help_category = "Building"
created_object_permission = "Wizards" # The permission level needed to control or delete the object if not the creator
# lockstring of newly created objects, for easy overloading.
# Will be formatted with the {id} of the creating object.
new_obj_lockstring = "control:id({id}) or perm(Wizards);delete:id({id}) or perm(Wizards)"
def func(self):
"""
@ -491,8 +494,7 @@ class CmdCreate(ObjManipCommand):
# create object (if not a valid typeclass, the default
# object typeclass will automatically be used)
lockstring = "control:id(%s) or perm(%s);delete:id(%s) or perm(%s)" % (caller.id,
self.created_object_permission, caller.id, self.created_object_permission)
lockstring = self.new_obj_lockstring.format(id=caller.id)
obj = create.create_object(typeclass, name, caller,
home=caller, aliases=aliases,
locks=lockstring, report_to=caller)
@ -717,7 +719,12 @@ class CmdDig(ObjManipCommand):
key = "@dig"
locks = "cmd:perm(dig) or perm(Builders)"
help_category = "Building"
created_room_permission = "Wizards" # The permission level needed to control, delete, or edit the room if not the creator
# lockstring of newly created rooms, for easy overloading.
# Will be formatted with the {id} of the creating object.
new_room_lockstring = "control:id({id}) or perm(Wizards); " \
"delete:id({id}) or perm(Wizards); " \
"edit:id({id}) or perm(Wizards)"
def func(self):
"Do the digging. Inherits variables from ObjManipCommand.parse()"
@ -744,13 +751,10 @@ class CmdDig(ObjManipCommand):
typeclass = settings.BASE_ROOM_TYPECLASS
# create room
lockstring = "control:id(%s) or perm(%s); delete:id(%s) or perm(%s); edit:id(%s) or perm(%s)"
lockstring = lockstring % (caller.dbref, self.created_room_permission, caller.dbref,
self.created_room_permission, caller.dbref, self.created_room_permission)
new_room = create.create_object(typeclass, room["name"],
aliases=room["aliases"],
report_to=caller)
lockstring = self.new_room_lockstring.format(id=caller.id)
new_room.locks.add(lockstring)
alias_string = ""
if new_room.aliases.all():