Fixed typeclass command check that used to fail with an old .typeclass check.
This commit is contained in:
parent
f77a650847
commit
77183a857e
1 changed files with 16 additions and 16 deletions
|
|
@ -1452,6 +1452,7 @@ class CmdTypeclass(MuxCommand):
|
||||||
@swap - this is a shorthand for using /force/reset flags.
|
@swap - this is a shorthand for using /force/reset flags.
|
||||||
|
|
||||||
Switch:
|
Switch:
|
||||||
|
show - display the current typeclass of object
|
||||||
reset - clean out *all* the attributes on the object -
|
reset - clean out *all* the attributes on the object -
|
||||||
basically making this a new clean object.
|
basically making this a new clean object.
|
||||||
force - change to the typeclass also if the object
|
force - change to the typeclass also if the object
|
||||||
|
|
@ -1459,6 +1460,9 @@ class CmdTypeclass(MuxCommand):
|
||||||
Example:
|
Example:
|
||||||
@type button = examples.red_button.RedButton
|
@type button = examples.red_button.RedButton
|
||||||
|
|
||||||
|
If the typeclass.path is not given, the current object's
|
||||||
|
typeclass is assumed.
|
||||||
|
|
||||||
View or set an object's typeclass. If setting, the creation hooks
|
View or set an object's typeclass. If setting, the creation hooks
|
||||||
of the new typeclass will be run on the object. If you have
|
of the new typeclass will be run on the object. If you have
|
||||||
clashing properties on the old class, use /reset. By default you
|
clashing properties on the old class, use /reset. By default you
|
||||||
|
|
@ -1493,24 +1497,21 @@ class CmdTypeclass(MuxCommand):
|
||||||
if not obj:
|
if not obj:
|
||||||
return
|
return
|
||||||
|
|
||||||
if not self.rhs:
|
if not hasattr(obj, "__dbclass__"):
|
||||||
# we did not supply a new typeclass, view the
|
string = "%s is not a typed object." % obj.name
|
||||||
# current one instead.
|
|
||||||
if hasattr(obj, "typeclass"):
|
|
||||||
string = "%s's current typeclass is '%s' (%s)." % (obj.name,
|
|
||||||
obj.typename, obj.path)
|
|
||||||
else:
|
|
||||||
string = "%s is not a typed object." % obj.name
|
|
||||||
caller.msg(string)
|
caller.msg(string)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
new_typeclass = self.rhs or obj.path
|
||||||
|
|
||||||
|
if "show" in self.switches:
|
||||||
|
string = "%s's current typeclass is %s." % (obj.name, obj.__class__)
|
||||||
|
return
|
||||||
|
|
||||||
if self.cmdstring == "@swap":
|
if self.cmdstring == "@swap":
|
||||||
self.switches.append("force")
|
self.switches.append("force")
|
||||||
self.switches.append("reset")
|
self.switches.append("reset")
|
||||||
|
|
||||||
# we have an =, a typeclass was supplied.
|
|
||||||
typeclass = self.rhs
|
|
||||||
|
|
||||||
if not obj.access(caller, 'edit'):
|
if not obj.access(caller, 'edit'):
|
||||||
caller.msg("You are not allowed to do that.")
|
caller.msg("You are not allowed to do that.")
|
||||||
return
|
return
|
||||||
|
|
@ -1519,15 +1520,15 @@ class CmdTypeclass(MuxCommand):
|
||||||
caller.msg("This object cannot have a type at all!")
|
caller.msg("This object cannot have a type at all!")
|
||||||
return
|
return
|
||||||
|
|
||||||
is_same = obj.is_typeclass(typeclass, exact=True)
|
is_same = obj.is_typeclass(new_typeclass, exact=True)
|
||||||
if is_same and not 'force' in self.switches:
|
if is_same and not 'force' in self.switches:
|
||||||
string = "%s already has the typeclass '%s'. Use /force to override." % (obj.name, typeclass)
|
string = "%s already has the typeclass '%s'. Use /force to override." % (obj.name, new_typeclass)
|
||||||
else:
|
else:
|
||||||
reset = "reset" in self.switches
|
reset = "reset" in self.switches
|
||||||
old_typeclass_path = obj.typeclass_path
|
old_typeclass_path = obj.typeclass_path
|
||||||
|
|
||||||
# we let this raise exception if needed
|
# we let this raise exception if needed
|
||||||
obj.swap_typeclass(typeclass, clean_attributes=reset)
|
obj.swap_typeclass(new_typeclass, clean_attributes=reset)
|
||||||
|
|
||||||
if is_same:
|
if is_same:
|
||||||
string = "%s updated its existing typeclass (%s).\n" % (obj.name, obj.path)
|
string = "%s updated its existing typeclass (%s).\n" % (obj.name, obj.path)
|
||||||
|
|
@ -1539,8 +1540,7 @@ class CmdTypeclass(MuxCommand):
|
||||||
if reset:
|
if reset:
|
||||||
string += " All old attributes where deleted before the swap."
|
string += " All old attributes where deleted before the swap."
|
||||||
else:
|
else:
|
||||||
string += " Note that the typeclassed object could have ended up with a mixture of old"
|
string += " Attributes set before swap were not removed."
|
||||||
string += "\nand new attributes. Use /reset to remove old attributes if you don't want this."
|
|
||||||
|
|
||||||
caller.msg(string)
|
caller.msg(string)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue