Added some more functionality to the copy method of objects, as well as some minor fixes.

This commit is contained in:
Griatch 2012-09-11 23:47:29 +02:00
parent 3c96dc9cc9
commit cc6fa079b6
3 changed files with 30 additions and 20 deletions

View file

@ -825,8 +825,20 @@ class ObjectDB(TypedObject):
<old_key>_copy by default.
Returns: Object (copy of this one)
"""
if not new_key:
new_key = "%s_copy" % self.key
def find_clone_key():
"""
Append 01, 02 etc to obj.key. Checks next higher number in the
same location, then adds the next number available
returns the new clone name on the form keyXX
"""
key = self.key
num = 1
for obj in (obj for obj in self.location.contents
if obj.key.startswith(key) and obj.key.lstrip(key).isdigit()):
num += 1
return "%s%02i" % (key, num)
new_key = new_key or find_clone_key(self)
return ObjectDB.objects.copy_object(self, new_key=new_key)
delete_iter = 0

View file

@ -389,15 +389,14 @@ class Object(TypeClass):
# controller, for example)
dbref = self.dbobj.dbref
self.locks.add("control:perm(Immortals)") # edit locks/permissions, delete
self.locks.add("examine:perm(Builders)") # examine properties
self.locks.add("view:all()") # look at object (visibility)
self.locks.add("edit:perm(Wizards)") # edit properties/attributes
self.locks.add("delete:perm(Wizards)") # delete object
self.locks.add("get:all()") # pick up object
self.locks.add("call:true()") # allow to call commands on this object
self.locks.add("puppet:id(%s) or perm(Immortals) or pperm(Immortals)" % dbref) # restricts puppeting of this object
self.locks.add(";".join("control:perm(Immortals)", # edit locks/permissions, delete
"examine:perm(Builders)", # examine properties
"view:all()", # look at object (visibility)
"edit:perm(Wizards)", # edit properties/attributes
"delete:perm(Wizards)", # delete object
"get:all()", # pick up object
"call:true()", # allow to call commands on this object
"puppet:id(%s) or perm(Immortals) or pperm(Immortals)" % dbref)) # restricts puppeting of this object
def basetype_posthook_setup(self):
"""
@ -721,9 +720,8 @@ class Character(Object):
overload the defaults (it is called after this one).
"""
super(Character, self).basetype_setup()
self.locks.add("get:false()") # noone can pick up the character
self.locks.add("call:false()") # no commands can be called on character from outside
self.locks.add(";".join("get:false()", # noone can pick up the character
"call:false()")) # no commands can be called on character from outside
# add the default cmdset
from settings import CMDSET_DEFAULT
self.cmdset.add_default(CMDSET_DEFAULT, permanent=True)
@ -790,10 +788,10 @@ class Room(Object):
"""
super(Room, self).basetype_setup()
self.locks.add("get:false();puppet:false()") # would be weird to puppet a room ...
self.locks.add(";".join("get:false()",
"puppet:false()")) # would be weird to puppet a room ...
self.location = None
#
# Exits
#
@ -886,9 +884,9 @@ class Exit(Object):
super(Exit, self).basetype_setup()
# setting default locks (overload these in at_object_creation()
self.locks.add("puppet:false()") # would be weird to puppet an exit ...
self.locks.add("traverse:all()") # who can pass through exit by default
self.locks.add("get:false()") # noone can pick up the exit
self.locks.add(";".join("puppet:false()", # would be weird to puppet an exit ...
"traverse:all()", # who can pass through exit by default
"get:false()")) # noone can pick up the exit
# an exit should have a destination (this is replaced at creation time)
if self.dbobj.location: